distributeInterval0.sim 12.9 KB
Newer Older
5
54liuyao 已提交
1 2 3 4 5 6 7
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1

system sh/exec.sh -n dnode1 -s start 
sleep 50
sql connect

L
liuyao 已提交
8

L
liuyao 已提交
9

10
print ===== step2
11 12
sql drop stream if exists stream_t1;
sql drop database if exists test;
5
54liuyao 已提交
13 14 15 16 17 18 19
sql create database test  vgroups 4;
sql use test;
sql create stable st(ts timestamp, a int, b int , c int, d double) tags(ta int,tb int,tc int);
sql create table ts1 using st tags(1,1,1);
sql create table ts2 using st tags(2,2,2);
sql create table ts3 using st tags(3,2,2);
sql create table ts4 using st tags(4,2,2);
L
liuyao 已提交
20
sql create stream stream_t1 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 watermark 1d into streamtST1 as select  _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b)  c4, min(c) c5 from st interval(10s);
5
54liuyao 已提交
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

sleep 1000

sql insert into ts1 values(1648791213001,1,12,3,1.0);
sql insert into ts2 values(1648791213001,1,12,3,1.0);

sql insert into ts3 values(1648791213001,1,12,3,1.0);
sql insert into ts4 values(1648791213001,1,12,3,1.0);

sql insert into ts1 values(1648791213002,NULL,NULL,NULL,NULL);
sql insert into ts2 values(1648791213002,NULL,NULL,NULL,NULL);

sql insert into ts3 values(1648791213002,NULL,NULL,NULL,NULL);
sql insert into ts4 values(1648791213002,NULL,NULL,NULL,NULL);

L
liuyao 已提交
36 37 38 39
$loop_count = 0
loop0:

$loop_count = $loop_count + 1
L
liuyao 已提交
40
if $loop_count == 30 then
L
liuyao 已提交
41 42 43
  return -1
endi

dengyihao's avatar
dengyihao 已提交
44
sleep 1000
L
liuyao 已提交
45 46 47 48 49 50 51 52 53
print 1 select * from streamtST1;
sql select * from streamtST1;

if $rows != 1 then
  print =====rows=$rows
  goto loop0
endi

if $data01 != 8 then
L
liuyao 已提交
54
  print =1====data01=$data01
L
liuyao 已提交
55 56 57
  goto loop0
endi

5
54liuyao 已提交
58 59 60 61 62 63 64 65
sql insert into ts1 values(1648791223002,2,2,3,1.1);
sql insert into ts1 values(1648791233003,3,2,3,2.1);
sql insert into ts2 values(1648791243004,4,2,43,73.1);
sql insert into ts1 values(1648791213002,24,22,23,4.1);
sql insert into ts1 values(1648791243005,4,20,3,3.1);
sql insert into ts2 values(1648791243006,4,2,3,3.1) (1648791243007,4,2,3,3.1) ;
sql insert into ts1 values(1648791243008,4,2,30,3.1) (1648791243009,4,2,3,3.1)  (1648791243010,4,2,3,3.1)  ;
sql insert into ts2 values(1648791243011,4,2,3,3.1) (1648791243012,34,32,33,3.1)  (1648791243013,4,2,3,3.1) (1648791243014,4,2,13,3.1);
L
liuyao 已提交
66 67 68 69 70

$loop_count = 0
loop01:

$loop_count = $loop_count + 1
L
liuyao 已提交
71
if $loop_count == 30 then
L
liuyao 已提交
72 73 74
  return -1
endi

L
liuyao 已提交
75
sleep 1000
L
liuyao 已提交
76 77 78 79 80 81 82 83 84
print 2 select * from streamtST1;
sql select * from streamtST1;

if $rows != 4 then
  print =====rows=$rows
  goto loop01
endi

if $data01 != 8 then
L
liuyao 已提交
85
  print =2====data01=$data01
L
liuyao 已提交
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
  goto loop01
endi

if $data11 != 1 then
  print =====data11=$data11
  goto loop01
endi

if $data21 != 1 then
  print =====data21=$data21
  goto loop01
endi

if $data31 != 11 then
  print =====data31=$data31
  goto loop01
