homework-jianmu/tests/script/tsim/stream/state1.sim

158 lines
3.1 KiB
Plaintext

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
print step 1
print =============== create database
sql create database test vgroups 4;
sql select * from information_schema.ins_databases;
if $rows != 3 then
return -1
endi
print $data00 $data01 $data02
sql use test;
sql create table t1(ts timestamp, a int, b int , c int, d double, id int);
print create stream streams1 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt1 as select _wstart, count(*) c1 from t1 state_window(a);
sql create stream streams1 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt1 as select _wstart, count(*) c1 from t1 state_window(a);
sql insert into t1(ts) values(1648791213000);
$loop_count = 0
loop0:
sleep 1000
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
sql select * from streamt1;
print $data00 $data01
print $data10 $data11
if $rows != 0 then
print =====rows=$rows
goto loop0
endi
sql insert into t1 values(1648791214000,1,2,3,1.0,3);
$loop_count = 0
loop1:
sleep 1000
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
sql select * from streamt1;
print $data00 $data01
print $data10 $data11
if $rows != 1 then
print =====rows=$rows
goto loop1
endi
sql insert into t1 values(1648791215000,2,2,3,1.0,4);
$loop_count = 0
loop2:
sleep 1000
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
sql select * from streamt1;
if $rows != 2 then
print =====rows=$rows
goto loop2
endi
sql insert into t1(ts) values(1648791216000);
$loop_count = 0
loop3:
sleep 1000
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
sql select * from streamt1;
if $rows != 2 then
print =====rows=$rows
goto loop3
endi
print step 1 over
print step 2
sql create database test2 vgroups 1;
sql use test2;
sql create table t1(ts timestamp, a int, b int , c int, d double);
print create stream streams2 trigger at_once watermark 1000s IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt2 as select _wstart, count(*) c1, count(d) c2 from t1 partition by b state_window(a)
sql create stream streams2 trigger at_once watermark 1000s IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt2 as select _wstart, count(*) c1, count(d) c2 from t1 partition by b state_window(a);
sql insert into t1 values(1648791213000,1,2,3,1.0);
sql insert into t1 values(1648791213010,1,2,3,1.1);
$loop_count = 0
loop4:
sleep 1000
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
sql select * from streamt2;
print $data00 $data01
print $data10 $data11
if $rows != 1 then
print =====rows=$rows
goto loop4
endi
print insert into t1 values(1648791213005,2,2,3,1.1)
sql insert into t1 values(1648791213005,2,2,3,1.1);
$loop_count = 0
loop5:
sleep 1000
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
print select * from streamt2
sql select * from streamt2;
print $data00 $data01
print $data10 $data11
print $data20 $data21
print $data30 $data31
if $rows != 3 then
print =====rows=$rows
goto loop5
endi
print step 2 over
print state1 end
system sh/stop_dnodes.sh