keep.sim 2.6 KB
Newer Older
1 2 3 4 5 6
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect

print ======== step1 create db
S
Shengliang Guan 已提交
7
sql create database keepdb replica 1 keep 30 duration 7 vgroups 2
8 9 10 11 12 13
sql use keepdb
sql create table tb (ts timestamp, i int)

$x = 1
while $x < 41
  $time = $x . d
S
Shengliang Guan 已提交
14
  sql insert into tb values (now - $time , $x ) -x step2
S
Shengliang Guan 已提交
15
  step2:
16 17 18 19
  $x = $x + 1
endw 

sql select * from tb
S
Shengliang Guan 已提交
20
print ===> rows $rows last $data01
S
Shengliang Guan 已提交
21
if $rows >= 40 then
22 23 24 25 26 27 28 29
	return -1
endi

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

sql select * from tb
S
Shengliang Guan 已提交
30
print ===> rows $rows last $data01
31 32 33 34 35 36 37 38 39 40 41
if $rows >= 40 then
	return -1
endi
if $rows <= 20 then
	return -1
endi

$num1 = $rows + 40

print ======== step3 alter db
sql alter database keepdb keep 60
S
Shengliang Guan 已提交
42
sql flush database keepdb
43 44
sql show databases
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07
S
Shengliang Guan 已提交
45
if $data22 != 2 then 
46 47
  return -1
endi
S
Shengliang Guan 已提交
48
if $data27 != 86400m,86400m,86400m then 
49 50 51 52 53 54 55
  return -1
endi

print ======== step4 insert data
$x = 41
while $x < 81
  $time = $x . d
S
Shengliang Guan 已提交
56 57
  sql insert into tb values (now - $time , $x ) -x step4
  step4:
58 59 60 61
  $x = $x + 1
endw 

sql select * from tb
S
Shengliang Guan 已提交
62 63
print ===> rows $rows last $data01
if $rows >= 80 then
64 65
	return -1
endi
S
Shengliang Guan 已提交
66
if $rows <= 50 then
67 68 69
	return -1
endi

S
Shengliang Guan 已提交
70 71
return

72
print ======== step5 stop dnode
S
Shengliang Guan 已提交
73
system sh/exec.sh -n dnode2 -s stop -x SIGKILL
74 75 76
system sh/exec.sh -n dnode2 -s start

sql select * from tb
S
Shengliang Guan 已提交
77 78
print ===> rows $rows last $data01
if $rows >= 80 then
79 80 81 82 83 84 85 86 87
	return -1
endi
if $rows <= 50 then
	return -1
endi

print ======== step6 alter db
sql alter database keepdb keep 30
sql show databases
S
Shengliang Guan 已提交
88
if $data22 != 2 then 
89 90
  return -1
endi
S
Shengliang Guan 已提交
91
if $data27 != 43200m,43200m,43200m then 
92 93 94 95
  return -1
endi

print ======== step7 stop dnode
S
Shengliang Guan 已提交
96
system sh/exec.sh -n dnode2 -s stop -x SIGKILL
97 98 99
system sh/exec.sh -n dnode2 -s start

sql select * from tb
S
Shengliang Guan 已提交
100
print ===> rows $rows last $data01
101 102 103 104 105 106 107 108 109 110 111
if $rows >= 40 then
	return -1
endi
if $rows <= 20 then
	return -1
endi

print ======== step8 insert data
$x = 81
while $x < 121
  $time = $x . d
S
Shengliang Guan 已提交
112 113
  sql insert into tb values (now - $time , $x ) -x step4
  step4:
114 115 116 117
  $x = $x + 1
endw 

sql select * from tb
S
Shengliang Guan 已提交
118 119
print ===> rows $rows last $data01
if $rows >= 40 then
120 121
	return -1
endi
S
Shengliang Guan 已提交
122
if $rows <= 20 then
123 124 125 126 127 128 129 130 131 132 133 134
	return -1
endi

print ======== step9 alter db
sql alter database keepdb keep -1 -x error1
  return -1
error1:

sql alter database keepdb keep 0 -x error2
  return -1
error2:

135
sql alter database keepdb duration 1 -x error3
136 137 138 139
  return -1
error3:

print ======= test success
S
Shengliang Guan 已提交
140 141 142

system sh/exec.sh -n dnode1 -s stop  -x SIGINT
system sh/exec.sh -n dnode2 -s stop  -x SIGINT