alter_replica_13.sim 4.6 KB
Newer Older
1 2 3 4 5
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/deploy.sh -n dnode4 -i 4
S
Shengliang Guan 已提交
6
system sh/cfg.sh -n dnode1 -c supportVnodes -v 0
7 8 9 10 11 12 13 14 15
system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode4 -s start
sql connect

print =============== step1: create dnodes
sql create dnode $hostname port 7200

S
Shengliang Guan 已提交
16
$x = 0
17
step1:
S
Shengliang Guan 已提交
18
	$ = $x + 1
19
	sleep 1000
S
Shengliang Guan 已提交
20
	if $x == 10 then
21 22 23
	  print ====> dnode not ready!
		return -1
	endi
X
Xiaoyu Wang 已提交
24
sql select * from information_schema.ins_dnodes
25 26 27 28 29 30 31 32 33 34 35 36 37
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

print =============== step2: create database
S
Shengliang Guan 已提交
38
sql create database db vgroups 4
X
Xiaoyu Wang 已提交
39
sql select * from information_schema.ins_databases
G
Ganlin Zhao 已提交
40
if $rows != 3 then
41 42
  return -1
endi
G
Ganlin Zhao 已提交
43
if $data(db)[4] != 1 then
44 45 46 47
  return -1
endi

# vnodes
X
Xiaoyu Wang 已提交
48
sql select * from information_schema.ins_dnodes
S
Shengliang Guan 已提交
49
if $data(2)[2] != 4 then
50 51 52 53 54 55 56 57 58 59
  return -1
endi

# v1_dnode
sql show db.vgroups
if $data(2)[3] != 2 then
  return -1
endi

sql_error alter database db replica 3
S
Shengliang Guan 已提交
60

61
sql create table db.stb (ts timestamp, c1 int, c2 binary(4)) tags(t1 int, t2 binary(16)) comment "abd"
S
Shengliang Guan 已提交
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
sql create table db.ctb0 using db.stb tags(100, "100")
sql create table db.ctb1 using db.stb tags(101, "101")
sql create table db.ctb2 using db.stb tags(102, "102")
sql create table db.ctb3 using db.stb tags(103, "103")
sql create table db.ctb4 using db.stb tags(104, "104")
sql create table db.ctb5 using db.stb tags(105, "105")
sql create table db.ctb6 using db.stb tags(106, "106")
sql create table db.ctb7 using db.stb tags(107, "107")
sql create table db.ctb8 using db.stb tags(108, "108")
sql create table db.ctb9 using db.stb tags(109, "109")
sql insert into db.ctb0 values(now, 0, "0")
sql insert into db.ctb1 values(now, 1, "1")
sql insert into db.ctb2 values(now, 2, "2")
sql insert into db.ctb3 values(now, 3, "3")
sql insert into db.ctb4 values(now, 4, "4")
sql insert into db.ctb5 values(now, 5, "5")
sql insert into db.ctb6 values(now, 6, "6")
sql insert into db.ctb7 values(now, 7, "7")
sql insert into db.ctb8 values(now, 8, "8")
sql insert into db.ctb9 values(now, 9, "9")
82 83 84 85 86

print =============== step3: create dnodes
sql create dnode $hostname port 7300
sql create dnode $hostname port 7400

S
Shengliang Guan 已提交
87
$x = 0
88
step3:
S
Shengliang Guan 已提交
89
	$x = $x + 1
90
	sleep 1000
S
Shengliang Guan 已提交
91
	if $x == 10 then
92 93 94
	  print ====> dnode not ready!
		return -1
	endi
X
Xiaoyu Wang 已提交
95
sql select * from information_schema.ins_dnodes
G
Ganlin Zhao 已提交
96
print ===> rows: $rows
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
print ===> $data30 $data31 $data32 $data33 $data24 $data35
if $rows != 4 then
  return -1
endi
if $data(1)[4] != ready then
  goto step3
endi
if $data(2)[4] != ready then
  goto step3
endi
if $data(3)[4] != ready then
  goto step3
endi
if $data(4)[4] != ready then
  goto step3
endi

print ============= step4: alter database
sql alter database db replica 3
S
Shengliang Guan 已提交
119

S
Shengliang Guan 已提交
120 121
$leaderIndex = 0

S
Shengliang Guan 已提交
122 123 124 125 126 127 128 129
$x = 0
step4:
	$x = $x + 1
	sleep 1000
	if $x == 10 then
	  print ====> dnode not ready!
		return -1
	endi
S
Shengliang Guan 已提交
130

S
Shengliang Guan 已提交
131
sql show db.vgroups
G
Ganlin Zhao 已提交
132
print ===> rows: $rows
S
Shengliang Guan 已提交
133
print ===> $data00 $data01 $data02 $data03 $data04 $data05
S
Shengliang Guan 已提交
134 135
if $data[0][4] == leader then
  $leaderIndex = 1
136
endi
S
Shengliang Guan 已提交
137 138
if $data[0][6] == leader then
  $leaderIndex = 2
139
endi
S
Shengliang Guan 已提交
140 141 142 143 144
if $data[0][8] == leader then
  $leaderIndex = 3
endi

if $$leaderIndex == 0 then
S
Shengliang Guan 已提交
145 146 147
  goto step4
endi

S
Shengliang Guan 已提交
148 149
print leaderIndex ==> $leaderIndex

S
Shengliang Guan 已提交
150 151
print ============= step5: result
$i = 0
S
Shengliang Guan 已提交
152
while $i < 10
S
Shengliang Guan 已提交
153 154 155
  $i = $i + 1

  sleep 1000
S
Shengliang Guan 已提交
156
  $leaderIndex2 = 0
S
Shengliang Guan 已提交
157 158
  sql show db.vgroups
  print ===> loop: $i | v0: $data03 $data04 | v1: $data05 $data06 | v2:  $data07 $data08 
S
Shengliang Guan 已提交
159 160
  if $data[0][4] == leader then
    $leaderIndex2 = 1
S
Shengliang Guan 已提交
161
  endi
162
  if $data[0][6] == leader then
S
Shengliang Guan 已提交
163
    $leaderIndex2 = 2
S
Shengliang Guan 已提交
164
  endi
165
  if $data[0][8] == leader then
S
Shengliang Guan 已提交
166 167 168 169 170
    $leaderIndex2 = 3
  endi

  print leaderIndex2 ==> $leaderIndex2
  if $leaderIndex2 != $leaderIndex then
S
Shengliang Guan 已提交
171 172
    return -1
  endi
S
Shengliang Guan 已提交
173

S
Shengliang Guan 已提交
174
endw 
175

S
Shengliang Guan 已提交
176 177 178 179 180
print ============= step5: check data
sql select * from db.ctb0
if $rows != 1 then
  return -1
endi
S
Shengliang Guan 已提交
181

S
Shengliang Guan 已提交
182
sql select * from db.ctb1
183 184 185 186
if $rows != 1 then
  return -1
endi

S
Shengliang Guan 已提交
187 188 189 190 191 192 193 194 195 196
sql select * from db.ctb2
if $rows != 1 then
  return -1
endi

sql select * from db.stb
if $rows != 10 then
  return -1
endi

197 198 199
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
G
Ganlin Zhao 已提交
200
system sh/exec.sh -n dnode4 -s stop -x SIGINT