endi

5
54liuyao 已提交
104
sql insert into ts1 values(1648791243005,4,42,3,3.1) (1648791243003,4,2,33,3.1) (1648791243006,4,2,3,3.1) (1648791213001,1,52,13,1.0) (1648791223001,22,22,83,1.1) ;
L
liuyao 已提交
105 106 107 108 109

$loop_count = 0
loop011:

$loop_count = $loop_count + 1
L
liuyao 已提交
110
if $loop_count == 30 then
L
liuyao 已提交
111 112 113
  return -1
endi

L
liuyao 已提交
114
sleep 1000
L
liuyao 已提交
115 116 117 118 119 120 121 122 123
print 3 select * from streamtST1;
sql select * from streamtST1;

if $rows != 4 then
  print =====rows=$rows
  goto loop011
endi

if $data01 != 8 then
L
liuyao 已提交
124
  print =3====data01=$data01
L
liuyao 已提交
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
  goto loop011
endi

if $data11 != 2 then
  print =====data11=$data11
  goto loop011
endi

if $data21 != 1 then
  print =====data21=$data21
  goto loop011
endi

if $data31 != 13 then
  print =====data31=$data31
  goto loop011
endi

5
54liuyao 已提交
143
sql insert into ts2 values(1648791243005,4,42,3,3.1) (1648791243003,4,2,33,3.1) (1648791243006,4,2,3,3.1) (1648791213001,1,52,13,1.0) (1648791223001,22,22,83,1.1) (1648791233004,13,12,13,2.1) ;
L
liuyao 已提交
144 145 146 147 148

$loop_count = 0
loop02:

$loop_count = $loop_count + 1
L
liuyao 已提交
149
if $loop_count == 30 then
L
liuyao 已提交
150 151 152
  return -1
endi

L
liuyao 已提交
153
sleep 1000
L
liuyao 已提交
154 155 156 157 158 159 160 161 162
print 4 select * from streamtST1;
sql select * from streamtST1;

if $rows != 4 then
  print =====rows=$rows
  goto loop02
endi

if $data01 != 8 then
L
liuyao 已提交
163
  print =4====data01=$data01
L
liuyao 已提交
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
  goto loop02
endi

if $data11 != 3 then
  print =====data11=$data11
  goto loop02
endi

if $data21 != 2 then
  print =====data21=$data21
  goto loop02
endi

if $data31 != 15 then
  print =====data31=$data31
  goto loop02
endi


5
54liuyao 已提交
183 184
sql insert into ts1 values(1648791243006,4,2,3,3.1) (1648791213001,1,52,13,1.0)  (1648791223001,22,22,83,1.1) ;

L
liuyao 已提交
185 186 187 188
$loop_count = 0
loop03:

$loop_count = $loop_count + 1
L
liuyao 已提交
189
if $loop_count == 30 then
L
liuyao 已提交
190 191 192
  return -1
endi

L
liuyao 已提交
193
sleep 1000
L
liuyao 已提交
194 195 196 197 198 199 200 201 202
print 5 select * from streamtST1;
sql select * from streamtST1;

if $rows != 4 then
  print =====rows=$rows
  goto loop03
endi

if $data01 != 8 then
L
liuyao 已提交
203
  print =5====data01=$data01
L
liuyao 已提交
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
  goto loop03
endi

if $data11 != 3 then
  print =====data11=$data11
  goto loop03
endi

if $data21 != 2 then
  print =====data21=$data21
  goto loop03
endi

if $data31 != 15 then
  print =====data31=$data31
  goto loop03
endi

5
54liuyao 已提交
222 223 224 225
sql insert into ts3 values(1648791223002,2,2,3,1.1);
sql insert into ts4 values(1648791233003,3,2,3,2.1);
sql insert into ts3 values(1648791243004,4,2,43,73.1);
sql insert into ts4 values(1648791213002,24,22,23,4.1);
L
liuyao 已提交
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248

$loop_count = 0
loop032:

$loop_count = $loop_count + 1
if $loop_count == 30 then
  return -1
endi

sleep 1000
print 6-0 select * from streamtST1;
sql select * from streamtST1;

