commit.sim 2.4 KB
Newer Older
S
slguan 已提交
1
system sh/stop_dnodes.sh
S
slguan 已提交
2 3 4 5 6 7



system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
S
slguan 已提交
8

S
slguan 已提交
9 10 11
system sh/cfg.sh -n dnode1 -c commitLog -v 2
system sh/cfg.sh -n dnode2 -c commitLog -v 2
system sh/cfg.sh -n dnode3 -c commitLog -v 2
S
slguan 已提交
12 13 14 15 16 17 18 19
system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1
system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1
system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1
system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4

print ========= start dnode1 as master
S
slguan 已提交
20
system sh/exec_up.sh -n dnode1 -s start
S
slguan 已提交
21 22 23 24
sql connect
sleep 3000

print ========= start other dnodes
S
slguan 已提交
25
sql create dnode $hostname2
S
slguan 已提交
26
system sh/exec_up.sh -n dnode2 -s start
S
slguan 已提交
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
sleep 3000

print ======== step1 create db
sql create database commitdb replica 1 days 7 keep 30
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
S
slguan 已提交
53
system sh/exec_up.sh -n dnode2 -s stop -x SIGINT
S
slguan 已提交
54
sleep 5000
S
slguan 已提交
55
system sh/exec_up.sh -n dnode2 -s start
S
slguan 已提交
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
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
print ===> last $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
S
slguan 已提交
104
system sh/exec_up.sh -n dnode2 -s stop -x SIGINT
S
slguan 已提交
105
sleep 5000
S
slguan 已提交
106
system sh/exec_up.sh -n dnode2 -s start
S
slguan 已提交
107 108 109 110 111 112 113 114 115 116 117 118 119 120
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