forked from bloomberg/comdb2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunit
executable file
·60 lines (46 loc) · 1.39 KB
/
runit
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
#!/usr/bin/env bash
source ${TESTSROOTDIR}/tools/runit_common.sh
source ${TESTSROOTDIR}/tools/cluster_utils.sh
set -ex
[ -z "${CLUSTER}" ] && { echo "Test requires a cluster"; exit 0; }
dbnm=$1
restart_cluster() {
set +e
for node in ${CLUSTER} ; do
kill_restart_node ${node} &
done
set -e
sleep 2
wait_for_cluster
}
test_partition_merge_resume() {
# Given
local starttime
starttime=$(get_timestamp 120)
local master
master=`cdb2sql --tabs ${CDB2_OPTIONS} $dbnm default 'SELECT host FROM comdb2_cluster WHERE is_master="Y"'`
cdb2sql $dbnm --host $master "EXEC PROCEDURE sys.cmd.send('convert_record_sleep 1')"
cdb2sql ${CDB2_OPTIONS} ${dbnm} default "create table t(a int) partitioned by time period 'daily' retention 2 start '${starttime}'"
cdb2sql ${CDB2_OPTIONS} $dbnm default "insert into t values (1)"
# When
cdb2sql ${CDB2_OPTIONS} ${dbnm} default "alter table t partitioned by none" &
waitpid=$!
sleep 1
restart_cluster &> /dev/null
# Then
if wait ${waitpid};
then
echo "FAIL: Merge succeeded before cluster bounced. Test is buggy."
return 1
fi
local timepart
timepart=$(cdb2sql --tabs ${CDB2_OPTIONS} ${dbnm} default "select * from comdb2_timepartitions where name='t'")
if [[ -z ${timepart} ]];
then
echo "FAIL: Could not find expected time partition"
return 1
fi
# Cleanup
cdb2sql ${CDB2_OPTIONS} ${dbnm} default "drop table t"
}
test_partition_merge_resume