commit.sim 2.8 KB
Newer Older
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
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3

system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
system sh/cfg.sh -n dnode3 -c walLevel -v 2
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4

print ========= start dnode1 as master
system sh/exec.sh -n dnode1 -s start
sql connect
sleep 2000

print ========= start other dnodes
sql create dnode $hostname2
system sh/exec.sh -n dnode2 -s start
sleep 2000

print ======== step1 create db
27
sql create database commitdb replica 1 duration 7 keep 30
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
sql use commitdb
sql create table tb (ts timestamp, i int)

$x = 1
while $x < 41
  $time = $x . m
  sql insert into tb values (now + $time , $x ) 
  $x = $x + 1
endw 

sql select * from tb order by ts desc
print ===> rows $rows
print ===> last $data01

if $rows != 40 then
	return -1
endi
if $data01 != 40 then
	return -1
endi

print ======== step2 stop dnode
system sh/exec.sh -n dnode2 -s stop -x SIGINT
sleep 3000
system sh/exec.sh -n dnode2 -s start
sleep 3000

sql select * from tb order by ts desc
print ===> rows $rows
print ===> last $data01

if $rows != 40 then
	return -1
endi
if $data01 != 40 then
	return -1
endi

$oldnum = $rows 
$num = $rows + 2

print ======== step3 import old data
sql import into tb values (now - 10d , -10 )
  
sql import into tb values (now - 11d , -11 )

sql select * from tb order by ts desc
print ===> rows $rows expect $num
print ===> last $data01 expect  $data01

if $rows != $num then
	return -1
endi
if $data01 != 40 then
	return -1
endi

print ======== step4 import new data
sql_error import into tb values (now + 30d , 30 )
sql_error import into tb values (now + 31d , 31 )

sql select * from tb order by ts desc
print ===> rows $rows
print ===> last $data01

if $rows != $num then
	return -1
endi
if $data01 != 40 then
	return -1
endi

print ======== step5 stop dnode
system sh/exec.sh -n dnode2 -s stop -x SIGINT
sleep 3000
system sh/exec.sh -n dnode2 -s start
sleep 3000

sql select * from tb
print ===> rows $rows
print ===> last $data01

sql select * from tb order by ts desc
if $rows != $num then
	return -1
endi
if $data01 != 40 then
	return -1
endi

system sh/exec.sh -n dnode1 -s stop  -x SIGINT
system sh/exec.sh -n dnode2 -s stop  -x SIGINT
system sh/exec.sh -n dnode3 -s stop  -x SIGINT
system sh/exec.sh -n dnode4 -s stop  -x SIGINT
system sh/exec.sh -n dnode5 -s stop  -x SIGINT
system sh/exec.sh -n dnode6 -s stop  -x SIGINT
system sh/exec.sh -n dnode7 -s stop  -x SIGINT
system sh/exec.sh -n dnode8 -s stop  -x SIGINT