if $rows != 4 then
  print =====rows=$rows
  goto loop032
endi

if $data01 != 8 then
  print =6====data01=$data01
  goto loop032
endi

5
54liuyao 已提交
249 250 251 252
sql insert into ts3 values(1648791243005,4,20,3,3.1);
sql insert into ts4 values(1648791243006,4,2,3,3.1) (1648791243007,4,2,3,3.1) ;
sql insert into ts3 values(1648791243008,4,2,30,3.1) (1648791243009,4,2,3,3.1)  (1648791243010,4,2,3,3.1)  ;
sql insert into ts4 values(1648791243011,4,2,3,3.1) (1648791243012,34,32,33,3.1)  (1648791243013,4,2,3,3.1) (1648791243014,4,2,13,3.1);
L
liuyao 已提交
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275

$loop_count = 0
loop033:

$loop_count = $loop_count + 1
if $loop_count == 30 then
  return -1
endi

sleep 1000
print 6-1 select * from streamtST1;
sql select * from streamtST1;

if $rows != 4 then
  print =====rows=$rows
  goto loop033
endi

if $data01 != 8 then
  print =6====data01=$data01
  goto loop033
endi

5
54liuyao 已提交
276
sql insert into ts3 values(1648791243005,4,42,3,3.1) (1648791243003,4,2,33,3.1) (1648791243006,4,2,3,3.1) (1648791213001,1,52,13,1.0) (1648791223001,22,22,83,1.1) ;
L
liuyao 已提交
277 278 279 280 281

$loop_count = 0
loop04:

$loop_count = $loop_count + 1
L
liuyao 已提交
282
if $loop_count == 30 then
L
liuyao 已提交
283 284 285
  return -1
endi

L
liuyao 已提交
286
sleep 1000
L
liuyao 已提交
287 288 289 290 291 292 293 294 295
print 6 select * from streamtST1;
sql select * from streamtST1;

if $rows != 4 then
  print =====rows=$rows
  goto loop04
endi

if $data01 != 8 then
L
liuyao 已提交
296
  print =6====data01=$data01
L
liuyao 已提交
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
  goto loop04
endi

if $data11 != 5 then
  print =====data11=$data11
  goto loop04
endi

if $data21 != 3 then
  print =====data21=$data21
  goto loop04
endi

if $data31 != 28 then
  print =====data31=$data31
  goto loop04
endi

5
54liuyao 已提交
315 316 317 318 319
sql insert into ts4 values(1648791243005,4,42,3,3.1) (1648791243003,4,2,33,3.1) (1648791243006,4,2,3,3.1) (1648791213001,1,52,13,1.0) (1648791223001,22,22,83,1.1) (1648791233004,13,12,13,2.1) ;
sql insert into ts3 values(1648791243006,4,2,3,3.1) (1648791213001,1,52,13,1.0)  (1648791223001,22,22,83,1.1) ;

$loop_count = 0
loop1:
L
liuyao 已提交
320
sleep 1000
5
54liuyao 已提交
321 322 323
sql select * from streamtST1;

$loop_count = $loop_count + 1
L
liuyao 已提交
324
if $loop_count == 30 then
5
54liuyao 已提交
325 326 327 328 329
  return -1
endi

# row 0
if $data01 != 8 then
L
liuyao 已提交
330
  print =7====data01=$data01
5
54liuyao 已提交
331 332 333
  goto loop1
endi

H
Haojun Liao 已提交
334
if $data02 != 6 then
5
54liuyao 已提交
335 336 337 338
  print =====data02=$data02
  goto loop1
endi

H
Haojun Liao 已提交
339 340
if $data03 != 52 then
  print ======data03=$data03
5
54liuyao 已提交
341
  goto loop1
5
54liuyao 已提交
342 343 344
endi

if $data04 != 52 then
H
Haojun Liao 已提交
345
  print ======data04=$data04
5
54liuyao 已提交
346
  goto loop1
5
54liuyao 已提交
347 348 349
endi

if $data05 != 13 then
H
Haojun Liao 已提交
350
  print ======data05=$data05
5
54liuyao 已提交
351
  goto loop1
