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

Commit 6b1fda5

Browse files
committed
CI: tests for prepare-workload, dependencies checks
1 parent d39c0f3 commit 6b1fda5

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
- run:
99
name: Install software
1010
command: |
11-
apt-get update && apt-get install -y sudo wget jq pgreplay \
11+
apt-get update && apt-get install -y sudo wget jq \
1212
&& wget get.docker.com -q -S -O - | sudo sh
1313
- checkout
1414
- setup_remote_docker

nancy_prepare_workload.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ if [ -z ${OUTPUT+x} ]; then
6060
exit 1;
6161
fi
6262

63+
awk_version=$((awk -Wversion 2>/dev/null || awk --version) | head -n1)
64+
if [ "${awk_version:0:3}" != "GNU" ]; then
65+
>&2 echo "ERROR: GNU awk is required. Your awk version is: ${awk_version}. Try to install gawk."
66+
exit 1;
67+
fi
68+
69+
pgreplay_version=$(pgreplay -v 2>/dev/null)
70+
if [ "${pgreplay_version:0:8}" != "pgreplay" ]; then
71+
>&2 echo "ERROR: pgreplay is not installed."
72+
exit 1;
73+
fi
74+
6375
cat $INPUT \
6476
| sed -r 's/^([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3} .*)$/\nNANCY_NEW_LINE_SEPARATOR\n\1/' \
6577
| sed "s/\"\"/NANCY_TWO_DOUBLE_QUOTES_SEPARATOR/g" \

tests/nancy_prepare_workload.sh

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

3-
export PATH=$PATH:${BASH_SOURCE%/*}/..
3+
# CAUTION: these checks will definitely not work on non-Debian(Ubuntu) machines,
4+
# In general, all this script is very fragile. TODO improve
5+
6+
failures=0
7+
8+
output=$( \
9+
nancy prepare-workload --db-name testci \
10+
--output ./test.replay ./.circleci/sample.log \
11+
2>&1
12+
)
13+
if [ "${output:0:27}" != "ERROR: GNU awk is required." ]; then
14+
failures=$((failures+1))
15+
fi
16+
17+
sudo apt-get install gawk # only Ubuntu/Debian! TODO
418

519
output=$( \
620
nancy prepare-workload --db-name testci \
721
--output ./test.replay ./.circleci/sample.log \
822
2>&1
923
)
24+
if [ "${output:0:33}" != "ERROR: pgreplay is not installed." ]; then
25+
failures=$((failures+1))
26+
echo "out: $output"
27+
fi
1028

29+
sudo apt-get install pgreplay # only Ubuntu/Debian! TODO
30+
31+
output=$( \
32+
nancy prepare-workload --db-name testci \
33+
--output ./test.replay ./.circleci/sample.log \
34+
2>&1
35+
)
1136
if [[ $output =~ "Total SQL statements processed: 2" ]]; then
37+
:
38+
else
39+
failures=$((failures+1))
40+
fi
41+
42+
if [ "$failures" -eq "0" ]; then
1243
echo -e "\e[36mOK\e[39m"
1344
else
1445
>&2 echo -e "\e[31mFAILED\e[39m"
15-
>&2 echo -e "Output: $output"
46+
>&2 echo -e "$failures/3 of checks failed"
1647
exit 1
1748
fi
1849

0 commit comments

Comments
 (0)