-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathtest_sql.sh
More file actions
executable file
·159 lines (133 loc) · 4.52 KB
/
Copy pathtest_sql.sh
File metadata and controls
executable file
·159 lines (133 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/bash
if [ -z "$SKDB_BIN" ]; then
if [ -z "$SKARGO_PROFILE" ]; then
SKARGO_PROFILE=dev
fi
SKDB_BIN="skargo run -q --profile $SKARGO_PROFILE -- "
fi
export SKDB=$SKDB_BIN
run_one_test () {
printf "%-40s " "$2:"
out1=$(mktemp)
err1=$(mktemp)
out2=$(mktemp)
err2=$(mktemp)
# a parameterized test foo.sql expects arguments in foo_args.json and
# checks skdb on foo_args.json and foo.sql vs sqlite
args_file="${2%.*}"_args.json
if test -f "$args_file"; then
# shellcheck disable=SC2086 # $SKDB intentionally not quoted
cat "$args_file" "$2" | $1 $SKDB --always-allow-joins --expect-query-params 2> "$err1" | sort > "$out1"
stat1=${PIPESTATUS[1]}
cat <(test/params/json_args_to_sqlite_params.sh "$args_file") "$2" | $1 sqlite3 2> "$err2" | sort > "$out2"
stat2=${PIPESTATUS[1]}
else
# shellcheck disable=SC2086 # $SKDB intentionally not quoted
cat "$2" | $1 $SKDB --always-allow-joins 2> "$err1" | sort > "$out1"
stat1=${PIPESTATUS[1]}
cat "$2" | $1 sqlite3 2> "$err2" | sort > "$out2"
stat2=${PIPESTATUS[1]}
fi
if [ "$stat1" -eq 0 ]; then
if [ "$stat2" -eq 0 ]; then
diff "$out1" "$out2" > /dev/null
if [ $? -eq 0 ]; then
echo "OK"
else
echo "FAILED"
fi
else
echo "FAILED (only sqlite exited $stat2)"
diff "$err1" "$err2"
fi
else
if [ "$stat2" -eq 0 ]; then
echo "FAILED (only skdb exited $stat1)"
diff "$err1" "$err2"
else
echo "OK (both exited non-zero)"
fi
fi
}
export -f run_one_test
run_test () {
run_one_test "" "$1"
}
export -f run_test
if [ -n "$1" ]; then
if test -f "$1"; then
echo "RUNNING TEST: $1"
run_one_test time "$1"
else
echo "File does not exist: $1"
fi
exit 0
fi
echo ""
echo "*******************************************************************************"
echo "* UNIT TESTS *"
echo "*******************************************************************************"
echo ""
./unit_tests.sh
echo ""
echo "*******************************************************************************"
echo "* SKDB TESTS *"
echo "*******************************************************************************"
echo ""
parallel run_test ::: \
test/*.sql \
test/random/expr/*.sql \
test/random/select/*.sql \
test/random/groupby/*.sql \
test/random/aggregates/*.sql
echo ""
echo "*******************************************************************************"
echo "* SKDB TAIL TESTS *"
echo "*******************************************************************************"
echo ""
./test_tail_filter_param.sh
echo ""
echo "*******************************************************************************"
echo "* DATES *"
echo "*******************************************************************************"
echo ""
./test_date.sh
echo ""
echo "*******************************************************************************"
echo "* SKDB REPLICATION TESTS *"
echo "*******************************************************************************"
echo ""
./test_replication.sh
echo ""
echo "*******************************************************************************"
echo "* SKDB CONCURRENCY TESTS *"
echo "*******************************************************************************"
echo ""
for _ in {1..10}; do ./test_concurrent_sync.sh; done
for _ in {1..10}; do (cd ./test/concurrent/inserts/ && ./run.sh); done
for _ in {1..10}; do (cd ./test/concurrent/sum/ && ./run.sh); done
for _ in {1..10}; do (cd ./test/concurrent/sum_transaction/ && ./run.sh); done
echo ""
echo "*******************************************************************************"
echo "* PRIVACY *"
echo "*******************************************************************************"
echo ""
./test_privacy.sh
echo ""
echo "*******************************************************************************"
echo "* JSON *"
echo "*******************************************************************************"
echo ""
./test_json.sh
echo ""
echo "*******************************************************************************"
echo "* SKDB DIFF TESTS *"
echo "*******************************************************************************"
echo ""
./test_diff.sh
echo ""
echo "*******************************************************************************"
echo "* MEMORY *"
echo "*******************************************************************************"
echo ""
(cd ./test/memory/ && ./run.sh)