5
54liuyao 已提交
352 353 354 355 356 357 358 359 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 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
endi

# row 1
if $data11 != 6 then
  print =====data11=$data11
  goto loop1
endi

if $data12 != 6 then
  print =====data12=$data12
  goto loop1
endi

if $data13 != 92 then
  print ======$data13
  return -1
endi

if $data14 != 22 then
  print ======$data14
  return -1
endi

if $data15 != 3 then
  print ======$data15
  return -1
endi

# row 2
if $data21 != 4 then
  print =====data21=$data21
  goto loop1
endi

if $data22 != 4 then
  print =====data22=$data22
  goto loop1
endi

if $data23 != 32 then
  print ======$data23
  return -1
endi

if $data24 != 12 then
  print ======$data24
  return -1
endi

if $data25 != 3 then
  print ======$data25
  return -1
endi

# row 3
if $data31 != 30 then
  print =====data31=$data31
  goto loop1
endi

if $data32 != 30 then
  print =====data32=$data32
  goto loop1
endi

if $data33 != 180 then
  print ======$data33
  return -1
endi

if $data34 != 42 then
  print ======$data34
  return -1
endi

if $data35 != 3 then
  print ======$data35
  return -1
endi

432
sql select  _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b)  c4, min(c) c5, avg(d) from st interval(10s);
5
54liuyao 已提交
433

5
54liuyao 已提交
434

435
sql create database test1  vgroups 4;
5
54liuyao 已提交
436 437 438 439
sql use test1;
sql create stable st(ts timestamp, a int, b int , c int) tags(ta int,tb int,tc int);
sql create table ts1 using st tags(1,1,1);
sql create table ts2 using st tags(2,2,2);
L
liuyao 已提交
440
sql create stream stream_t2 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 watermark 20s into streamtST1 as select  _wstart, count(*) c1, count(a) c2 , sum(a) c3 ,  max(b)  c5, min(c) c6 from st interval(10s) ;
5
54liuyao 已提交
441 442 443 444 445 446 447 448 449 450

sql insert into ts1 values(1648791211000,1,2,3);
sql insert into ts1 values(1648791222001,2,2,3);
sql insert into ts2 values(1648791211000,1,2,3);
sql insert into ts2 values(1648791222001,2,2,3);

$loop_count = 0
loop2:
sql select * from streamtST1;

L
liuyao 已提交
451
sleep 1000
5
54liuyao 已提交
452
$loop_count = $loop_count + 1
L
liuyao 已提交
453
if $loop_count == 30 then
5
54liuyao 已提交
454 455 456 457 458
  return -1
endi

# row 0
if $data01 != 2 then
L
liuyao 已提交
459
  print =8====data01=$data01
5
54liuyao 已提交
460 461 462 463 464 465 466 467 468
  goto loop2
endi

#rows 1
if $data11 != 2 then
  print =====data11=$data11
  goto loop2
endi

469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489
#max,min selectivity
sql create database test3  vgroups 4;
sql use test3;
sql create stable st(ts timestamp, a int, b int , c int) tags(ta int,tb int,tc int);
sql create table ts1 using st tags(1,1,1);
sql create table ts2 using st tags(2,2,2);
sql create stream stream_t3 trigger at_once into streamtST3 as select ts, min(a) c6, a, b, c, ta, tb, tc from st interval(10s) ;

sql insert into ts1 values(1648791211000,1,2,3);
sleep 50
sql insert into ts1 values(1648791222001,2,2,3);
sleep 50
sql insert into ts2 values(1648791211000,1,2,3);
sleep 50
sql insert into ts2 values(1648791222001,2,2,3);
sleep 50

$loop_count = 0
loop3:
sql select * from streamtST3;

L
liuyao 已提交
490
sleep 1000
491
$loop_count = $loop_count + 1
L
liuyao 已提交
492
if $loop_count == 30 then
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507
  return -1
endi

# row 0
if $data02 != 1 then
  print =====data02=$data02
  goto loop3
endi

# row 1
if $data12 != 2 then
  print =====data12=$data12
  goto loop3
endi

L
liuyao 已提交
508 509
return 1

