triggerSession0.sim 2.2 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

print =============== create database
8
sql create database test vgroups 1;
X
Xiaoyu Wang 已提交
9
sql select * from information_schema.ins_databases
5
54liuyao 已提交
10 11 12 13 14 15
if $rows != 3 then
  return -1
endi

print $data00 $data01 $data02

5
54liuyao 已提交
16
sql use test;
5
54liuyao 已提交
17
sql create table t2(ts timestamp, a int, b int , c int, d double);
18
sql create stream streams2 trigger window_close into streamt2 as select  _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b)  c4, min(c) c5 from t2 session(ts, 10s);
5
54liuyao 已提交
19 20 21 22 23 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

sql insert into t2 values(1648791213000,1,2,3,1.0);
sql insert into t2 values(1648791222999,1,2,3,1.0);
sql insert into t2 values(1648791223000,1,2,3,1.0);
sql insert into t2 values(1648791223001,1,2,3,1.0);
sql insert into t2 values(1648791233001,1,2,3,1.0);
sleep 300
sql select * from streamt2;
if $rows != 0 then
  print ======$rows
  return -1
endi

sql insert into t2 values(1648791243002,1,2,3,1.0);
sleep 300
sql select * from streamt2;
if $rows != 1 then
  print ======$rows
  return -1
endi

if $data01 != 5 then
  print ======$data01
  return -1
endi

sql insert into t2 values(1648791223001,1,2,3,1.0) (1648791223002,1,2,3,1.0) (1648791222999,1,2,3,1.0);
sleep 300
sql select * from streamt2;
if $rows != 1 then
  print ======$rows
  return -1
endi

if $data01 != 6 then
  print ======$data01
  return -1
endi

sql insert into t2 values(1648791233002,1,2,3,1.0);
sleep 300
sql select * from streamt2;
5
54liuyao 已提交
61
if $rows != 0 then
5
54liuyao 已提交
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
  print ======$rows
  return -1
endi

sql insert into t2 values(1648791253003,1,2,3,1.0);
sleep 300
sql select * from streamt2;
if $rows != 1 then
  print ======$rows
  return -1
endi

if $data01 != 8 then
  print ======$data01
  return -1
endi

sql insert into t2 values(1648791243003,1,2,3,1.0) (1648791243002,1,2,3,1.0) (1648791270004,1,2,3,1.0) (1648791280005,1,2,3,1.0)  (1648791290006,1,2,3,1.0);
sleep 500
sql select * from streamt2;
if $rows != 3 then
5
54liuyao 已提交
83
  print =====rows=$rows
5
54liuyao 已提交
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
  return -1
endi

if $data01 != 10 then
  print ======$data01
  return -1
endi
if $data11 != 1 then
  print ======$data11
  return -1
endi
if $data21 != 1 then
  print ======$data21
  return -1
endi

5
54liuyao 已提交
100
system sh/exec.sh -n dnode1 -s stop -x SIGINT