session0.sim 3.2 KB
Newer Older
5
54liuyao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
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
sql create database test vgroups 1
sql show 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);
sql create stream streams2 trigger at_once  into streamt as select  _wstartts, count(*) c1,  sum(a), max(a), min(d), stddev(a), last(a), first(d), max(id) s from t1 session(ts,10s);
sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL,1);
sql insert into t1 values(1648791223001,10,2,3,1.1,2);
sql insert into t1 values(1648791233002,3,2,3,2.1,3);
sql insert into t1 values(1648791243003,NULL,NULL,NULL,NULL,4);
sql insert into t1 values(1648791213002,NULL,NULL,NULL,NULL,5) (1648791233012,NULL,NULL,NULL,NULL,6);
5
54liuyao 已提交
26 27 28 29

$loop_count = 0
loop0:

5
54liuyao 已提交
30
sleep 300
5
54liuyao 已提交
31 32
sql select * from streamt order by s desc;

5
54liuyao 已提交
33 34 35 36 37
$loop_count = $loop_count + 1
if $loop_count == 10 then
  return -1
endi

5
54liuyao 已提交
38 39
# row 0
if $data01 != 3 then
5
54liuyao 已提交
40 41
  print ======data01=$data01
  goto loop0
5
54liuyao 已提交
42 43 44
endi

if $data02 != 3 then
5
54liuyao 已提交
45 46
  print ======data02=$data02
  goto loop0
5
54liuyao 已提交
47 48 49
endi

if $data03 != 3 then
5
54liuyao 已提交
50 51
  print ======data03=$data03
  goto loop0
5
54liuyao 已提交
52 53 54
endi

if $data04 != 2.100000000 then
5
54liuyao 已提交
55
  print ======data04=$data04
5
54liuyao 已提交
56 57 58 59
  return -1
endi

if $data05 != 0.000000000 then
5
54liuyao 已提交
60
  print ======data05=$data05
5
54liuyao 已提交
61 62 63 64
  return -1
endi

if $data06 != 3 then
5
54liuyao 已提交
65
  print ======data06=$data06
5
54liuyao 已提交
66 67 68 69
  return -1
endi

if $data07 != 2.100000000 then
5
54liuyao 已提交
70
  print ======data07=$data07
5
54liuyao 已提交
71 72 73 74
  return -1
endi

if $data08 != 6 then
5
54liuyao 已提交
75
  print ======data08=$data08
5
54liuyao 已提交
76 77 78 79 80 81
  return -1
endi

# row 1

if $data11 != 3 then
5
54liuyao 已提交
82 83
  print ======data11=$data11
  goto loop0
5
54liuyao 已提交
84 85 86
endi

if $data12 != 10 then
5
54liuyao 已提交
87 88
  print ======data12=$data12
  goto loop0
5
54liuyao 已提交
89 90 91
endi

if $data13 != 10 then
5
54liuyao 已提交
92 93
  print ======data13=$data13
  goto loop0
5
54liuyao 已提交
94 95 96
endi

if $data14 != 1.100000000 then
5
54liuyao 已提交
97
  print ======data14=$data14
5
54liuyao 已提交
98 99 100 101
  return -1
endi

if $data15 != 0.000000000 then
5
54liuyao 已提交
102
  print ======data15=$data15
5
54liuyao 已提交
103 104 105 106
  return -1
endi

if $data16 != 10 then
5
54liuyao 已提交
107
  print ======data16=$data16
5
54liuyao 已提交
108 109 110 111
  return -1
endi

if $data17 != 1.100000000 then
5
54liuyao 已提交
112
  print ======data17=$data17
5
54liuyao 已提交
113 114 115 116
  return -1
endi

if $data18 != 5 then
5
54liuyao 已提交
117
  print ======data18=$data18
5
54liuyao 已提交
118 119 120 121 122 123 124 125 126
  return -1
endi

sql insert into t1 values(1648791213000,1,2,3,1.0,7);
sql insert into t1 values(1648791223001,2,2,3,1.1,8);
sql insert into t1 values(1648791233002,3,2,3,2.1,9);
sql insert into t1 values(1648791243003,4,2,3,3.1,10);
sql insert into t1 values(1648791213002,4,2,3,4.1,11) ;
sql insert into t1 values(1648791213002,4,2,3,4.1,12) (1648791223009,4,2,3,4.1,13);
5
54liuyao 已提交
127 128 129

$loop_count = 0
loop1:
5
54liuyao 已提交
130
sleep 300
5
54liuyao 已提交
131 132
sql select * from streamt order by s desc ;

5
54liuyao 已提交
133 134 135 136 137
$loop_count = $loop_count + 1
if $loop_count == 10 then
  return -1
endi

5
54liuyao 已提交
138 139
# row 0
if $data01 != 7 then
5
54liuyao 已提交
140 141
  print =====data01=$data01
  goto loop1
5
54liuyao 已提交
142 143 144
endi

if $data02 != 9 then
5
54liuyao 已提交
145 146
  print =====data02=$data02
  goto loop1
5
54liuyao 已提交
147 148 149
endi

if $data03 != 4 then
5
54liuyao 已提交
150 151
  print =====data03=$data03
  goto loop1
5
54liuyao 已提交
152 153 154 155 156 157 158 159 160 161 162 163 164
endi

if $data04 != 1.100000000 then
  print ======$data04
  return -1
endi

if $data05 != 0.816496581 then
  print ======$data05
  return -1
endi

if $data06 != 3 then
5
54liuyao 已提交
165
  print ======$data06
5
54liuyao 已提交
166 167 168 169
  return -1
endi

if $data07 != 1.100000000 then
5
54liuyao 已提交
170
  print ======$data07
5
54liuyao 已提交
171 172 173 174
  return -1
endi

if $data08 != 13 then
5
54liuyao 已提交
175
  print ======$data08
5
54liuyao 已提交
176 177 178 179
  return -1
endi

system sh/exec.sh -n dnode1 -s stop -x SIGINT