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

Commit cece627

Browse files
committed
CI: fix tests and make them work on macOS
1 parent e92c8ad commit cece627

15 files changed

+127
-92
lines changed

nancy_run.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,7 @@ function checkPath() {
410410
return 0 # we do not actually check S3 paths at the moment
411411
elif [[ $path =~ "file://" ]]; then
412412
dbg "$1 looks like a local file path."
413-
curdir=$(pwd)
414-
path=$curdir/${path/file:\/\//}
413+
path=${path/file:\/\//}
415414
if [[ -f $path ]]; then
416415
dbg "$path found."
417416
eval "$1=\"$path\"" # update original variable
@@ -729,7 +728,9 @@ function cleanupAndExit {
729728
sleep $KEEP_ALIVE
730729
fi
731730
msg "Remove temp files..." # if exists
732-
docker $dockerConfig exec -i ${containerHash} bash -c "sudo rm -rf $MACHINE_HOME"
731+
if [[ ! -z "${dockerConfig+x}" ]]; then
732+
docker $dockerConfig exec -i ${containerHash} bash -c "sudo rm -rf $MACHINE_HOME"
733+
fi
733734
rm -rf "$TMP_PATH"
734735
if [[ "$RUN_ON" == "localhost" ]]; then
735736
msg "Remove docker container"
@@ -750,7 +751,7 @@ function cleanupAndExit {
750751
trap cleanupAndExit EXIT
751752

752753
if [[ "$RUN_ON" == "localhost" ]]; then
753-
if [ -z ${CONTAINER_ID+x} ]; then
754+
if [[ -z ${CONTAINER_ID+x} ]]; then
754755
containerHash=$(docker run --name="pg_nancy_${CURRENT_TS}" \
755756
-v $TMP_PATH:/machine_home \
756757
-dit "postgresmen/postgres-with-stuff:pg${PG_VERSION}" \

tests/nancy_cli_run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export PATH=$PATH:${BASH_SOURCE%/*}/..
44

55
output=$(nancy run --run-on aws 2>&1)
66

7-
if [[ $output =~ "ERROR: AWS keys not given" ]]; then
7+
if [[ $output =~ "ERROR: AWS keypair name and ssh key file must be specified to run on AWS EC2." ]]; then
88
echo -e "\e[36mOK\e[39m"
99
else
1010
>&2 echo -e "\e[31mFAILED\e[39m"

tests/nancy_cli_run_no_optons.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
output=$(${BASH_SOURCE%/*}/../nancy run --run-on aws 2>&1)
44

5-
if [[ $output =~ "ERROR: AWS keys not given" ]]; then
5+
if [[ $output =~ "ERROR: AWS keypair name and ssh key file must be specified to run on AWS EC2." ]]; then
66
echo -e "\e[36mOK\e[39m"
77
else
88
>&2 echo -e "\e[31mFAILED\e[39m"

tests/nancy_run_no_options.sh renamed to tests/nancy_run_aws_no_keys.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
output=$(${BASH_SOURCE%/*}/../nancy_run.sh --run-on aws 2>&1)
44

5-
if [[ $output =~ "ERROR: AWS keys not given" ]]; then
5+
if [[ $output =~ "AWS keypair name and ssh key file must be specified" ]]; then
66
echo -e "\e[36mOK\e[39m"
77
else
88
>&2 echo -e "\e[31mFAILED\e[39m"

tests/nancy_run_before_init_code.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
#!/bin/bash
22

3-
output=$(${BASH_SOURCE%/*}/../nancy run \
4-
--sql-before-db-restore "select abs from beforeinittable;" \
5-
--workload-custom-sql "file://$srcDir/custom.sql" \
6-
--db-dump "file://$srcDir/test.dump.bz2" \
7-
--tmp-path $srcDir/tmp \
8-
2>&1)
3+
realpath() {
4+
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
5+
}
6+
7+
src_dir=$(dirname $(dirname $(realpath "$0")))"/.circleci"
8+
9+
output=$(
10+
${BASH_SOURCE%/*}/../nancy run \
11+
--sql-before-db-restore "select abs from beforeinittable;" \
12+
--workload-custom-sql "file://$src_dir/custom.sql" \
13+
--db-dump "file://$src_dir/test.dump.bz2" \
14+
--tmp-path $src_dir/tmp \
15+
2>&1
16+
)
917

1018
if [[ $output =~ "ERROR: relation \"beforeinittable\" does not exist" ]]; then
1119
echo -e "\e[36mOK\e[39m"

tests/nancy_run_ebs_disk_size.sh

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
#!/bin/bash
22

3-
output=$(${BASH_SOURCE%/*}/../nancy run \
4-
--debug \
5-
--ebs-volume-size 37 \
6-
2>&1)
3+
# TODO(NikolayS) -aws-ebs-volume-size requires "--run-on aws" – allow these tests in CI
74

8-
if [[ $output =~ "ebs-volume-size: 37" ]]; then
9-
echo -e "\e[36mOK\e[39m"
10-
else
11-
>&2 echo -e "\e[31mFAILED\e[39m"
12-
>&2 echo -e "Output: $output"
13-
exit 1
14-
fi
5+
#output=$(
6+
# ${BASH_SOURCE%/*}/../nancy run \
7+
# --debug \
8+
# --run-on aws \
9+
# --aws-ebs-volume-size 37 \
10+
# 2>&1
11+
#)
12+
#
13+
#if [[ $output =~ "ebs-volume-size: 37" ]]; then
14+
# echo -e "\e[36mOK\e[39m"
15+
#else
16+
# >&2 echo -e "\e[31mFAILED\e[39m"
17+
# >&2 echo -e "Output: $output"
18+
# exit 1
19+
#fi
Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
#!/bin/bash
22

3-
output=$(${BASH_SOURCE%/*}/../nancy run \
4-
--ebs-volume-size sa \
5-
--workload-custom-sql "file://$srcDir/custom.sql" \
6-
--db-dump "file://$srcDir/test.dump.bz2" \
7-
--tmp-path $srcDir/tmp \
8-
2>&1)
3+
realpath() {
4+
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
5+
}
96

10-
if [[ $output =~ "ERROR: ebs-volume-size must be integer." ]]; then
11-
echo -e "\e[36mOK\e[39m"
12-
else
13-
>&2 echo -e "\e[31mFAILED\e[39m"
14-
>&2 echo -e "Output: $output"
15-
exit 1
16-
fi
7+
src_dir=$(dirname $(dirname $(realpath "$0")))"/.circleci"
8+
9+
# TODO(NikolayS) -aws-ebs-volume-size requires "--run-on aws" – allow these tests in CI
10+
11+
#output=$(
12+
# ${BASH_SOURCE%/*}/../nancy run \
13+
# --run-on aws \
14+
# --aws-ebs-volume-size sa \
15+
# --workload-custom-sql "file://$src_dir/custom.sql" \
16+
# --db-dump "file://$src_dir/test.dump.bz2" \
17+
# --tmp-path $src_dir/tmp \
18+
# 2>&1
19+
#)
20+
#
21+
#if [[ $output =~ "ERROR: ebs-volume-size must be integer." ]]; then
22+
# echo -e "\e[36mOK\e[39m"
23+
#else
24+
# >&2 echo -e "\e[31mFAILED\e[39m"
25+
# >&2 echo -e "Output: $output"
26+
# exit 1
27+
#fi

tests/nancy_run_invalid_aws_option.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
#!/bin/bash
22

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)
3+
output=$(
4+
${BASH_SOURCE%/*}/../nancy run \
5+
--run-on localhost \
6+
--aws-keypair-name awskey \
7+
--aws-ssh-key-path /path/.ssh/awskey.pem \
8+
--aws-ec2-type i3.large \
9+
2>&1
10+
)
411

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
12+
if [[ $output =~ "must be used with '--run on aws'" ]]; then
613
echo -e "\e[36mOK\e[39m"
714
else
815
>&2 echo -e "\e[31mFAILED\e[39m"

tests/nancy_run_localhost_real_workload.sh

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
#!/bin/bash
22

3-
thisDir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
4-
parentDir="$(dirname "$thisDir")"
5-
srcDir="$parentDir/.circleci"
6-
if [ ! -d "$srcDir/tmp" ]; then
7-
mkdir "$srcDir/tmp"
8-
fi
9-
nancyRun="$parentDir/nancy_run.sh"
3+
realpath() {
4+
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
5+
}
6+
7+
src_dir=$(dirname $(dirname $(realpath "$0")))"/.circleci"
108

119
output=$(
12-
$nancyRun \
10+
${BASH_SOURCE%/*}/../nancy run \
1311
--db-dump "create table hello_world as select i, i as id from generate_series(1, 1000) _(i);" \
14-
--workload-real "file://$srcDir/sample.replay" \
15-
--tmp-path $srcDir/tmp 2>&1
12+
--workload-real "file://$src_dir/sample.replay" \
13+
--tmp-path $src_dir/tmp 2>&1
1614
)
1715

1816
regex="Queries:[[:blank:]]*1"

tests/nancy_run_localhost_simple_dump.sh

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
#!/bin/bash
22

3-
thisDir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
4-
parentDir="$(dirname "$thisDir")"
5-
srcDir="$parentDir/.circleci"
6-
if [ ! -d "$srcDir/tmp" ]; then
7-
mkdir "$srcDir/tmp"
8-
fi
9-
nancyRun="$parentDir/nancy_run.sh"
3+
realpath() {
4+
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
5+
}
6+
7+
src_dir=$(dirname $(dirname $(realpath "$0")))"/.circleci"
108

119
output=$(
12-
$nancyRun --workload-custom-sql "file://$srcDir/custom.sql" \
13-
--db-dump "file://$srcDir/test.dump.bz2" \
14-
--tmp-path $srcDir/tmp 2>&1
10+
${BASH_SOURCE%/*}/../nancy run \
11+
--workload-custom-sql "file://$src_dir/custom.sql" \
12+
--db-dump "file://$src_dir/test.dump.bz2" \
13+
--tmp-path $src_dir/tmp 2>&1
1514
)
1615

1716
regex="Errors:[[:blank:]]*0"

0 commit comments

Comments
 (0)