Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Commit dd41a60

Browse files
dmiusDmitry
authored andcommitted
Invalid options check + aws options check + tests
1 parent 9ca907e commit dd41a60

6 files changed

+39
-6
lines changed

nancy_run.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,13 @@ while true; do
235235
TMP_PATH="$2"; shift 2 ;;
236236
--debug-timeout )
237237
DEBUG_TIMEOUT="$2"; shift 2 ;;
238-
-- ) shift; break ;;
239-
* ) break ;;
238+
-- )
239+
>&2 echo "ERROR: Invalid option '$1'"
240+
exit 1;
241+
break ;;
242+
* )
243+
[ "$1" != "" ] && >&2 echo "ERROR: Invalid option '$1'. Please verify command options." && exit 1;
244+
break ;;
240245
esac
241246
done
242247

@@ -280,7 +285,6 @@ function checkPath() {
280285
if [[ $path =~ "file:///" ]]
281286
then
282287
path=${path/file:\/\//}
283-
echo "CHECK $path"
284288
if [ -f $path ]
285289
then
286290
eval "$1=\"$path\"" # update original variable
@@ -329,6 +333,13 @@ function checkParams() {
329333
>&2 echo "ERROR: AWS EC2 Instance type not given."
330334
exit 1
331335
fi
336+
elif [ "$RUN_ON" = "localhost" ]; then
337+
if [ ! -z ${AWS_KEY_PAIR+x} ] || [ ! -z ${AWS_KEY_PATH+x} ] ; then
338+
>&2 echo "WARNING: AWS keys given but run-on option has value 'localhost'."
339+
fi
340+
if [ ! -z ${AWS_EC2_TYPE+x} ]; then
341+
>&2 echo "WARNING: AWS instance type given but run-on option has value 'localhost'."
342+
fi
332343
fi
333344

334345
if [ -z ${PG_VERSION+x} ]

tests/nancy_run_invalid_aws_option.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
output=$(${BASH_SOURCE%/*}/../nancy run --run-on localhost --aws-keypair-name awskey --aws-ssh-key-path /path/.ssh/awskey.pem --aws-ec2-type i3.large 2>&1)
4+
5+
if [[ $output =~ "WARNING: AWS keys given but run-on option has value 'localhost'." ]] && [[ $output =~ "WARNING: AWS instance type given but run-on option has value 'localhost'." ]]; then
6+
echo -e "\e[36mOK\e[39m"
7+
else
8+
>&2 echo -e "\e[31mFAILED\e[39m"
9+
>&2 echo -e "Output: $output"
10+
exit 1
11+
fi

tests/nancy_run_invalid_option.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
output=$(${BASH_SOURCE%/*}/../nancy run --run-on-type test 2>&1)
4+
5+
if [[ $output =~ "ERROR: Invalid option '--run-on-type'. Please verify command options." ]]; then
6+
echo -e "\e[36mOK\e[39m"
7+
else
8+
>&2 echo -e "\e[31mFAILED\e[39m"
9+
>&2 echo -e "Output: $output"
10+
exit 1
11+
fi

tests/nancy_run_options_ddl_do+_undo-.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ read -r -d '' params <<PARAMS
88
--workload-full-path "s3://somebucket/db.sql.30min.pgreplay" \
99
--tmp-path tmp \
1010
--db-dump-path "s3://somebucket/dump.sql.bz2" \
11-
--target-ddl-do "create index i_zzz on sometable(col1);"
11+
--target-ddl-do "create\tindex\ti_zzz\ton\tsometable(col1);"
1212
PARAMS
1313

1414
output=$(${BASH_SOURCE%/*}/../nancy_run.sh $params 2>&1)

tests/nancy_run_options_ddl_do-_undo+.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ read -r -d '' params <<PARAMS
88
--workload-full-path "s3://somebucket/db.sql.30min.pgreplay" \
99
--tmp-path tmp \
1010
--db-dump-path "s3://somebucket/dump.sql.bz2" \
11-
--target-ddl-undo "drop index i_zzz;"
11+
--target-ddl-undo "drop\tindex\ti_zzz;"
1212
PARAMS
1313

1414
output=$(${BASH_SOURCE%/*}/../nancy_run.sh $params 2>&1)

tests/nancy_run_options_multi_workloads.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ read -r -d '' params <<PARAMS
66
--aws-ec2-type "r4.large" \
77
--s3cfg-path "/home/someuser/.s3cfg" \
88
--workload-full-path "s3://somebucket/db.sql.30min.pgreplay" \
9-
--workload-custom-sql "select now();" \
9+
--workload-custom-sql "select\tnow();" \
1010
--tmp-path tmp \
1111
--db-dump-path "s3://somebucket/dump.sql.bz2"
1212
PARAMS

0 commit comments

Comments
 (0)