balance.sim 7.7 KB
Newer Older
S
slguan 已提交
1
system sh/stop_dnodes.sh
S
slguan 已提交
2
system sh/deploy.sh -n dnode1 -i 1
S
scripts  
Shengliang Guan 已提交
3 4
system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 4
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 1000
S
slguan 已提交
5

S
slguan 已提交
6
system sh/deploy.sh -n dnode2 -i 2
S
scripts  
Shengliang Guan 已提交
7 8
system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 1000
S
slguan 已提交
9

S
slguan 已提交
10
system sh/deploy.sh -n dnode3 -i 3
S
scripts  
Shengliang Guan 已提交
11 12
system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 1000
S
slguan 已提交
13

S
slguan 已提交
14
system sh/deploy.sh -n dnode4 -i 4
S
scripts  
Shengliang Guan 已提交
15 16
system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 1000
S
slguan 已提交
17

S
slguan 已提交
18
system sh/deploy.sh -n dnode5 -i 5
S
scripts  
Shengliang Guan 已提交
19 20
system sh/cfg.sh -n dnode5 -c maxVgroupsPerDb -v 4
system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 1000
S
slguan 已提交
21 22

print =============== prepare data
S
Shengliang Guan 已提交
23
system sh/exec.sh -n dnode1 -s start
S
slguan 已提交
24 25 26 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 53 54 55 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
sql connect

$i = 0
$tbNum = 4000
$rowNum = 1
$totalNum = 4000 * $rowNum

sql create database db
sql use db
sql create table mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int)

$i = 0
$tbPrefix = t
while $i < $tbNum
  $tb = $tbPrefix . $i
  sql create table $tb using mt tags( $i ) 
  $i = $i + 1
endw 

$i = 0
while $i < $tbNum
  $tb = $tbPrefix . $i
  sql insert into $tb values (now, $i , $i ) 
  
  $i = $i + 1
endw 

print ========== step0
sql show db.tables
if $rows != 4000 then
  return -1
endi

sql select count(*) from t10
print select count(*) from t10 $data00 expect $rowNum 
if $data00 != $rowNum then
  return -1
endi

sql select count(*) from t1010
print select count(*) from t1010 $data00 expect $rowNum 
if $data00 != $rowNum then
  return -1
endi

sql select count(*) from t2010
print select count(*) from t2010 $data00 expect $rowNum 
if $data00 != $rowNum then
  return -1
endi

sql select count(*) from t3010
print select count(*) from t3010 $data00 expect $rowNum 
if $data00 != $rowNum then
  return -1
endi

sql select count(*) from mt
print select count(*) from mt $data00 expect $rowNum 
if $data00 != $totalNum then
  return -1
endi

print ========== step1
S
slguan 已提交
88
sql create dnode $hostname2
S
Shengliang Guan 已提交
89
system sh/exec.sh -n dnode2 -s start
S
slguan 已提交
90 91 92 93

$x = 0
show1: 
	$x = $x + 1
S
Shengliang Guan 已提交
94 95
	sleep 1000
	if $x == 30 then 
S
slguan 已提交
96 97 98 99
		return -1
	endi
	
sql show dnodes
S
scripts  
Shengliang Guan 已提交
100 101 102
print dnode1 openvnodes $data2_1
print dnode2 openvnodes $data2_2
if $data2_1 != 2 then
S
slguan 已提交
103 104
	goto show1
endi
S
scripts  
Shengliang Guan 已提交
105
if $data2_2 != 2 then
S
slguan 已提交
106 107 108
	goto show1
endi

S
scripts  
Shengliang Guan 已提交
109
sql reset query cache
S
Shengliang Guan 已提交
110
sleep 100
S
scripts  
Shengliang Guan 已提交
111

S
slguan 已提交
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
sql select count(*) from t10
print select count(*) from t10 $data00 expect $rowNum 
if $data00 != $rowNum then
  goto show1
endi

sql select count(*) from t1010
print select count(*) from t1010 $data00 expect $rowNum 
if $data00 != $rowNum then
  goto show1
endi

sql select count(*) from t2010
print select count(*) from t2010 $data00 expect $rowNum 
if $data00 != $rowNum then
  goto show1
endi

sql select count(*) from t3010
print select count(*) from t3010 $data00 expect $rowNum 
if $data00 != $rowNum then
  goto show1
