session0.sim 6.7 KB
Newer Older
5
54liuyao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
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);
20
sql create stream streams1 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);
5
54liuyao 已提交
21 22 23 24 25
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
endi

5
54liuyao 已提交
144
if $data02 != 18 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
endi

5
54liuyao 已提交
154
if $data04 != 1.000000000 then
5
54liuyao 已提交
155 156 157 158
  print ======$data04
  return -1
endi

5
54liuyao 已提交
159
if $data05 != 1.154700538 then
5
54liuyao 已提交
160 161 162 163
  print ======$data05
  return -1
endi

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

5
54liuyao 已提交
169
if $data07 != 1.000000000 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
  return -1
endi

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 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
sql create database test2 vgroups 1;
sql use test2;
sql create table t2(ts timestamp, a int, b int , c int, d double, id int);
sql create stream streams2 trigger at_once  watermark 1d into streamt2 as select  _wstartts,apercentile(a,30) c1, apercentile(a,70), apercentile(a,20,"t-digest") c2, apercentile(a,60,"t-digest") c3, max(id) c4 from t2 session(ts,10s);
sql insert into t2 values(1648791213001,1,1,3,1.0,1);
sql insert into t2 values(1648791213002,2,2,6,3.4,2);
sql insert into t2 values(1648791213003,4,9,3,4.8,3);
sql insert into t2 values(1648791233003,3,4,3,2.1,4);
sql insert into t2 values(1648791233004,3,5,3,3.4,5);
sql insert into t2 values(1648791233005,3,6,3,7.6,6);

#
sql insert into t2 values(1648791223003,20,7,3,10.1,7);

$loop_count = 0
loop2:
sleep 300
sql select * from streamt2 where c4=7;

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

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

# row 0
if $data01 != 2.091607978 then
  print =====data01=$data01
  goto loop2
endi

if $data02 != 3.274823935 then
  print =====data02=$data02
  goto loop2
endi

if $data03 != 1.800000000 then
  print ======$data03
  return -1
endi

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

sql create database test3 vgroups 1;
sql use test3;
sql create table t1(ts timestamp, a int, b int , c int, d double);
sql create stream streams3 trigger at_once  watermark 1d into streamt3 as select  _wstartts, min(b), a,c from t1 session(ts,10s);
sql create stream streams4 trigger at_once  watermark 1d into streamt4 as select  _wstartts, max(b), a,c from t1 session(ts,10s);
5
54liuyao 已提交
234 235 236 237
# sql create stream streams5 trigger at_once  watermark 1d into streamt5 as select  _wstartts, top(b,3), a,c from t1 session(ts,10s);
# sql create stream streams6 trigger at_once  watermark 1d into streamt6 as select  _wstartts, bottom(b,3), a,c from t1 session(ts,10s);
# sql create stream streams7 trigger at_once  watermark 1d into streamt7 as select  _wstartts, spread(a), elapsed(ts), hyperloglog(a) from t1 session(ts,10s);
sql create stream streams7 trigger at_once  watermark 1d into streamt7 as select  _wstartts, spread(a), hyperloglog(a) from t1 session(ts,10s);
5
54liuyao 已提交
238
# sql create stream streams8 trigger at_once  watermark 1d into streamt8 as select  _wstartts, histogram(a,"user_input", "[1,3,5,7]", 1), histogram(a,"user_input", "[1,3,5,7]", 0) from t1 session(ts,10s);
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
sql insert into t1 values(1648791213001,1,1,1,1.0);
sql insert into t1 values(1648791213002,2,3,2,3.4);
sql insert into t1 values(1648791213003,4,9,3,4.8);
sql insert into t1 values(1648791213004,4,5,4,4.8);

sql insert into t1 values(1648791233004,3,4,0,2.1);
sql insert into t1 values(1648791233005,3,0,6,3.4);
sql insert into t1 values(1648791233006,3,6,7,7.6);
sql insert into t1 values(1648791233007,3,13,8,7.6);


sql insert into t1 values(1648791223004,20,7,9,10.1);

$loop_count = 0
loop3:
sleep 300

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

sql select * from streamt3;
if $rows == 0 then
  print ======$rows
  goto loop3
endi

sql select * from streamt4;
if $rows == 0 then
  print ======$rows
  goto loop3
endi

5
54liuyao 已提交
273
#sql select * from streamt5;
274 275
if $rows == 0 then
  print ======$rows
5
54liuyao 已提交
276
  # goto loop3
277 278
endi

5
54liuyao 已提交
279
# sql select * from streamt6;
280 281 282 283 284
if $rows == 0 then
  print ======$rows
  goto loop3
endi

285 286 287 288 289 290
sql select * from streamt7;
if $rows == 0 then
  print ======$rows
  goto loop3
endi

5
54liuyao 已提交
291 292 293 294 295
#sql select * from streamt8;
#if $rows == 0 then
#  print ======$rows
#  goto loop3
#endi
296

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