L
liuyao 已提交
510 511 512 513 514 515 516 517 518 519 520 521
print ===== step3

sql drop database if exists test4;
sql create database test4  vgroups 10;
sql use test4;
sql create stable st(ts timestamp,a int,b int,c varchar(250) ) tags(ta int,tb int,tc int);
sql create table aaa using st tags(1,1,1);
sql create table bbb using st tags(2,2,2);
sql create table ccc using st tags(3,2,2);
sql create table ddd using st tags(4,2,2);


L
liuyao 已提交
522
sql create stream streams1 IGNORE EXPIRED 0 IGNORE UPDATE 0  fill_history 0 watermark 3s into streamst subtable(c) as select  _wstart, c , count(*) c1, last_row(b) c2  from st partition by c interval(1s) ;
L
liuyao 已提交
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557

sql insert into aaa values(1648791221001,2,2,"/a1/aa/aa");
sql insert into bbb values(1648791221001,2,2,"/a1/aa/aa");
sql insert into ccc values(1648791221001,2,2,"/a1/aa/aa");
sql insert into ddd values(1648791221001,2,2,"/a1/aa/aa");

sql insert into aaa values(1648791222002,2,2,"/a2/aa/aa");
sql insert into bbb values(1648791222002,2,2,"/a2/aa/aa");
sql insert into ccc values(1648791222002,2,2,"/a2/aa/aa");
sql insert into ddd values(1648791222002,2,2,"/a2/aa/aa");

sql insert into aaa values(1648791223003,2,2,"/a3/aa/aa");
sql insert into bbb values(1648791223003,2,2,"/a3/aa/aa");
sql insert into ccc values(1648791223003,2,2,"/a3/aa/aa");
sql insert into ddd values(1648791223003,2,2,"/a3/aa/aa");

sql insert into aaa values(1648791224003,2,2,"/a4/aa/aa");
sql insert into bbb values(1648791224003,2,2,"/a4/aa/aa");
sql insert into ccc values(1648791224003,2,2,"/a4/aa/aa");
sql insert into ddd values(1648791224003,2,2,"/a4/aa/aa");


sql insert into aaa values(1648791225003,2,2,"/a5/aa/aa");
sql insert into bbb values(1648791225003,2,2,"/a5/aa/aa");
sql insert into ccc values(1648791225003,2,2,"/a5/aa/aa");
sql insert into ddd values(1648791225003,2,2,"/a5/aa/aa");

sql insert into aaa values(1648791226003,2,2,"/a6/aa/aa");
sql insert into bbb values(1648791226003,2,2,"/a6/aa/aa");
sql insert into ccc values(1648791226003,2,2,"/a6/aa/aa");
sql insert into ddd values(1648791226003,2,2,"/a6/aa/aa");

$loop_count = 0

loop4:
L
liuyao 已提交
558
sleep 1000
L
liuyao 已提交
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575

$loop_count = $loop_count + 1
if $loop_count == 20 then
  return -1
endi

sql select * from streamst;

if $rows == 0 then
  goto loop4
endi

sql delete  from aaa where ts = 1648791223003 ;

$loop_count = 0

loop5:
L
liuyao 已提交
576
sleep 1000
L
liuyao 已提交
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594

$loop_count = $loop_count + 1
if $loop_count == 20 then
  return -1
endi

sql select * from streamst;

if $rows == 0 then
  goto loop5
endi


sql delete  from ccc;

$loop_count = 0

loop6:
L
liuyao 已提交
595
sleep 1000
L
liuyao 已提交
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612

$loop_count = $loop_count + 1
if $loop_count == 20 then
  return -1
endi

sql select * from streamst;

if $rows == 0 then
  goto loop6
endi

sql delete  from ddd;

$loop_count = 0

loop7:
L
liuyao 已提交
613
sleep 1000
L
liuyao 已提交
614 615 616 617 618 619 620 621 622 623 624 625 626 627

$loop_count = $loop_count + 1
if $loop_count == 20 then
  return -1
endi

sql select * from streamst;

if $rows == 0 then
  goto loop7
endi

print ===== over

L
Liu Jicong 已提交
628
system sh/stop_dnodes.sh