endi

sql select count(*) from mt
print select count(*) from mt $data00 expect $rowNum 
if $data00 != $totalNum then
  goto show1
endi

print ========== step2
S
slguan 已提交
143
sql create dnode $hostname3
S
Shengliang Guan 已提交
144
system sh/exec.sh -n dnode3 -s start
S
slguan 已提交
145 146

print ========== step3
S
slguan 已提交
147
sql drop dnode $hostname2
S
slguan 已提交
148 149 150 151

$x = 0
show3: 
	$x = $x + 1
S
Shengliang Guan 已提交
152 153
	sleep 1000
	if $x == 30 then 
S
slguan 已提交
154 155 156 157
		return -1
	endi
	
sql show dnodes
S
scripts  
Shengliang Guan 已提交
158 159 160 161
print dnode1 freeVnodes $data2_1
print dnode2 freeVnodes $data2_2
print dnode3 freeVnodes $data2_3
if $data2_1 != 2 then
S
slguan 已提交
162 163
	goto show3
endi
S
scripts  
Shengliang Guan 已提交
164
if $data2_2 != null then
S
slguan 已提交
165 166
	goto show3
endi
S
scripts  
Shengliang Guan 已提交
167
if $data2_3 != 2 then
S
slguan 已提交
168 169 170
	goto show3
endi

S
Shengliang Guan 已提交
171
system sh/exec.sh -n dnode2 -s stop -x SIGINT
S
slguan 已提交
172

S
scripts  
Shengliang Guan 已提交
173
sql reset query cache
S
Shengliang Guan 已提交
174
sleep 100
S
scripts  
Shengliang Guan 已提交
175

S
slguan 已提交
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
sql select count(*) from t10
print select count(*) from t10 $data00 expect $rowNum 
if $data00 != $rowNum then
  return -1
endi

sql select count(*) from t1010
print select count(*) from t1010 $data00 expect $rowNum 
if $data00 != $rowNum then
  return -1
endi

sql select count(*) from t2010
print select count(*) from t2010 $data00 expect $rowNum 
if $data00 != $rowNum then
  return -1
endi

sql select count(*) from t3010
print select count(*) from t3010 $data00 expect $rowNum 
if $data00 != $rowNum then
  return -1
endi

sql select count(*) from mt
print select count(*) from mt $data00 expect $rowNum 
if $data00 != $totalNum then
  return -1
endi

print ========== step4
S
slguan 已提交
207
sql drop dnode $hostname3
S
slguan 已提交
208 209 210 211

$x = 0
show4: 
	$x = $x + 1
S
Shengliang Guan 已提交
212 213
	sleep 1000
	if $x == 30 then 
S
slguan 已提交
214 215 216 217
		return -1
	endi
	
sql show dnodes
S
scripts  
Shengliang Guan 已提交
218 219
print dnode1 freeVnodes $data2_1
print dnode3 freeVnodes $data2_3
S
scripts  
Shengliang Guan 已提交
220
if $data2_1 != 4 then
S
slguan 已提交
221 222
	goto show4
endi
S
scripts  
Shengliang Guan 已提交
223
if $data2_3 != null then
S
slguan 已提交
224 225 226
	goto show4
endi

S
Shengliang Guan 已提交
227
system sh/exec.sh -n dnode3 -s stop -x SIGINT
S
slguan 已提交
228

S
scripts  
Shengliang Guan 已提交
229
sql reset query cache
S
Shengliang Guan 已提交
230
sleep 100
S
scripts  
Shengliang Guan 已提交
231

S
slguan 已提交
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
sql select count(*) from t10
print select count(*) from t10 $data00 expect $rowNum 
if $data00 != $rowNum then
  return -1
endi

sql select count(*) from t1010
print select count(*) from t1010 $data00 expect $rowNum 
if $data00 != $rowNum then
  return -1
endi

sql select count(*) from t2010
print select count(*) from t2010 $data00 expect $rowNum 
if $data00 != $rowNum then
  return -1
endi

sql select count(*) from t3010
print select count(*) from t3010 $data00 expect $rowNum 
if $data00 != $rowNum then
  return -1
endi

sql select count(*) from mt
print select count(*) from mt $data00 expect $rowNum 
if $data00 != $totalNum then
  return -1
endi

