Skip to content

Commit 292d4f8

Browse files
committed
Update test
Signed-off-by: mdouglas47 <[email protected]>
1 parent 95629ed commit 292d4f8

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
multitable_ddl 1
22
partitioned_table_merge_resume on
3+
test_sc_resume_race 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Failed kill_by_pidfile: pidfile /mdouglas47db.m4.pid does not exist

tests/sc_resume_partition.test/runit

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,39 @@ teardown() {
2828
cdb2sql ${CDB2_OPTIONS} ${dbnm} ${tier} "drop table ${tbl_name}"
2929
}
3030

31-
# Tests that the resume of partitioned table merge triggered by a crash or a downgrade completes correctly
32-
test_driver() {
33-
local -r tbl_name=$1 num_shards=$2 num_records_per_shard=$3 resume_trigger=$4
31+
do_resume() {
32+
local -r tbl_name=$1 num_shards=$2 num_records_inserted_per_shard_during_resume=$3 resume_trigger=$4
3433
local master
3534
master=`cdb2sql --tabs ${CDB2_OPTIONS} $dbnm ${tier} 'SELECT host FROM comdb2_cluster WHERE is_master="Y"'`
3635

3736
COMDB2_CONFIG_MIN_RETRIES=0 \
3837
COMDB2_CONFIG_MAX_RETRIES=0 \
3938
cdb2sql ${CDB2_OPTIONS} ${dbnm} ${tier} "alter table ${tbl_name} partitioned by none" &
4039
local -r waitpid=$!
41-
sleep 5
40+
sleep 2
4241

4342
#cdb2sql ${CDB2_OPTIONS} ${dbnm} ${tier} "rebuild ${tbl_name}" &
4443

45-
trigger_resume ${master} ${resume_trigger}
44+
# trigger_resume ${master} ${resume_trigger}
45+
echo "TRIGGER RESUME NOW"
46+
sleep 20
4647

4748
if wait ${waitpid};
4849
then
4950
echo "FAIL: Merge succeeded before master swing. Test is buggy."
5051
return 1
5152
fi
5253

53-
local -r num_records_inserted_per_shard_during_resume=1
5454
insert_records_into_table ${tbl_name} ${num_shards} ${num_records_inserted_per_shard_during_resume}
5555

5656
wait_for_outstanding_scs &> /dev/null
5757

58+
}
59+
60+
# Verifies that resume completed correctly
61+
verify() {
62+
local -r tbl_name=$1 num_shards=$2 num_records_per_shard=$3 num_records_inserted_per_shard_during_resume=$4
63+
5864
local timepart
5965
timepart=$(cdb2sql --tabs ${CDB2_OPTIONS} ${dbnm} ${tier} "select * from comdb2_timepartitions where name='${tbl_name}'")
6066
if [[ -n ${timepart} ]];
@@ -63,7 +69,7 @@ test_driver() {
6369
return 1
6470
fi
6571

66-
local -r expected_num_records=$(num_shards*num_records_per_shard+num_shards*num_records_inserted_per_shard_during_resume)
72+
local -r expected_num_records=$((num_shards*num_records_per_shard+num_shards*num_records_inserted_per_shard_during_resume))
6773
local actual_num_records
6874
actual_num_records=$(cdb2sql --tabs ${CDB2_OPTIONS} ${dbnm} ${tier} "select count(*) from ${tbl_name}")
6975
if (( actual_num_records != expected_num_records ));
@@ -75,23 +81,19 @@ test_driver() {
7581

7682
run_test() {
7783
local -r num_shards=$1 num_records_per_shard=$2 resume_trigger=$3 op_for_creating_partition=$4
78-
local -r tbl_name="t"
84+
local -r tbl_name="t" num_records_per_shard_inserted_during_resume=1
7985

8086
setup ${tbl_name} ${num_shards} ${num_records_per_shard} ${op_for_creating_partition}
81-
82-
test_driver ${tbl_name} ${num_shards} ${num_records_per_shard} ${resume_trigger}
83-
local -r rc=$?
84-
87+
do_resume ${tbl_name} ${num_shards} ${num_records_per_shard_inserted_during_resume} ${resume_trigger}
88+
verify ${tbl_name} ${num_shards} ${num_records_per_shard} ${num_records_per_shard_inserted_during_resume}
8589
teardown ${tbl_name}
86-
87-
return ${rc}
8890
}
8991

9092
main() {
9193
local -r num_shards=5
9294
for num_records_per_shard in 10000;
9395
do
94-
for resume_trigger in ${DOWNGRADE};
96+
for resume_trigger in ${CRASH};
9597
do
9698
for op_for_creating_partition in ${CREATE};
9799
do

tests/sc_resume_partition.test/util.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ wait_for_outstanding_scs() {
4242
}
4343

4444
create_table() {
45+
local -r tbl_name=$1
46+
4547
local starttime
4648
starttime=$(get_timestamp 120)
4749
#cdb2sql ${CDB2_OPTIONS} ${dbnm} ${tier} "create table ${tbl_name}(i int, j int)"
@@ -56,7 +58,7 @@ create_table() {
5658
}
5759

5860
insert_records_into_table() {
59-
local -r tbl_name=$1 num_shards=$2 num_records_per_shard=$3 op_for_creating_partitioned_table=$4
61+
local -r tbl_name=$1 num_shards=$2 num_records_per_shard=$3
6062
for i in $(seq 0 1 $((num_shards-1)));
6163
do
6264
local shard
@@ -77,7 +79,7 @@ trigger_resume() {
7779
elif (( resume_trigger == DOWNGRADE )); then
7880
downgrade ${master}
7981
else
80-
echo "FAIL: expected resume_trigger to be one of: KILL, DOWNGRADE"
82+
echo "FAIL: expected resume_trigger to be one of: CRASH, DOWNGRADE"
8183
return 1
8284
fi
8385
}

0 commit comments

Comments
 (0)