commit.sim 2.4 KB
Newer Older
1 2 3 4 5 6
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2

print ========= start dnode1 as master
system sh/exec.sh -n dnode1 -s start
S
Shengliang Guan 已提交
7
system sh/exec.sh -n dnode2 -s start
8 9 10
sql connect

print ========= start other dnodes
S
Shengliang Guan 已提交
11 12 13 14 15 16 17 18 19 20
sql create dnode $hostname port 7200

$x = 0
step1:
	$ = $x + 1
	sleep 1000
	if $x == 10 then
	  print ====> dnode not ready!
		return -1
	endi
X
Xiaoyu Wang 已提交
21
sql select * from information_schema.ins_dnodes
S
Shengliang Guan 已提交
22 23 24 25 26 27 28 29 30 31 32
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
if $rows != 2 then
  return -1
endi
if $data(1)[4] != ready then
  goto step1
endi
if $data(2)[4] != ready then
  goto step1
endi
33 34

print ======== step1 create db
35
sql create database commitdb replica 1 duration 7 keep 30
36 37 38 39 40 41
sql use commitdb
sql create table tb (ts timestamp, i int)

$x = 1
while $x < 41
  $time = $x . m
G
Ganlin Zhao 已提交
42
  sql insert into tb values (now + $time , $x )
43
  $x = $x + 1
G
Ganlin Zhao 已提交
44
endw
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

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

G
Ganlin Zhao 已提交
74
$oldnum = $rows
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
$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
system sh/exec.sh -n dnode2 -s start

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
G
Ganlin Zhao 已提交
123
system sh/exec.sh -n dnode2 -s stop  -x SIGINT