basic1.sim 9.3 KB
Newer Older
P
plum-lihui 已提交
1
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
P
plum-lihui 已提交
2 3 4 5 6
#basic1.sim: vgroups=1, one topic for one consumer, firstly insert data, then start consume. Include six topics
#basic2.sim: vgroups=1, multi topics for one consumer, firstly insert data, then start consume. Include six topics
#basic3.sim: vgroups=4, one topic for one consumer, firstly insert data, then start consume. Include six topics
#basic4.sim: vgroups=4, multi topics for one consumer, firstly insert data, then start consume. Include six topics

P
plum-lihui 已提交
7
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
P
plum-lihui 已提交
8 9
# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5;
#
P
plum-lihui 已提交
10
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
P
plum-lihui 已提交
11
#
P
plum-lihui 已提交
12

P
plum-lihui 已提交
13
run tsim/tmq/prepareBasicEnv-1vgrp.sim
P
plum-lihui 已提交
14 15 16 17 18 19 20 21 22 23

#---- global parameters start ----#
$dbName    = db
$vgroups    = 1
$stbPrefix  = stb
$ctbPrefix  = ctb
$ntbPrefix  = ntb
$stbNum     = 1
$ctbNum     = 10
$ntbNum     = 10
P
plum-lihui 已提交
24
$rowsPerCtb = 10
P
plum-lihui 已提交
25 26 27
$tstart     = 1640966400000  # 2022-01-01 00:00:00.000
#---- global parameters end ----#

P
plum-lihui 已提交
28
$pullDelay    = 5
P
plum-lihui 已提交
29 30 31
$ifcheckdata  = 1
$showMsg      = 1
$showRow      = 0
P
plum-lihui 已提交
32 33

sql connect
P
plum-lihui 已提交
34
sql use $dbName
P
plum-lihui 已提交
35

P
plum-lihui 已提交
36 37 38 39
print == create topics from super table
sql create topic topic_stb_column as select ts, c3 from stb
sql create topic topic_stb_all as select ts, c1, c2, c3 from stb
sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb
P
plum-lihui 已提交
40

P
plum-lihui 已提交
41 42 43 44
print == create topics from child table
sql create topic topic_ctb_column as select ts, c3 from ctb0
sql create topic topic_ctb_all as select * from ctb0
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ctb0
P
plum-lihui 已提交
45

P
plum-lihui 已提交
46 47 48 49
print == create topics from normal table
sql create topic topic_ntb_column as select ts, c3 from ntb0
sql create topic topic_ntb_all as select * from ntb0
sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb0
P
plum-lihui 已提交
50

P
plum-lihui 已提交
51 52 53 54
#sql show topics
#if $rows != 9 then 
#  return -1
#endi
P
plum-lihui 已提交
55

P
plum-lihui 已提交
56 57
$keyList = ' . group.id:cgrp1
$keyList = $keyList . '
P
plum-lihui 已提交
58

P
plum-lihui 已提交
59 60 61
$cdb_index = 0
#=============================== start consume =============================#

P
plum-lihui 已提交
62 63 64
print ================ test consume from stb
$loop_cnt = 0
loop_consume_diff_topic_from_stb:
P
plum-lihui 已提交
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85

#######################################################################################
# clear consume info and consume result 
#run tsim/tmq/clearConsume.sim
# because drop table function no stable, so by create new db for consume info and result. Modify it later
$cdb_index = $cdb_index + 1
$cdbName = cdb . $cdb_index
sql create database $cdbName vgroups 1
sleep 500
sql use $cdbName

print == create consume info table and consume result table
sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)
sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)

sql show tables
if $rows != 2 then 
  return -1
endi
#######################################################################################

P
plum-lihui 已提交
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
if $loop_cnt == 0 then
  print == scenario 1: topic_stb_column
  $topicList = ' . topic_stb_column
  $topicList = $topicList . '
elif $loop_cnt == 1 then
  print == scenario 2: topic_stb_all
  $topicList = ' . topic_stb_all
  $topicList = $topicList . '
elif $loop_cnt == 2 then
  print == scenario 3: topic_stb_function
  $topicList = ' . topic_stb_function
  $topicList = $topicList . '
else
  goto loop_consume_diff_topic_from_stb_end
endi
P
plum-lihui 已提交
101

P
plum-lihui 已提交
102 103
$consumerId    = 0
$totalMsgOfStb = $ctbNum * $rowsPerCtb
P
plum-lihui 已提交
104
$expectmsgcnt  = $totalMsgOfStb
P
plum-lihui 已提交
105 106 107
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )

print == start consumer to pull msgs from stb
P
plum-lihui 已提交
108 109
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start
P
plum-lihui 已提交
110 111 112 113 114 115 116 117 118 119 120 121 122 123

print == check consume result
wait_consumer_end_from_stb:
sql select * from consumeresult
print ==> rows: $rows 
print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
if $rows != 1 then
  sleep 1000
  goto wait_consumer_end_from_stb
endi
if $data[0][1] != $consumerId then
  return -1
endi
if $data[0][2] != $expectmsgcnt then
P
plum-lihui 已提交
124 125
  return -1
endi
P
plum-lihui 已提交
126 127 128 129 130 131 132
if $data[0][3] != $expectmsgcnt then
  return -1
endi
$loop_cnt = $loop_cnt + 1
goto loop_consume_diff_topic_from_stb
loop_consume_diff_topic_from_stb_end:

P
plum-lihui 已提交
133 134 135 136
print ================ test consume from ctb
$loop_cnt = 0
loop_consume_diff_topic_from_ctb:

P
plum-lihui 已提交
137 138 139 140
#######################################################################################
# clear consume info and consume result 
#run tsim/tmq/clearConsume.sim
# because drop table function no stable, so by create new db for consume info and result. Modify it later
P
plum-lihui 已提交
141 142
$cdb_index = $cdb_index + 1
$cdbName = cdb . $cdb_index
P
plum-lihui 已提交
143 144 145 146 147 148 149
sql create database $cdbName vgroups 1
sleep 500
sql use $cdbName

print == create consume info table and consume result table
sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)
sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)
P
plum-lihui 已提交
150

P
plum-lihui 已提交
151 152
sql show tables
if $rows != 2 then 
P
plum-lihui 已提交
153 154
  return -1
endi
P
plum-lihui 已提交
155
#######################################################################################
P
plum-lihui 已提交
156

P
plum-lihui 已提交
157 158 159 160 161 162 163 164 165 166 167 168 169 170
if $loop_cnt == 0 then
  print == scenario 1: topic_ctb_column
  $topicList = ' . topic_ctb_column
  $topicList = $topicList . '
elif $loop_cnt == 1 then
  print == scenario 2: topic_ctb_all
  $topicList = ' . topic_ctb_all
  $topicList = $topicList . '
elif $loop_cnt == 2 then
  print == scenario 3: topic_ctb_function
  $topicList = ' . topic_ctb_function
  $topicList = $topicList . '
else
  goto loop_consume_diff_topic_from_ctb_end
P
plum-lihui 已提交
171 172
endi

P
plum-lihui 已提交
173 174
$consumerId    = 0
$totalMsgOfCtb = $rowsPerCtb
P
plum-lihui 已提交
175
$expectmsgcnt  = $totalMsgOfCtb
P
plum-lihui 已提交
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )

print == start consumer to pull msgs from stb
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start

print == check consume result
wait_consumer_end_from_ctb:
sql select * from consumeresult
print ==> rows: $rows 
print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
if $rows != 1 then
  sleep 1000
  goto wait_consumer_end_from_ctb
endi
if $data[0][1] != $consumerId then
P
plum-lihui 已提交
192 193
  return -1
endi
P
plum-lihui 已提交
194
if $data[0][2] != $totalMsgOfCtb then
L
Liu Jicong 已提交
195 196
  return -1
endi
P
plum-lihui 已提交
197
if $data[0][3] != $totalMsgOfCtb then
P
plum-lihui 已提交
198 199
  return -1
endi
P
plum-lihui 已提交
200 201 202 203
$loop_cnt = $loop_cnt + 1
goto loop_consume_diff_topic_from_ctb
loop_consume_diff_topic_from_ctb_end:

P
plum-lihui 已提交
204 205 206 207
print ================ test consume from ntb
$loop_cnt = 0
loop_consume_diff_topic_from_ntb:

P
plum-lihui 已提交
208 209 210 211
#######################################################################################
# clear consume info and consume result 
#run tsim/tmq/clearConsume.sim
# because drop table function no stable, so by create new db for consume info and result. Modify it later
P
plum-lihui 已提交
212 213
$cdb_index = $cdb_index + 1
$cdbName = cdb . $cdb_index
P
plum-lihui 已提交
214 215 216 217 218 219 220
sql create database $cdbName vgroups 1
sleep 500
sql use $cdbName

print == create consume info table and consume result table
sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)
sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)
P
plum-lihui 已提交
221

P
plum-lihui 已提交
222 223
sql show tables
if $rows != 2 then 
P
plum-lihui 已提交
224 225
  return -1
endi
P
plum-lihui 已提交
226
#######################################################################################
P
plum-lihui 已提交
227

P
plum-lihui 已提交
228 229 230 231 232 233 234 235 236 237 238 239 240 241
if $loop_cnt == 0 then
  print == scenario 1: topic_ntb_column
  $topicList = ' . topic_ntb_column
  $topicList = $topicList . '
elif $loop_cnt == 1 then
  print == scenario 2: topic_ntb_all
  $topicList = ' . topic_ntb_all
  $topicList = $topicList . '
elif $loop_cnt == 2 then
  print == scenario 3: topic_ntb_function
  $topicList = ' . topic_ntb_function
  $topicList = $topicList . '
else
  goto loop_consume_diff_topic_from_ntb_end
L
Liu Jicong 已提交
242
endi
P
plum-lihui 已提交
243

P
plum-lihui 已提交
244 245
$consumerId    = 0
$totalMsgOfNtb = $rowsPerCtb
P
plum-lihui 已提交
246
$expectmsgcnt  = $totalMsgOfNtb
P
plum-lihui 已提交
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )

print == start consumer to pull msgs from stb
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start

print == check consume result from ntb
wait_consumer_end_from_ntb:
sql select * from consumeresult
print ==> rows: $rows 
print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
if $rows != 1 then
  sleep 1000
  goto wait_consumer_end_from_ntb
endi
if $data[0][1] != $consumerId then
P
plum-lihui 已提交
263 264
  return -1
endi
P
plum-lihui 已提交
265 266 267 268 269 270 271 272 273
if $data[0][2] != $totalMsgOfNtb then
  return -1
endi
if $data[0][3] != $totalMsgOfNtb then
  return -1
endi
$loop_cnt = $loop_cnt + 1
goto loop_consume_diff_topic_from_ntb
loop_consume_diff_topic_from_ntb_end:
P
plum-lihui 已提交
274

P
plum-lihui 已提交
275 276
#------ not need stop consumer, because it exit after pull msg overthan expect msg
#system tsim/tmq/consume.sh -s stop -x SIGINT
P
plum-lihui 已提交
277

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