提交 34b9880b 编写于 作者: H Haozhou Wang 提交者: Adam Lee

s3ext: modify gpcheckcloud upload option syntax

1. change upload option -u -f to -u
2. update the usage help message
3. update gpcheckcloud regression tests

Signed-off-by: Kuien Liu, Peifeng Qiu
上级 03ae8296
......@@ -16,8 +16,8 @@ void printUsage(FILE *stream) {
"config=path_to_config_file\", to check the configuration.\n"
" gpcheckcloud -d \"s3://endpoint/bucket/prefix "
"config=path_to_config_file\", to download and output to stdout.\n"
" gpcheckcloud -u \"s3://endpoint/bucket/prefix "
"config=path_to_config_file\" -f \"/path/to/file\", to upload a file to S3.\n"
" gpcheckcloud -u \"/path/to/file\" \"s3://endpoint/bucket/prefix "
"config=path_to_config_file\", to upload a file to S3.\n"
" gpcheckcloud -t, to show the config template.\n"
" gpcheckcloud -h, to show this help.\n");
}
......@@ -27,18 +27,16 @@ map<char, string> parseCommandLineArgs(int argc, char *argv[]) {
int opt = 0;
map<char, string> optionPairs;
while ((opt = getopt(argc, argv, "c:d:u:f:ht")) != -1) {
while ((opt = getopt(argc, argv, "c:d:u:ht")) != -1) {
switch (opt) {
case 'c':
case 'd':
case 'u':
case 'f':
case 'h':
case 't':
if (optarg == NULL) {
optionPairs[opt] = "";
} else if (optarg[0] == '-') {
fprintf(stderr, "Failed. Invalid argument for -%c: '%s'\n\n", opt, optarg);
fprintf(stderr, "Failed. Invalid argument for -%c: '%s'.\n\n", opt, optarg);
printUsage(stderr);
exit(EXIT_FAILURE);
} else {
......@@ -46,6 +44,19 @@ map<char, string> parseCommandLineArgs(int argc, char *argv[]) {
}
break;
case 'u':
if (optarg == NULL) {
optionPairs[opt] = "";
} else if (optind + 1 == argc) {
optionPairs['f'] = optarg;
optionPairs['u'] = argv[optind];
} else {
fprintf(stderr, "Failed. Invalid arguments for -u, please check.\n\n");
printUsage(stderr);
exit(EXIT_FAILURE);
}
break;
default: // '?'
printUsage(stderr);
exit(EXIT_FAILURE);
......@@ -62,7 +73,7 @@ void validateCommandLineArgs(map<char, string> &optionPairs) {
if ((count == 2) && (optionPairs.size() == 2)) {
return;
} else if (count == 1) {
fprintf(stderr, "Failed. Option \'-u\' must work with \'-f\'\n\n");
fprintf(stderr, "Failed. Option \'-u\' must work with \'-f\'.\n\n");
printUsage(stderr);
exit(EXIT_FAILURE);
}
......
......@@ -12,8 +12,8 @@ MD5SUM_SMALL=`cat /tmp/gpcheckcloud.small |openssl md5 |cut -d ' ' -f 2`
MD5SUM_LARGE=`cat /tmp/gpcheckcloud.large |openssl md5 |cut -d ' ' -f 2`
echo "Uploading data..."
$GPCHECKCLOUD -u "s3://s3-us-west-2.amazonaws.com/s3test.pivotal.io/regress/s3write/$RANDOM_PREFIX/small/ config=/home/gpadmin/s3.conf" -f /tmp/gpcheckcloud.small
$GPCHECKCLOUD -u "s3://s3-us-west-2.amazonaws.com/s3test.pivotal.io/regress/s3write/$RANDOM_PREFIX/large/ config=/home/gpadmin/s3.conf" -f /tmp/gpcheckcloud.large
$GPCHECKCLOUD -u /tmp/gpcheckcloud.small "s3://s3-us-west-2.amazonaws.com/s3test.pivotal.io/regress/s3write/$RANDOM_PREFIX/small/ config=/home/gpadmin/s3.conf"
$GPCHECKCLOUD -u /tmp/gpcheckcloud.large "s3://s3-us-west-2.amazonaws.com/s3test.pivotal.io/regress/s3write/$RANDOM_PREFIX/large/ config=/home/gpadmin/s3.conf"
echo "Downloading and checking hashsum..."
CHECK_CASES=(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册