print ========== step5
S
Shengliang Guan 已提交
263
system sh/exec.sh -n dnode4 -s start
S
scripts  
Shengliang Guan 已提交
264 265
sql create dnode $hostname4

S
Shengliang Guan 已提交
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
$x = 0
step5: 
	$x = $x + 1
	sleep 1000
	if $x == 10 then
		return -1
	endi

sql show dnodes
print dnode1 $data4_1
print dnode2 $data4_2
print dnode3 $data4_3
print dnode4 $data4_4

if $data4_4 != ready then
  goto step5
endi

S
scripts  
Shengliang Guan 已提交
284
sql alter database db replica 2
S
slguan 已提交
285 286 287 288

$x = 0
show5: 
	$x = $x + 1
S
Shengliang Guan 已提交
289 290
	sleep 1000
	if $x == 30 then 
S
slguan 已提交
291 292 293 294
		return -1
	endi
	
sql show dnodes
S
scripts  
Shengliang Guan 已提交
295 296
print dnode1 freeVnodes $data2_1
print dnode4 freeVnodes $data2_4
S
scripts  
Shengliang Guan 已提交
297
if $data2_1 != 4 then
S
slguan 已提交
298 299
	goto show5
endi
S
scripts  
Shengliang Guan 已提交
300
if $data2_4 != 4 then
S
slguan 已提交
301 302 303
	goto show5
endi

S
scripts  
Shengliang Guan 已提交
304
sql reset query cache
S
Shengliang Guan 已提交
305
sleep 100
S
scripts  
Shengliang Guan 已提交
306

S
slguan 已提交
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
sql select count(*) from t10
print select count(*) from t10 $data00 expect $rowNum 
if $data00 != $rowNum then
  goto show5
endi

sql select count(*) from t1010
print select count(*) from t1010 $data00 expect $rowNum 
if $data00 != $rowNum then
  goto show5
endi

sql select count(*) from t2010
print select count(*) from t2010 $data00 expect $rowNum 
if $data00 != $rowNum then
  goto show5
endi

sql select count(*) from t3010
print select count(*) from t3010 $data00 expect $rowNum 
if $data00 != $rowNum then
  goto show5
endi

sql select count(*) from mt
print select count(*) from mt $data00 expect $rowNum 
if $data00 != $totalNum then
  goto show5
endi
guanshengliang's avatar
scripts  
guanshengliang 已提交
336

S
scripts  
Shengliang Guan 已提交
337 338 339 340 341 342
print ========== step6
sql alter database db replica 1

$x = 0
show6: 
	$x = $x + 1
S
Shengliang Guan 已提交
343 344
	sleep 1000
	if $x == 30 then 
S
scripts  
Shengliang Guan 已提交
345 346 347 348 349 350 351 352 353 354 355 356 357 358
		return -1
	endi
	
sql show dnodes
print dnode1 freeVnodes $data2_1
print dnode4 freeVnodes $data2_4
if $data2_1 != 2 then
	goto show6
endi
if $data2_4 != 2 then
	goto show6
endi

sql reset query cache
S
Shengliang Guan 已提交
359
sleep 100
S
scripts  
Shengliang Guan 已提交
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391

sql select count(*) from t10
print select count(*) from t10 $data00 expect $rowNum 
if $data00 != $rowNum then
  goto show5
endi

sql select count(*) from t1010
print select count(*) from t1010 $data00 expect $rowNum 
if $data00 != $rowNum then
  goto show5
endi

sql select count(*) from t2010
print select count(*) from t2010 $data00 expect $rowNum 
if $data00 != $rowNum then
  goto show5
endi

sql select count(*) from t3010
print select count(*) from t3010 $data00 expect $rowNum 
if $data00 != $rowNum then
  goto show5
endi

sql select count(*) from mt
print select count(*) from mt $data00 expect $rowNum 
if $data00 != $totalNum then
  goto show5
endi


S
Shengliang Guan 已提交
392 393 394 395 396 397 398 399
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
system sh/exec.sh -n dnode4 -s stop  -x SIGINT
system sh/exec.sh -n dnode5 -s stop  -x SIGINT
system sh/exec.sh -n dnode6 -s stop  -x SIGINT
system sh/exec.sh -n dnode7 -s stop  -x SIGINT
system sh/exec.sh -n dnode8 -s stop  -x SIGINT