alter_replica_31.sim 5.0 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 16 17 18 19 20 21 22 23 24 25
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
sql create dnode $hostname port 7300
sql create dnode $hostname port 7400

$x = 0
step1:
	$x = $x + 1
	sleep 1000
	if $x == 10 then
	  print ====> dnode not ready!
		return -1
	endi
X
Xiaoyu Wang 已提交
26
sql select * from information_schema.ins_dnodes
G
Ganlin Zhao 已提交
27
print ===> rows: $rows
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
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 step1
endi
if $data(2)[4] != ready then
  goto step1
endi
if $data(3)[4] != ready then
  goto step1
endi
if $data(4)[4] != ready then
  goto step1
endi

print =============== step2: create database
S
Shengliang Guan 已提交
49
sql create database db vgroups 4 replica 3
X
Xiaoyu Wang 已提交
50
sql select * from information_schema.ins_databases
G
Ganlin Zhao 已提交
51
if $rows != 3 then
52 53
  return -1
endi
G
Ganlin Zhao 已提交
54
if $data(db)[4] != 3 then
55 56 57 58
  return -1
endi

# vnodes
X
Xiaoyu Wang 已提交
59
sql select * from information_schema.ins_dnodes
S
Shengliang Guan 已提交
60
if $data(2)[2] != 4 then
61 62
  return -1
endi
S
Shengliang Guan 已提交
63
if $data(3)[2] != 4 then
64 65
  return -1
endi
S
Shengliang Guan 已提交
66
if $data(4)[2] != 4 then
67 68 69 70
  return -1
endi

# v1_dnode
71 72 73 74 75 76 77 78 79
$hasleader = 0
$x = 0
step2:
	$x = $x + 1
	sleep 1000
	if $x == 20 then
	  print ====> dnode not ready!
		return -1
	endi
80 81
sql show db.vgroups
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08
S
Shengliang Guan 已提交
82
if $data(2)[3] != 2 then
83 84 85 86 87
  return -1
endi
if $data(2)[5] != 3 then
  return -1
endi
S
Shengliang Guan 已提交
88
if $data(2)[7] != 4 then
89 90
  return -1
endi
91 92 93 94 95 96 97 98 99 100 101 102
if $data(2)[4] == leader then
  $hasleader = 1
endi
if $data(2)[6] == leader then
  $hasleader = 1
endi
if $data(2)[8] == leader then
  $hasleader = 1
endi
if $hasleader != 1 then
  goto step2
endi
103 104

sql create table db.stb (ts timestamp, c1 int, c2 binary(4)) tags(t1 int, t2 binary(16)) comment "abd"
S
Shengliang Guan 已提交
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
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")
125 126 127 128

sql show db.vgroups
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08

S
Shengliang Guan 已提交
129 130 131 132
sql select * from db.ctb0
if $rows != 1 then
  return -1
endi
133

S
Shengliang Guan 已提交
134
sql select * from db.ctb1
135 136 137 138
if $rows != 1 then
  return -1
endi

S
Shengliang Guan 已提交
139 140 141 142 143 144 145 146 147 148
sql select * from db.ctb2
if $rows != 1 then
  return -1
endi

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

149 150
print ============= step3: alter database
sql alter database db replica 1
S
Shengliang Guan 已提交
151
$wt = 0
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
 stepwt1:
 	$wt = $wt + 1
 	sleep 1000
 	if $wt == 200 then
 	  print ====> dnode not ready!
 		return -1
 	endi
sql show transactions
if $rows != 0 then
  print wait 1 seconds to alter
  goto stepwt1
endi

sql show db.vgroups
print ---> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print ---> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data27 $data28 $data29
print ---> $data10 $data11 $data12 $data13 $data14 $data15 $data26 $data37 $data38 $data39
print ---> $data10 $data11 $data12 $data13 $data14 $data15 $data36 $data47 $data48 $data49

S
Shengliang Guan 已提交
171
$hasleader = 0
172 173 174 175 176 177 178 179 180 181

$x = 0
step3:
	$x = $x + 1
	sleep 1000
	if $x == 10 then
	  print ====> dnode not ready!
		return -1
	endi
sql show db.vgroups
G
Ganlin Zhao 已提交
182
print ===> rows: $rows
S
Shengliang Guan 已提交
183
if $rows != 4 then
184 185
  goto step3
endi
S
Shengliang Guan 已提交
186 187
if $data(2)[4] == leader then
  $hasleader = 1
188
endi
S
Shengliang Guan 已提交
189 190 191 192 193
if $data(2)[6] == leader then
  $hasleader = 1
endi
if $data(2)[8] == leader then
  $hasleader = 1
194
endi
S
Shengliang Guan 已提交
195
if $hasleader != 1 then
196 197 198 199
  goto step3
endi

print ============= step5: stop dnode 2
S
Shengliang Guan 已提交
200 201 202 203 204 205
sql select * from db.ctb0
if $rows != 1 then
  return -1
endi

sql select * from db.ctb1
206 207 208 209
if $rows != 1 then
  return -1
endi

S
Shengliang Guan 已提交
210 211 212 213 214 215 216 217 218 219
sql select * from db.ctb2
if $rows != 1 then
  return -1
endi

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

220 221 222
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 已提交
223
system sh/exec.sh -n dnode4 -s stop -x SIGINT