-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathtest_concurrent_sync.sh
More file actions
executable file
·48 lines (39 loc) · 1.21 KB
/
Copy pathtest_concurrent_sync.sh
File metadata and controls
executable file
·48 lines (39 loc) · 1.21 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
#!/bin/bash
pass() { printf "%-20s OK\n" "$1:"; }
fail() { printf "%-20s FAILED\n" "$1:"; }
if [ -z "$SKDB_BIN" ]; then
if [ -z "$SKARGO_PROFILE" ]; then
SKARGO_PROFILE=dev
fi
SKDB_BIN="skargo run -q --manifest-path ./sql/Skargo.toml --profile $SKARGO_PROFILE -- "
fi
SKDB=$SKDB_BIN
# Test that launches a bunch of unix process that insert numbers in a table
# concurrently. We check at the end that the sum of the numbers is correct.
rm -f /tmp/test_data
$SKDB --init /tmp/test_data
echo 'create table t1(a INTEGER);' | $SKDB --data /tmp/test_data
for i in {0..100}
do
command="/tmp/cmd$i.sql"
rm -f "$command"
for j in $(seq $((i * 100)) $(((i+1) * 100)))
do
echo "INSERT INTO t1 VALUES($j);" >> "/tmp/cmd$i.sql"
done
# UNCOMMENT THIS IF YOU WANT A CORE DUMP
# ulimit -c unlimited
cat "$command" | $SKDB --data /tmp/test_data &
# if [[ $? -eq 139 ]]; then
# gdb -q $SKDB core -x /tmp/backtrace
# fi
done
wait
echo "SELECT * FROM t1;" | $SKDB --data /tmp/test_data > /tmp/test_result
sum=$(cat /tmp/test_result | grep -E '^[0-9]+$' | awk '{x += $1} END {print x}')
if [[ sum -eq 51515050 ]]
then
pass "CONCURRENT SYNC"
else
fail "CONCURRENT SYNC"
fi