test: add tmq test cases
This commit is contained in:
parent
a114724120
commit
7b3a883498
|
@ -22,23 +22,19 @@ while $i < $tbNum
|
|||
|
||||
$x = 0
|
||||
while $x < $rowNum
|
||||
$c = $x / 10
|
||||
$c = $c * 10
|
||||
$c = $x - $c
|
||||
|
||||
$binary = ' . binary
|
||||
$binary = $binary . $c
|
||||
$binary = $binary . $i
|
||||
$binary = $binary . '
|
||||
|
||||
#print ====> insert into $tb values ($tstart , $c , $x , $binary )
|
||||
#print ====> insert into ntb values ($tstart , $c , $x , $binary )
|
||||
sql insert into $tb values ($tstart , $c , $x , $binary )
|
||||
sql insert into ntb values ($tstart , $c , $x , $binary )
|
||||
#print ====> insert into $tb values ($tstart , $i , $x , $binary )
|
||||
#print ====> insert into ntb values ($tstart , $i , $x , $binary )
|
||||
sql insert into $tb values ($tstart , $i , $x , $binary )
|
||||
sql insert into ntb values ($tstart , 999 , 999 , 'binary-ntb' )
|
||||
$tstart = $tstart + 1
|
||||
$x = $x + 1
|
||||
endw
|
||||
|
||||
#print ====> insert rows: $rowNum into $tb and ntb
|
||||
print ====> insert rows: $rowNum into $tb and ntb
|
||||
|
||||
$i = $i + 1
|
||||
# $tstart = 1640966400000
|
||||
|
|
|
@ -22,18 +22,14 @@ while $i < $tbNum
|
|||
|
||||
$x = 0
|
||||
while $x < $rowNum
|
||||
$c = $x / 10
|
||||
$c = $c * 10
|
||||
$c = $x - $c
|
||||
|
||||
$binary = ' . binary
|
||||
$binary = $binary . $c
|
||||
$binary = $binary . $i
|
||||
$binary = $binary . '
|
||||
|
||||
#print ====> insert into $tb values ($tstart , $c , $x , $binary )
|
||||
#print ====> insert into ntb values ($tstart , $c , $x , $binary )
|
||||
sql insert into $tb values ($tstart , $c , $x , $binary )
|
||||
sql insert into ntb values ($tstart , $c , $x , $binary )
|
||||
#print ====> insert into $tb values ($tstart , $i , $x , $binary )
|
||||
#print ====> insert into ntb values ($tstart , $i , $x , $binary )
|
||||
sql insert into $tb values ($tstart , $i , $x , $binary )
|
||||
sql insert into ntb values ($tstart , 999 , 999 , 'binary-ntb' )
|
||||
$tstart = $tstart + 1
|
||||
$x = $x + 1
|
||||
endw
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
|
||||
sql connect
|
||||
|
||||
print ================ insert data
|
||||
$dbNamme = d0
|
||||
$tbPrefix = ct
|
||||
$tbNum = 10
|
||||
$rowNum = 100
|
||||
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
|
||||
|
||||
$loopInsertNum = 10
|
||||
|
||||
sql use $dbNamme
|
||||
|
||||
$loopIndex = 0
|
||||
|
||||
loop_insert:
|
||||
print ====> loop $loopIndex insert
|
||||
$loopIndex = $loopIndex + 1
|
||||
|
||||
$i = 0
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
|
||||
$x = 0
|
||||
while $x < $rowNum
|
||||
$binary = ' . binary
|
||||
$binary = $binary . $i
|
||||
$binary = $binary . '
|
||||
|
||||
#print ====> insert into $tb values ($tstart , $i , $x , $binary )
|
||||
#print ====> insert into ntb values ($tstart , $i , $x , $binary )
|
||||
sql insert into $tb values ($tstart , $i , $x , $binary )
|
||||
sql insert into ntb values ($tstart , 999 , 999 , 'binary-ntb' )
|
||||
$tstart = $tstart + 1
|
||||
$x = $x + 1
|
||||
endw
|
||||
|
||||
#print ====> insert rows: $rowNum into $tb and ntb
|
||||
|
||||
$i = $i + 1
|
||||
# $tstart = 1640966400000
|
||||
endw
|
||||
|
||||
|
||||
if $loopIndex < $loopInsertNum then
|
||||
goto loop_insert
|
||||
endi
|
||||
|
||||
print ====> insert data end ===========
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
|
||||
sql connect
|
||||
|
||||
print ================ insert data
|
||||
$dbNamme = d1
|
||||
$tbPrefix = ct
|
||||
$tbNum = 10
|
||||
$rowNum = 100
|
||||
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
|
||||
|
||||
$loopInsertNum = 10
|
||||
|
||||
sql use $dbNamme
|
||||
|
||||
$loopIndex = 0
|
||||
|
||||
loop_insert:
|
||||
print ====> loop $loopIndex insert
|
||||
$loopIndex = $loopIndex + 1
|
||||
|
||||
$i = 0
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
|
||||
$x = 0
|
||||
while $x < $rowNum
|
||||
$binary = ' . binary
|
||||
$binary = $binary . $i
|
||||
$binary = $binary . '
|
||||
|
||||
#print ====> insert into $tb values ($tstart , $i , $x , $binary )
|
||||
#print ====> insert into ntb values ($tstart , $i , $x , $binary )
|
||||
sql insert into $tb values ($tstart , $i , $x , $binary )
|
||||
sql insert into ntb values ($tstart , 999 , 999 , 'binary-ntb' )
|
||||
$tstart = $tstart + 1
|
||||
$x = $x + 1
|
||||
endw
|
||||
|
||||
#print ====> insert rows: $rowNum into $tb and ntb
|
||||
|
||||
$i = $i + 1
|
||||
# $tstart = 1640966400000
|
||||
endw
|
||||
|
||||
|
||||
if $loopIndex < $loopInsertNum then
|
||||
goto loop_insert
|
||||
endi
|
||||
|
||||
print ====> insert data end ===========
|
||||
|
|
@ -0,0 +1,265 @@
|
|||
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
|
||||
# scene1: vgroups=2, one topic for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||
# scene2: vgroups=2, multi topics for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||
# scene3: vgroups=4, one topic for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||
# scene4: vgroups=4, multi topics for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
|
||||
# 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;
|
||||
#
|
||||
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
|
||||
#
|
||||
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
|
||||
######## This test case include scene1 and scene3
|
||||
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
|
||||
|
||||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
$loop_cnt = 0
|
||||
check_dnode_ready:
|
||||
$loop_cnt = $loop_cnt + 1
|
||||
sleep 200
|
||||
if $loop_cnt == 10 then
|
||||
print ====> dnode not ready!
|
||||
return -1
|
||||
endi
|
||||
sql show dnodes
|
||||
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
|
||||
if $data00 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data04 != ready then
|
||||
goto check_dnode_ready
|
||||
endi
|
||||
|
||||
sql connect
|
||||
|
||||
$loop_cnt = 0
|
||||
$vgroups = 2
|
||||
$dbNamme = d0
|
||||
loop_vgroups:
|
||||
print =============== create database $dbNamme vgroups $vgroups
|
||||
sql create database $dbNamme vgroups $vgroups
|
||||
sql show databases
|
||||
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
|
||||
print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29
|
||||
|
||||
if $loop_cnt == 0 then
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 2 then # vgroups
|
||||
print vgroups: $data02
|
||||
return -1
|
||||
endi
|
||||
else
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 == d1 then
|
||||
if $data02 != 4 then # vgroups
|
||||
print vgroups: $data02
|
||||
return -1
|
||||
endi
|
||||
else
|
||||
if $data12 != 4 then # vgroups
|
||||
print vgroups: $data12
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
endi
|
||||
|
||||
sql use $dbNamme
|
||||
|
||||
print =============== create super table
|
||||
sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int)
|
||||
|
||||
sql show stables
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== create child table
|
||||
$tbPrefix = ct
|
||||
$tbNum = 100
|
||||
|
||||
$i = 0
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
sql create table $tb using stb tags( $i )
|
||||
$i = $i + 1
|
||||
endw
|
||||
|
||||
print =============== create normal table
|
||||
sql create table ntb (ts timestamp, c1 int, c2 float, c3 binary(10))
|
||||
|
||||
print =============== create topics from child table
|
||||
|
||||
sql create topic topic_ctb_column as select ts, c1, c3 from ct0
|
||||
sql create topic topic_ctb_all as select * from ct0
|
||||
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0
|
||||
|
||||
#sql create topic topic_ntb_column as select ts, c1, c3 from ntb
|
||||
#sql create topic topic_ntb_all as select * from ntb
|
||||
#sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb
|
||||
|
||||
sql show tables
|
||||
if $rows != 101 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== run_back insert data
|
||||
|
||||
if $loop_cnt == 0 then
|
||||
run_back tsim/tmq/insertFixedDataV2.sim
|
||||
else
|
||||
run_back tsim/tmq/insertFixedDataV4.sim
|
||||
endi
|
||||
|
||||
#sleep 1000
|
||||
|
||||
#$rowNum = 1000
|
||||
#$tstart = 1640966400000 # 2022-01-01 00:00:00.000
|
||||
#
|
||||
#$i = 0
|
||||
#while $i < $tbNum
|
||||
# $tb = $tbPrefix . $i
|
||||
#
|
||||
# $x = 0
|
||||
# while $x < $rowNum
|
||||
# $c = $x / 10
|
||||
# $c = $c * 10
|
||||
# $c = $x - $c
|
||||
#
|
||||
# $binary = ' . binary
|
||||
# $binary = $binary . $c
|
||||
# $binary = $binary . '
|
||||
#
|
||||
# sql insert into $tb values ($tstart , $c , $x , $binary )
|
||||
# sql insert into ntb values ($tstart , $c , $x , $binary )
|
||||
# $tstart = $tstart + 1
|
||||
# $x = $x + 1
|
||||
# endw
|
||||
#
|
||||
# $i = $i + 1
|
||||
# $tstart = 1640966400000
|
||||
#endw
|
||||
|
||||
#root@trd02 /home $ tmq_sim --help
|
||||
# -c Configuration directory, default is
|
||||
# -d The name of the database for cosumer, no default
|
||||
# -t The topic string for cosumer, no default
|
||||
# -k The key-value string for cosumer, no default
|
||||
# -g showMsgFlag, default is 0
|
||||
#
|
||||
|
||||
$tbNum = 10
|
||||
$consumeDelay = 10
|
||||
$expectMsgCntFromCtb = 300
|
||||
$expectMsgCntFromStb = $expectMsgCntFromCtb * $tbNum
|
||||
print consumeDelay: $consumeDelay
|
||||
print insert data child num: $tbNum
|
||||
print expectMsgCntFromCtb: $expectMsgCntFromCtb
|
||||
print expectMsgCntFromStb: $expectMsgCntFromStb
|
||||
|
||||
# supported key:
|
||||
# group.id:<xxx>
|
||||
# enable.auto.commit:<true | false>
|
||||
# auto.offset.reset:<earliest | latest | none>
|
||||
# td.connect.ip:<fqdn | ipaddress>
|
||||
# td.connect.user:root
|
||||
# td.connect.pass:taosdata
|
||||
# td.connect.port:6030
|
||||
# td.connect.db:db
|
||||
|
||||
$expect_result = @{consume success: @
|
||||
$expect_result = $expect_result . $rowNum
|
||||
$expect_result = $expect_result . @, @
|
||||
$expect_result = $expect_result . 0}
|
||||
print expect_result----> $expect_result
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_column" -k1 "group.id:tg2" -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 0
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_column" -k1 "group.id:tg2" -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 0
|
||||
print cmd result----> $system_content
|
||||
if $system_content != success then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_all" -k1 "group.id:tg2" -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 0
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_all" -k1 "group.id:tg2" -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 0
|
||||
print cmd result----> $system_content
|
||||
if $system_content != success then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_function" -k1 "group.id:tg2" -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 0
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_function" -k1 "group.id:tg2" -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 0
|
||||
print cmd result----> $system_content
|
||||
if $system_content != success then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#$expect_result = @{consume success: @
|
||||
#$expect_result = $expect_result . $totalMsgCnt
|
||||
#$expect_result = $expect_result . @, @
|
||||
#$expect_result = $expect_result . 0}
|
||||
#print expect_result----> $expect_result
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_column" -k1 "group.id:tg2" -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_column" -k1 "group.id:tg2" -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_all" -k1 "group.id:tg2" -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_all" -k1 "group.id:tg2" -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_function" -k1 "group.id:tg2" -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_function" -k1 "group.id:tg2" -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#$expect_result = @{consume success: @
|
||||
#$expect_result = $expect_result . $expectConsumeMsgCnt
|
||||
#$expect_result = $expect_result . @, @
|
||||
#$expect_result = $expect_result . 0}
|
||||
#print expect_result----> $expect_result
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
##print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
##system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
##print cmd result----> $system_content
|
||||
###if $system_content != @{consume success: 10000, 0}@ then
|
||||
##if $system_content != success then
|
||||
## return -1
|
||||
##endi
|
||||
#
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
#print cmd result----> $system_content
|
||||
##if $system_content != @{consume success: 10000, 0}@ then
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
if $loop_cnt == 0 then
|
||||
$loop_cnt = 1
|
||||
$vgroups = 4
|
||||
$dbNamme = d1
|
||||
goto loop_vgroups
|
||||
endi
|
||||
|
||||
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -0,0 +1,270 @@
|
|||
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
|
||||
# scene1: vgroups=2, one topic for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||
# scene2: vgroups=2, multi topics for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||
# scene3: vgroups=4, one topic for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||
# scene4: vgroups=4, multi topics for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
|
||||
# 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;
|
||||
#
|
||||
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
|
||||
#
|
||||
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
|
||||
######## This test case include scene1 and scene3
|
||||
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
|
||||
|
||||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
$loop_cnt = 0
|
||||
check_dnode_ready:
|
||||
$loop_cnt = $loop_cnt + 1
|
||||
sleep 200
|
||||
if $loop_cnt == 10 then
|
||||
print ====> dnode not ready!
|
||||
return -1
|
||||
endi
|
||||
sql show dnodes
|
||||
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
|
||||
if $data00 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data04 != ready then
|
||||
goto check_dnode_ready
|
||||
endi
|
||||
|
||||
sql connect
|
||||
|
||||
$loop_cnt = 0
|
||||
$vgroups = 2
|
||||
$dbNamme = d0
|
||||
loop_vgroups:
|
||||
print =============== create database $dbNamme vgroups $vgroups
|
||||
sql create database $dbNamme vgroups $vgroups
|
||||
sql show databases
|
||||
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
|
||||
print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29
|
||||
|
||||
if $loop_cnt == 0 then
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 2 then # vgroups
|
||||
print vgroups: $data02
|
||||
return -1
|
||||
endi
|
||||
else
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 == d1 then
|
||||
if $data02 != 4 then # vgroups
|
||||
print vgroups: $data02
|
||||
return -1
|
||||
endi
|
||||
else
|
||||
if $data12 != 4 then # vgroups
|
||||
print vgroups: $data12
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
endi
|
||||
|
||||
sql use $dbNamme
|
||||
|
||||
print =============== create super table
|
||||
sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int)
|
||||
|
||||
sql show stables
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== create child table
|
||||
$tbPrefix = ct
|
||||
$tbNum = 100
|
||||
|
||||
$i = 0
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
sql create table $tb using stb tags( $i )
|
||||
$i = $i + 1
|
||||
endw
|
||||
|
||||
print =============== create normal table
|
||||
sql create table ntb (ts timestamp, c1 int, c2 float, c3 binary(10))
|
||||
|
||||
print =============== create multi topics. notes: now only support:
|
||||
print =============== 1. columns from stb/ctb/ntb; 2. * from ctb/ntb; 3. function from stb/ctb/ntb
|
||||
print =============== will support: * from stb
|
||||
|
||||
sql create topic topic_stb_column as select ts, c1, c3 from stb
|
||||
#sql create topic topic_stb_all as select * from stb
|
||||
sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb
|
||||
|
||||
sql create topic topic_ctb_column as select ts, c1, c3 from ct0
|
||||
sql create topic topic_ctb_all as select * from ct0
|
||||
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0
|
||||
|
||||
sql create topic topic_ntb_column as select ts, c1, c3 from ntb
|
||||
sql create topic topic_ntb_all as select * from ntb
|
||||
sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb
|
||||
|
||||
sql show tables
|
||||
if $rows != 101 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== run_back insert data
|
||||
|
||||
if $loop_cnt == 0 then
|
||||
run_back tsim/tmq/insertFixedDataV2.sim
|
||||
else
|
||||
run_back tsim/tmq/insertFixedDataV4.sim
|
||||
endi
|
||||
|
||||
#sleep 1000
|
||||
|
||||
#$rowNum = 1000
|
||||
#$tstart = 1640966400000 # 2022-01-01 00:00:00.000
|
||||
#
|
||||
#$i = 0
|
||||
#while $i < $tbNum
|
||||
# $tb = $tbPrefix . $i
|
||||
#
|
||||
# $x = 0
|
||||
# while $x < $rowNum
|
||||
# $c = $x / 10
|
||||
# $c = $c * 10
|
||||
# $c = $x - $c
|
||||
#
|
||||
# $binary = ' . binary
|
||||
# $binary = $binary . $c
|
||||
# $binary = $binary . '
|
||||
#
|
||||
# sql insert into $tb values ($tstart , $c , $x , $binary )
|
||||
# sql insert into ntb values ($tstart , $c , $x , $binary )
|
||||
# $tstart = $tstart + 1
|
||||
# $x = $x + 1
|
||||
# endw
|
||||
#
|
||||
# $i = $i + 1
|
||||
# $tstart = 1640966400000
|
||||
#endw
|
||||
|
||||
#root@trd02 /home $ tmq_sim --help
|
||||
# -c Configuration directory, default is
|
||||
# -d The name of the database for cosumer, no default
|
||||
# -t The topic string for cosumer, no default
|
||||
# -k The key-value string for cosumer, no default
|
||||
# -g showMsgFlag, default is 0
|
||||
#
|
||||
|
||||
$tbNum = 10
|
||||
$consumeDelay = 10
|
||||
$expectMsgCntFromCtb = 300
|
||||
$expectMsgCntFromStb = $expectMsgCntFromCtb * $tbNum
|
||||
print consumeDelay: $consumeDelay
|
||||
print insert data child num: $tbNum
|
||||
print expectMsgCntFromCtb: $expectMsgCntFromCtb
|
||||
print expectMsgCntFromStb: $expectMsgCntFromStb
|
||||
|
||||
# supported key:
|
||||
# group.id:<xxx>
|
||||
# enable.auto.commit:<true | false>
|
||||
# auto.offset.reset:<earliest | latest | none>
|
||||
# td.connect.ip:<fqdn | ipaddress>
|
||||
# td.connect.user:root
|
||||
# td.connect.pass:taosdata
|
||||
# td.connect.port:6030
|
||||
# td.connect.db:db
|
||||
|
||||
#$expect_result = @{consume success: @
|
||||
#$expect_result = $expect_result . $rowNum
|
||||
#$expect_result = $expect_result . @, @
|
||||
#$expect_result = $expect_result . 0}
|
||||
#print expect_result----> $expect_result
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_column" -k1 "group.id:tg2" -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_column" -k1 "group.id:tg2" -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_all" -k1 "group.id:tg2" -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_all" -k1 "group.id:tg2" -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_function" -k1 "group.id:tg2" -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_function" -k1 "group.id:tg2" -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#$expect_result = @{consume success: @
|
||||
#$expect_result = $expect_result . $totalMsgCnt
|
||||
#$expect_result = $expect_result . @, @
|
||||
#$expect_result = $expect_result . 0}
|
||||
#print expect_result----> $expect_result
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_column" -k1 "group.id:tg2" -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_column" -k1 "group.id:tg2" -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_all" -k1 "group.id:tg2" -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_all" -k1 "group.id:tg2" -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_function" -k1 "group.id:tg2" -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_function" -k1 "group.id:tg2" -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
$expect_result = @{consume success: @
|
||||
$expect_result = $expect_result . $expectConsumeMsgCnt
|
||||
$expect_result = $expect_result . @, @
|
||||
$expect_result = $expect_result . 0}
|
||||
print expect_result----> $expect_result
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
print cmd result----> $system_content
|
||||
if $system_content != success then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
#print cmd result----> $system_content
|
||||
##if $system_content != @{consume success: 10000, 0}@ then
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
print cmd result----> $system_content
|
||||
#if $system_content != @{consume success: 10000, 0}@ then
|
||||
if $system_content != success then
|
||||
return -1
|
||||
endi
|
||||
if $loop_cnt == 0 then
|
||||
$loop_cnt = 1
|
||||
$vgroups = 4
|
||||
$dbNamme = d1
|
||||
goto loop_vgroups
|
||||
endi
|
||||
|
||||
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -0,0 +1,265 @@
|
|||
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
|
||||
# scene1: vgroups=2, one topic for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||
# scene2: vgroups=2, multi topics for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||
# scene3: vgroups=4, one topic for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||
# scene4: vgroups=4, multi topics for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
|
||||
# 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;
|
||||
#
|
||||
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
|
||||
#
|
||||
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
|
||||
######## This test case include scene1 and scene3
|
||||
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
|
||||
|
||||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
$loop_cnt = 0
|
||||
check_dnode_ready:
|
||||
$loop_cnt = $loop_cnt + 1
|
||||
sleep 200
|
||||
if $loop_cnt == 10 then
|
||||
print ====> dnode not ready!
|
||||
return -1
|
||||
endi
|
||||
sql show dnodes
|
||||
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
|
||||
if $data00 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data04 != ready then
|
||||
goto check_dnode_ready
|
||||
endi
|
||||
|
||||
sql connect
|
||||
|
||||
$loop_cnt = 0
|
||||
$vgroups = 2
|
||||
$dbNamme = d0
|
||||
loop_vgroups:
|
||||
print =============== create database $dbNamme vgroups $vgroups
|
||||
sql create database $dbNamme vgroups $vgroups
|
||||
sql show databases
|
||||
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
|
||||
print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29
|
||||
|
||||
if $loop_cnt == 0 then
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 2 then # vgroups
|
||||
print vgroups: $data02
|
||||
return -1
|
||||
endi
|
||||
else
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 == d1 then
|
||||
if $data02 != 4 then # vgroups
|
||||
print vgroups: $data02
|
||||
return -1
|
||||
endi
|
||||
else
|
||||
if $data12 != 4 then # vgroups
|
||||
print vgroups: $data12
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
endi
|
||||
|
||||
sql use $dbNamme
|
||||
|
||||
print =============== create super table
|
||||
sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int)
|
||||
|
||||
sql show stables
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== create child table
|
||||
$tbPrefix = ct
|
||||
$tbNum = 100
|
||||
|
||||
$i = 0
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
sql create table $tb using stb tags( $i )
|
||||
$i = $i + 1
|
||||
endw
|
||||
|
||||
print =============== create normal table
|
||||
sql create table ntb (ts timestamp, c1 int, c2 float, c3 binary(10))
|
||||
|
||||
print =============== create topics from child table
|
||||
|
||||
sql create topic topic_ctb_column as select ts, c1, c3 from ct0
|
||||
sql create topic topic_ctb_all as select * from ct0
|
||||
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0
|
||||
|
||||
#sql create topic topic_ntb_column as select ts, c1, c3 from ntb
|
||||
#sql create topic topic_ntb_all as select * from ntb
|
||||
#sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb
|
||||
|
||||
sql show tables
|
||||
if $rows != 101 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== run_back insert data
|
||||
|
||||
if $loop_cnt == 0 then
|
||||
run_back tsim/tmq/insertFixedDataV2.sim
|
||||
else
|
||||
run_back tsim/tmq/insertFixedDataV4.sim
|
||||
endi
|
||||
|
||||
#sleep 1000
|
||||
|
||||
#$rowNum = 1000
|
||||
#$tstart = 1640966400000 # 2022-01-01 00:00:00.000
|
||||
#
|
||||
#$i = 0
|
||||
#while $i < $tbNum
|
||||
# $tb = $tbPrefix . $i
|
||||
#
|
||||
# $x = 0
|
||||
# while $x < $rowNum
|
||||
# $c = $x / 10
|
||||
# $c = $c * 10
|
||||
# $c = $x - $c
|
||||
#
|
||||
# $binary = ' . binary
|
||||
# $binary = $binary . $c
|
||||
# $binary = $binary . '
|
||||
#
|
||||
# sql insert into $tb values ($tstart , $c , $x , $binary )
|
||||
# sql insert into ntb values ($tstart , $c , $x , $binary )
|
||||
# $tstart = $tstart + 1
|
||||
# $x = $x + 1
|
||||
# endw
|
||||
#
|
||||
# $i = $i + 1
|
||||
# $tstart = 1640966400000
|
||||
#endw
|
||||
|
||||
#root@trd02 /home $ tmq_sim --help
|
||||
# -c Configuration directory, default is
|
||||
# -d The name of the database for cosumer, no default
|
||||
# -t The topic string for cosumer, no default
|
||||
# -k The key-value string for cosumer, no default
|
||||
# -g showMsgFlag, default is 0
|
||||
#
|
||||
|
||||
$tbNum = 10
|
||||
$consumeDelay = 10
|
||||
$expectMsgCntFromCtb = 300
|
||||
$expectMsgCntFromStb = $expectMsgCntFromCtb * $tbNum
|
||||
print consumeDelay: $consumeDelay
|
||||
print insert data child num: $tbNum
|
||||
print expectMsgCntFromCtb: $expectMsgCntFromCtb
|
||||
print expectMsgCntFromStb: $expectMsgCntFromStb
|
||||
|
||||
# supported key:
|
||||
# group.id:<xxx>
|
||||
# enable.auto.commit:<true | false>
|
||||
# auto.offset.reset:<earliest | latest | none>
|
||||
# td.connect.ip:<fqdn | ipaddress>
|
||||
# td.connect.user:root
|
||||
# td.connect.pass:taosdata
|
||||
# td.connect.port:6030
|
||||
# td.connect.db:db
|
||||
|
||||
$expect_result = @{consume success: @
|
||||
$expect_result = $expect_result . $rowNum
|
||||
$expect_result = $expect_result . @, @
|
||||
$expect_result = $expect_result . 0}
|
||||
print expect_result----> $expect_result
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_all" -k1 "group.id:tg2" -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 1
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_all" -k1 "group.id:tg2" -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 1
|
||||
print cmd result----> $system_content
|
||||
if $system_content != success then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_function" -k1 "group.id:tg2" -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 1
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_function" -k1 "group.id:tg2" -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 1
|
||||
print cmd result----> $system_content
|
||||
if $system_content != success then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_column" -k1 "group.id:tg2" -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 1
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_column" -k1 "group.id:tg2" -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 1
|
||||
print cmd result----> $system_content
|
||||
if $system_content != success then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#$expect_result = @{consume success: @
|
||||
#$expect_result = $expect_result . $totalMsgCnt
|
||||
#$expect_result = $expect_result . @, @
|
||||
#$expect_result = $expect_result . 0}
|
||||
#print expect_result----> $expect_result
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_column" -k1 "group.id:tg2" -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 1
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_column" -k1 "group.id:tg2" -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 1
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_all" -k1 "group.id:tg2" -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_all" -k1 "group.id:tg2" -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_function" -k1 "group.id:tg2" -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_function" -k1 "group.id:tg2" -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#$expect_result = @{consume success: @
|
||||
#$expect_result = $expect_result . $expectConsumeMsgCnt
|
||||
#$expect_result = $expect_result . @, @
|
||||
#$expect_result = $expect_result . 0}
|
||||
#print expect_result----> $expect_result
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
##print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
##system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
##print cmd result----> $system_content
|
||||
###if $system_content != @{consume success: 10000, 0}@ then
|
||||
##if $system_content != success then
|
||||
## return -1
|
||||
##endi
|
||||
#
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
#print cmd result----> $system_content
|
||||
##if $system_content != @{consume success: 10000, 0}@ then
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
if $loop_cnt == 0 then
|
||||
$loop_cnt = 1
|
||||
$vgroups = 4
|
||||
$dbNamme = d1
|
||||
goto loop_vgroups
|
||||
endi
|
||||
|
||||
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -0,0 +1,270 @@
|
|||
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
|
||||
# scene1: vgroups=2, one topic for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||
# scene2: vgroups=2, multi topics for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||
# scene3: vgroups=4, one topic for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||
# scene4: vgroups=4, multi topics for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
|
||||
# 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;
|
||||
#
|
||||
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
|
||||
#
|
||||
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
|
||||
######## This test case include scene1 and scene3
|
||||
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
|
||||
|
||||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
$loop_cnt = 0
|
||||
check_dnode_ready:
|
||||
$loop_cnt = $loop_cnt + 1
|
||||
sleep 200
|
||||
if $loop_cnt == 10 then
|
||||
print ====> dnode not ready!
|
||||
return -1
|
||||
endi
|
||||
sql show dnodes
|
||||
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
|
||||
if $data00 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data04 != ready then
|
||||
goto check_dnode_ready
|
||||
endi
|
||||
|
||||
sql connect
|
||||
|
||||
$loop_cnt = 0
|
||||
$vgroups = 2
|
||||
$dbNamme = d0
|
||||
loop_vgroups:
|
||||
print =============== create database $dbNamme vgroups $vgroups
|
||||
sql create database $dbNamme vgroups $vgroups
|
||||
sql show databases
|
||||
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
|
||||
print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29
|
||||
|
||||
if $loop_cnt == 0 then
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 2 then # vgroups
|
||||
print vgroups: $data02
|
||||
return -1
|
||||
endi
|
||||
else
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 == d1 then
|
||||
if $data02 != 4 then # vgroups
|
||||
print vgroups: $data02
|
||||
return -1
|
||||
endi
|
||||
else
|
||||
if $data12 != 4 then # vgroups
|
||||
print vgroups: $data12
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
endi
|
||||
|
||||
sql use $dbNamme
|
||||
|
||||
print =============== create super table
|
||||
sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int)
|
||||
|
||||
sql show stables
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== create child table
|
||||
$tbPrefix = ct
|
||||
$tbNum = 100
|
||||
|
||||
$i = 0
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
sql create table $tb using stb tags( $i )
|
||||
$i = $i + 1
|
||||
endw
|
||||
|
||||
print =============== create normal table
|
||||
sql create table ntb (ts timestamp, c1 int, c2 float, c3 binary(10))
|
||||
|
||||
print =============== create multi topics. notes: now only support:
|
||||
print =============== 1. columns from stb/ctb/ntb; 2. * from ctb/ntb; 3. function from stb/ctb/ntb
|
||||
print =============== will support: * from stb
|
||||
|
||||
sql create topic topic_stb_column as select ts, c1, c3 from stb
|
||||
#sql create topic topic_stb_all as select * from stb
|
||||
sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb
|
||||
|
||||
sql create topic topic_ctb_column as select ts, c1, c3 from ct0
|
||||
sql create topic topic_ctb_all as select * from ct0
|
||||
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0
|
||||
|
||||
sql create topic topic_ntb_column as select ts, c1, c3 from ntb
|
||||
sql create topic topic_ntb_all as select * from ntb
|
||||
sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb
|
||||
|
||||
sql show tables
|
||||
if $rows != 101 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== run_back insert data
|
||||
|
||||
if $loop_cnt == 0 then
|
||||
run_back tsim/tmq/insertFixedDataV2.sim
|
||||
else
|
||||
run_back tsim/tmq/insertFixedDataV4.sim
|
||||
endi
|
||||
|
||||
#sleep 1000
|
||||
|
||||
#$rowNum = 1000
|
||||
#$tstart = 1640966400000 # 2022-01-01 00:00:00.000
|
||||
#
|
||||
#$i = 0
|
||||
#while $i < $tbNum
|
||||
# $tb = $tbPrefix . $i
|
||||
#
|
||||
# $x = 0
|
||||
# while $x < $rowNum
|
||||
# $c = $x / 10
|
||||
# $c = $c * 10
|
||||
# $c = $x - $c
|
||||
#
|
||||
# $binary = ' . binary
|
||||
# $binary = $binary . $c
|
||||
# $binary = $binary . '
|
||||
#
|
||||
# sql insert into $tb values ($tstart , $c , $x , $binary )
|
||||
# sql insert into ntb values ($tstart , $c , $x , $binary )
|
||||
# $tstart = $tstart + 1
|
||||
# $x = $x + 1
|
||||
# endw
|
||||
#
|
||||
# $i = $i + 1
|
||||
# $tstart = 1640966400000
|
||||
#endw
|
||||
|
||||
#root@trd02 /home $ tmq_sim --help
|
||||
# -c Configuration directory, default is
|
||||
# -d The name of the database for cosumer, no default
|
||||
# -t The topic string for cosumer, no default
|
||||
# -k The key-value string for cosumer, no default
|
||||
# -g showMsgFlag, default is 0
|
||||
#
|
||||
|
||||
$tbNum = 10
|
||||
$consumeDelay = 10
|
||||
$expectMsgCntFromCtb = 300
|
||||
$expectMsgCntFromStb = $expectMsgCntFromCtb * $tbNum
|
||||
print consumeDelay: $consumeDelay
|
||||
print insert data child num: $tbNum
|
||||
print expectMsgCntFromCtb: $expectMsgCntFromCtb
|
||||
print expectMsgCntFromStb: $expectMsgCntFromStb
|
||||
|
||||
# supported key:
|
||||
# group.id:<xxx>
|
||||
# enable.auto.commit:<true | false>
|
||||
# auto.offset.reset:<earliest | latest | none>
|
||||
# td.connect.ip:<fqdn | ipaddress>
|
||||
# td.connect.user:root
|
||||
# td.connect.pass:taosdata
|
||||
# td.connect.port:6030
|
||||
# td.connect.db:db
|
||||
|
||||
#$expect_result = @{consume success: @
|
||||
#$expect_result = $expect_result . $rowNum
|
||||
#$expect_result = $expect_result . @, @
|
||||
#$expect_result = $expect_result . 0}
|
||||
#print expect_result----> $expect_result
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_column" -k1 "group.id:tg2" -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_column" -k1 "group.id:tg2" -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_all" -k1 "group.id:tg2" -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_all" -k1 "group.id:tg2" -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_function" -k1 "group.id:tg2" -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ctb_function" -k1 "group.id:tg2" -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#$expect_result = @{consume success: @
|
||||
#$expect_result = $expect_result . $totalMsgCnt
|
||||
#$expect_result = $expect_result . @, @
|
||||
#$expect_result = $expect_result . 0}
|
||||
#print expect_result----> $expect_result
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_column" -k1 "group.id:tg2" -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_column" -k1 "group.id:tg2" -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_all" -k1 "group.id:tg2" -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_all" -k1 "group.id:tg2" -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_function" -k1 "group.id:tg2" -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_ntb_function" -k1 "group.id:tg2" -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
#print cmd result----> $system_content
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
$expect_result = @{consume success: @
|
||||
$expect_result = $expect_result . $expectMsgCntFromStb
|
||||
$expect_result = $expect_result . @, @
|
||||
$expect_result = $expect_result . 0}
|
||||
print expect_result----> $expect_result
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 1
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 1
|
||||
print cmd result----> $system_content
|
||||
if $system_content != success then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 1
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 1
|
||||
#print cmd result----> $system_content
|
||||
##if $system_content != @{consume success: 10000, 0}@ then
|
||||
#if $system_content != success then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 1
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 1
|
||||
print cmd result----> $system_content
|
||||
#if $system_content != @{consume success: 10000, 0}@ then
|
||||
if $system_content != success then
|
||||
return -1
|
||||
endi
|
||||
if $loop_cnt == 0 then
|
||||
$loop_cnt = 1
|
||||
$vgroups = 4
|
||||
$dbNamme = d1
|
||||
goto loop_vgroups
|
||||
endi
|
||||
|
||||
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -120,9 +120,9 @@ endi
|
|||
print =============== run_back insert data
|
||||
|
||||
if $loop_cnt == 0 then
|
||||
run_back tsim/tmq/insertDataV1.sim
|
||||
run_back tsim/tmq/insertFixedDataV2.sim
|
||||
else
|
||||
run_back tsim/tmq/insertDataV4.sim
|
||||
run_back tsim/tmq/insertFixedDataV4.sim
|
||||
endi
|
||||
|
||||
#sleep 1000
|
||||
|
@ -162,9 +162,16 @@ endi
|
|||
# -g showMsgFlag, default is 0
|
||||
#
|
||||
|
||||
$consumeDelay = 50
|
||||
$consumeMsgCntFromTopic = 1000
|
||||
print consumeMsgCntFromTopic: $consumeMsgCntFromTopic , consumeDelay: $consumeDelay
|
||||
$tbNum = 10
|
||||
$consumeDelay = 5
|
||||
$expectMsgCntFromCtb = 1000
|
||||
$expectMsgCntFromNtb = 1000
|
||||
$expectMsgCntFromStb = $expectMsgCntFromCtb * $tbNum
|
||||
print consumeDelay: $consumeDelay
|
||||
print insert data child num: $tbNum
|
||||
print expectMsgCntFromCtb: $expectMsgCntFromCtb
|
||||
print expectMsgCntFromStb: $expectMsgCntFromStb
|
||||
|
||||
|
||||
# supported key:
|
||||
# group.id:<xxx>
|
||||
|
@ -177,49 +184,50 @@ print consumeMsgCntFromTopic: $consumeMsgCntFromTopic , consumeDelay: $consumeDe
|
|||
# td.connect.db:db
|
||||
|
||||
$numOfTopics = 2
|
||||
$expectConsumeMsgCnt = $consumeMsgCntFromTopic * $numOfTopics
|
||||
$expectMsgCntFromStb = $expectMsgCntFromStb * $numOfTopics
|
||||
$expect_result = @{consume success: @
|
||||
$expect_result = $expect_result . $expectConsumeMsgCnt
|
||||
$expect_result = $expect_result . $expectMsgCntFromStb
|
||||
$expect_result = $expect_result . @, @
|
||||
$expect_result = $expect_result . 0}
|
||||
print expect_result----> $expect_result
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function, topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function, topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function, topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function, topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
print cmd result----> $system_content
|
||||
#if $system_content != @{consume success: 20000, 0}@ then
|
||||
if $system_content < $expect_result then
|
||||
if $system_content != $expect_result then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$numOfTopics = 3
|
||||
$expectConsumeMsgCnt = $consumeMsgCntFromTopic * $numOfTopics
|
||||
$expectMsgCntFromCtb = $expectMsgCntFromCtb * $numOfTopics
|
||||
$expect_result = @{consume success: @
|
||||
$expect_result = $expect_result . $expectConsumeMsgCnt
|
||||
$expect_result = $expect_result . $expectMsgCntFromCtb
|
||||
$expect_result = $expect_result . @, @
|
||||
$expect_result = $expect_result . 0}
|
||||
print expect_result----> $expect_result
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column, topic_ctb_function, topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column, topic_ctb_function, topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column, topic_ctb_function, topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column, topic_ctb_function, topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
print cmd result----> $system_content
|
||||
#if $system_content != @{consume success: 300, 0}@ then
|
||||
if $system_content < $expectConsumeMsgCnt then
|
||||
if $system_content != $expect_result then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$numOfTopics = 3
|
||||
$expectConsumeMsgCnt = $consumeMsgCntFromTopic * $numOfTopics
|
||||
$expectMsgCntFromNtb = $expectMsgCntFromNtb * $tbNum
|
||||
$expectMsgCntFromNtb = $expectMsgCntFromNtb * $numOfTopics
|
||||
$expect_result = @{consume success: @
|
||||
$expect_result = $expect_result . $expectConsumeMsgCnt
|
||||
$expect_result = $expect_result . $expectMsgCntFromNtb
|
||||
$expect_result = $expect_result . @, @
|
||||
$expect_result = $expect_result . 0}
|
||||
print expect_result----> $expect_result
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column, topic_ntb_all, topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column, topic_ntb_all, topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column, topic_ntb_all, topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromNtb
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column, topic_ntb_all, topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromNtb
|
||||
print cmd result----> $system_content
|
||||
#if $system_content != @{consume success: 30000, 0}@ then
|
||||
if $system_content < $expectConsumeMsgCnt then
|
||||
if $system_content != $expect_result then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
|
|
@ -120,9 +120,9 @@ endi
|
|||
print =============== run_back insert data
|
||||
|
||||
if $loop_cnt == 0 then
|
||||
run_back tsim/tmq/insertDataV1.sim
|
||||
run_back tsim/tmq/insertFixedDataV2.sim
|
||||
else
|
||||
run_back tsim/tmq/insertDataV4.sim
|
||||
run_back tsim/tmq/insertFixedDataV4.sim
|
||||
endi
|
||||
|
||||
#sleep 1000
|
||||
|
@ -162,9 +162,15 @@ endi
|
|||
# -g showMsgFlag, default is 0
|
||||
#
|
||||
|
||||
$consumeDelay = 50
|
||||
$expectConsumeMsgCnt = 1000
|
||||
print expectConsumeMsgCnt: $expectConsumeMsgCnt , consumeDelay: $consumeDelay
|
||||
$tbNum = 10
|
||||
$consumeDelay = 5
|
||||
$expectMsgCntFromCtb = 1000
|
||||
$expectMsgCntFromStb = $expectMsgCntFromCtb * $tbNum
|
||||
print consumeDelay: $consumeDelay
|
||||
print insert data child num: $tbNum
|
||||
print expectMsgCntFromCtb: $expectMsgCntFromCtb
|
||||
print expectMsgCntFromStb: $expectMsgCntFromStb
|
||||
|
||||
|
||||
# supported key:
|
||||
# group.id:<xxx>
|
||||
|
@ -177,82 +183,82 @@ print expectConsumeMsgCnt: $expectConsumeMsgCnt , consumeDelay: $consumeDelay
|
|||
# td.connect.db:db
|
||||
|
||||
$expect_result = @{consume success: @
|
||||
$expect_result = $expect_result . $expectConsumeMsgCnt
|
||||
$expect_result = $expect_result . $expectMsgCntFromStb
|
||||
$expect_result = $expect_result . @, @
|
||||
$expect_result = $expect_result . 0}
|
||||
print expect_result----> $expect_result
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
print cmd result----> $system_content
|
||||
if $system_content < $expectConsumeMsgCnt then
|
||||
if $system_content != $expect_result then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
#print cmd result----> $system_content
|
||||
##if $system_content != @{consume success: 10000, 0}@ then
|
||||
#if $system_content < $expectConsumeMsgCnt then
|
||||
#if $system_content != $expect_result then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
|
||||
print cmd result----> $system_content
|
||||
#if $system_content != @{consume success: 10000, 0}@ then
|
||||
if $system_content < $expectConsumeMsgCnt then
|
||||
if $system_content != $expect_result then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$expect_result = @{consume success: @
|
||||
$expect_result = $expect_result . $rowNum
|
||||
$expect_result = $expect_result . $expectMsgCntFromCtb
|
||||
$expect_result = $expect_result . @, @
|
||||
$expect_result = $expect_result . 0}
|
||||
print expect_result----> $expect_result
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
print cmd result----> $system_content
|
||||
if $system_content < $expectConsumeMsgCnt then
|
||||
if $system_content != $expect_result then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
print cmd result----> $system_content
|
||||
if $system_content < $expectConsumeMsgCnt then
|
||||
if $system_content != $expect_result then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
print cmd result----> $system_content
|
||||
if $system_content < $expectConsumeMsgCnt then
|
||||
if $system_content != $expect_result then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$expect_result = @{consume success: @
|
||||
$expect_result = $expect_result . $totalMsgCnt
|
||||
$expect_result = $expect_result . $expectMsgCntFromStb
|
||||
$expect_result = $expect_result . @, @
|
||||
$expect_result = $expect_result . 0}
|
||||
print expect_result----> $expect_result
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
print cmd result----> $system_content
|
||||
if $system_content < $expectConsumeMsgCnt then
|
||||
if $system_content != $expect_result then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
print cmd result----> $system_content
|
||||
if $system_content < $expectConsumeMsgCnt then
|
||||
if $system_content != $expect_result then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
|
||||
print cmd result----> $system_content
|
||||
if $system_content < $expectConsumeMsgCnt then
|
||||
if $system_content != $expect_result then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
|
|
@ -34,14 +34,23 @@
|
|||
#define MAX_SQL_STR_LEN (1024 * 1024)
|
||||
#define MAX_ROW_STR_LEN (16 * 1024)
|
||||
|
||||
typedef struct {
|
||||
int32_t expectMsgCnt;
|
||||
int32_t consumeMsgCnt;
|
||||
TdThread thread;
|
||||
} SThreadInfo;
|
||||
|
||||
typedef struct {
|
||||
// input from argvs
|
||||
char dbName[32];
|
||||
char topicString[256];
|
||||
char keyString[1024];
|
||||
char topicString1[256];
|
||||
char keyString1[1024];
|
||||
int32_t showMsgFlag;
|
||||
int32_t consumeDelay; // unit s
|
||||
int32_t consumeMsgCnt;
|
||||
int32_t checkMode;
|
||||
|
||||
// save result after parse agrvs
|
||||
int32_t numOfTopic;
|
||||
|
@ -50,6 +59,13 @@ typedef struct {
|
|||
int32_t numOfKey;
|
||||
char key[32][64];
|
||||
char value[32][64];
|
||||
|
||||
int32_t numOfTopic1;
|
||||
char topics1[32][64];
|
||||
|
||||
int32_t numOfKey1;
|
||||
char key1[32][64];
|
||||
char value1[32][64];
|
||||
} SConfInfo;
|
||||
|
||||
static SConfInfo g_stConfInfo;
|
||||
|
@ -69,12 +85,18 @@ static void printHelp() {
|
|||
printf("%s%s%s\n", indent, indent, "The topic string for cosumer, no default ");
|
||||
printf("%s%s\n", indent, "-k");
|
||||
printf("%s%s%s\n", indent, indent, "The key-value string for cosumer, no default ");
|
||||
printf("%s%s\n", indent, "-t1");
|
||||
printf("%s%s%s\n", indent, indent, "The topic1 string for cosumer, no default ");
|
||||
printf("%s%s\n", indent, "-k1");
|
||||
printf("%s%s%s\n", indent, indent, "The key1-value1 string for cosumer, no default ");
|
||||
printf("%s%s\n", indent, "-g");
|
||||
printf("%s%s%s%d\n", indent, indent, "showMsgFlag, default is ", g_stConfInfo.showMsgFlag);
|
||||
printf("%s%s\n", indent, "-y");
|
||||
printf("%s%s%s%d\n", indent, indent, "consume delay, default is s", g_stConfInfo.consumeDelay);
|
||||
printf("%s%s\n", indent, "-m");
|
||||
printf("%s%s%s%d\n", indent, indent, "consume msg count, default is s", g_stConfInfo.consumeMsgCnt);
|
||||
printf("%s%s\n", indent, "-j");
|
||||
printf("%s%s%s%d\n", indent, indent, "check mode, default is s", g_stConfInfo.checkMode);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -96,12 +118,18 @@ void parseArgument(int32_t argc, char* argv[]) {
|
|||
strcpy(g_stConfInfo.topicString, argv[++i]);
|
||||
} else if (strcmp(argv[i], "-k") == 0) {
|
||||
strcpy(g_stConfInfo.keyString, argv[++i]);
|
||||
} else if (strcmp(argv[i], "-t1") == 0) {
|
||||
strcpy(g_stConfInfo.topicString1, argv[++i]);
|
||||
} else if (strcmp(argv[i], "-k1") == 0) {
|
||||
strcpy(g_stConfInfo.keyString1, argv[++i]);
|
||||
} else if (strcmp(argv[i], "-g") == 0) {
|
||||
g_stConfInfo.showMsgFlag = atol(argv[++i]);
|
||||
} else if (strcmp(argv[i], "-y") == 0) {
|
||||
g_stConfInfo.consumeDelay = atol(argv[++i]);
|
||||
} else if (strcmp(argv[i], "-m") == 0) {
|
||||
g_stConfInfo.consumeMsgCnt = atol(argv[++i]);
|
||||
} else if (strcmp(argv[i], "-j") == 0) {
|
||||
g_stConfInfo.checkMode = atol(argv[++i]);
|
||||
} else {
|
||||
printf("%s unknow para: %s %s", GREEN, argv[++i], NC);
|
||||
exit(-1);
|
||||
|
@ -158,6 +186,17 @@ void parseInputString() {
|
|||
token = strtok(NULL, delim);
|
||||
}
|
||||
|
||||
token = strtok(g_stConfInfo.topicString1, delim);
|
||||
while(token != NULL) {
|
||||
//printf("%s\n", token );
|
||||
strcpy(g_stConfInfo.topics1[g_stConfInfo.numOfTopic1], token);
|
||||
ltrim(g_stConfInfo.topics1[g_stConfInfo.numOfTopic1]);
|
||||
//printf("%s\n", g_stConfInfo.topics[g_stConfInfo.numOfTopic]);
|
||||
g_stConfInfo.numOfTopic1++;
|
||||
|
||||
token = strtok(NULL, delim);
|
||||
}
|
||||
|
||||
token = strtok(g_stConfInfo.keyString, delim);
|
||||
while (token != NULL) {
|
||||
// printf("%s\n", token );
|
||||
|
@ -174,8 +213,25 @@ void parseInputString() {
|
|||
|
||||
token = strtok(NULL, delim);
|
||||
}
|
||||
|
||||
token = strtok(g_stConfInfo.keyString1, delim);
|
||||
while(token != NULL) {
|
||||
//printf("%s\n", token );
|
||||
{
|
||||
char* pstr = token;
|
||||
ltrim(pstr);
|
||||
char *ret = strchr(pstr, ch);
|
||||
memcpy(g_stConfInfo.key1[g_stConfInfo.numOfKey1], pstr, ret-pstr);
|
||||
strcpy(g_stConfInfo.value1[g_stConfInfo.numOfKey1], ret+1);
|
||||
//printf("key: %s, value: %s\n", g_stConfInfo.key[g_stConfInfo.numOfKey], g_stConfInfo.value[g_stConfInfo.numOfKey]);
|
||||
g_stConfInfo.numOfKey1++;
|
||||
}
|
||||
|
||||
token = strtok(NULL, delim);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int running = 1;
|
||||
/*static void msg_process(tmq_message_t* message) { tmqShowMsg(message); }*/
|
||||
|
||||
|
@ -225,6 +281,40 @@ tmq_list_t* build_topic_list() {
|
|||
return topic_list;
|
||||
}
|
||||
|
||||
|
||||
tmq_t* build_consumer_x() {
|
||||
char sqlStr[1024] = {0};
|
||||
|
||||
TAOS* pConn = taos_connect(NULL, "root", "taosdata", NULL, 0);
|
||||
assert(pConn != NULL);
|
||||
|
||||
sprintf(sqlStr, "use %s", g_stConfInfo.dbName);
|
||||
TAOS_RES* pRes = taos_query(pConn, sqlStr);
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in use db, reason:%s\n", taos_errstr(pRes));
|
||||
taos_free_result(pRes);
|
||||
exit(-1);
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
tmq_conf_t* conf = tmq_conf_new();
|
||||
//tmq_conf_set(conf, "group.id", "tg2");
|
||||
for (int32_t i = 0; i < g_stConfInfo.numOfKey1; i++) {
|
||||
tmq_conf_set(conf, g_stConfInfo.key1[i], g_stConfInfo.value1[i]);
|
||||
}
|
||||
tmq_t* tmq = tmq_consumer_new(pConn, conf, NULL, 0);
|
||||
return tmq;
|
||||
}
|
||||
|
||||
tmq_list_t* build_topic_list_x() {
|
||||
tmq_list_t* topic_list = tmq_list_new();
|
||||
//tmq_list_append(topic_list, "test_stb_topic_1");
|
||||
for (int32_t i = 0; i < g_stConfInfo.numOfTopic1; i++) {
|
||||
tmq_list_append(topic_list, g_stConfInfo.topics1[i]);
|
||||
}
|
||||
return topic_list;
|
||||
}
|
||||
|
||||
void loop_consume(tmq_t* tmq) {
|
||||
tmq_resp_err_t err;
|
||||
|
||||
|
@ -262,7 +352,7 @@ void loop_consume(tmq_t* tmq) {
|
|||
printf("{consume success: %d, %d}", totalMsgs, totalRows);
|
||||
}
|
||||
|
||||
void parallel_consume(tmq_t* tmq) {
|
||||
int32_t parallel_consume(tmq_t* tmq, int threadLable) {
|
||||
tmq_resp_err_t err;
|
||||
|
||||
int32_t totalMsgs = 0;
|
||||
|
@ -273,6 +363,8 @@ void parallel_consume(tmq_t* tmq) {
|
|||
if (tmqMsg) {
|
||||
totalMsgs++;
|
||||
|
||||
//printf("threadFlag: %d, totalMsgs: %d\n", threadLable, totalMsgs);
|
||||
|
||||
#if 0
|
||||
TAOS_ROW row;
|
||||
while (NULL != (row = tmq_get_row(tmqMsg))) {
|
||||
|
@ -300,13 +392,65 @@ void parallel_consume(tmq_t* tmq) {
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
printf("%d", totalMsgs); // output to sim for check result
|
||||
//printf("%d", totalMsgs); // output to sim for check result
|
||||
return totalMsgs;
|
||||
}
|
||||
|
||||
|
||||
void *threadFunc(void *param) {
|
||||
int32_t totalMsgs = 0;
|
||||
|
||||
SThreadInfo *pInfo = (SThreadInfo *)param;
|
||||
|
||||
tmq_t* tmq = build_consumer_x();
|
||||
tmq_list_t* topic_list = build_topic_list_x();
|
||||
if ((NULL == tmq) || (NULL == topic_list)){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tmq_resp_err_t err = tmq_subscribe(tmq, topic_list);
|
||||
if (err) {
|
||||
printf("tmq_subscribe() fail, reason: %s\n", tmq_err2str(err));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
//if (0 == g_stConfInfo.consumeMsgCnt) {
|
||||
// loop_consume(tmq);
|
||||
//} else {
|
||||
pInfo->consumeMsgCnt = parallel_consume(tmq, 1);
|
||||
//}
|
||||
|
||||
err = tmq_unsubscribe(tmq);
|
||||
if (err) {
|
||||
printf("tmq_unsubscribe() fail, reason: %s\n", tmq_err2str(err));
|
||||
pInfo->consumeMsgCnt = -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int main(int32_t argc, char* argv[]) {
|
||||
parseArgument(argc, argv);
|
||||
parseInputString();
|
||||
|
||||
int32_t numOfThreads = 1;
|
||||
TdThreadAttr thattr;
|
||||
taosThreadAttrInit(&thattr);
|
||||
taosThreadAttrSetDetachState(&thattr, PTHREAD_CREATE_JOINABLE);
|
||||
SThreadInfo *pInfo = (SThreadInfo *)taosMemoryCalloc(numOfThreads, sizeof(SThreadInfo));
|
||||
|
||||
if (g_stConfInfo.numOfTopic1) {
|
||||
// pthread_create one thread to consume
|
||||
for (int32_t i = 0; i < numOfThreads; ++i) {
|
||||
pInfo[i].expectMsgCnt = 0;
|
||||
pInfo[i].consumeMsgCnt = 0;
|
||||
taosThreadCreate(&(pInfo[i].thread), &thattr, threadFunc, (void *)(pInfo + i));
|
||||
}
|
||||
}
|
||||
|
||||
int32_t totalMsgs = 0;
|
||||
tmq_t* tmq = build_consumer();
|
||||
tmq_list_t* topic_list = build_topic_list();
|
||||
if ((NULL == tmq) || (NULL == topic_list)) {
|
||||
|
@ -319,10 +463,10 @@ int main(int32_t argc, char* argv[]) {
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
if (0 == g_stConfInfo.consumeMsgCnt) {
|
||||
if (0 == g_stConfInfo.numOfTopic1) {
|
||||
loop_consume(tmq);
|
||||
} else {
|
||||
parallel_consume(tmq);
|
||||
totalMsgs = parallel_consume(tmq, 0);
|
||||
}
|
||||
|
||||
err = tmq_unsubscribe(tmq);
|
||||
|
@ -331,6 +475,27 @@ int main(int32_t argc, char* argv[]) {
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
if (g_stConfInfo.numOfTopic1) {
|
||||
for (int32_t i = 0; i < numOfThreads; i++) {
|
||||
taosThreadJoin(pInfo[i].thread, NULL);
|
||||
}
|
||||
|
||||
//printf("consumer: %d, cosumer1: %d\n", totalMsgs, pInfo->consumeMsgCnt);
|
||||
if (0 == g_stConfInfo.checkMode) {
|
||||
if ((totalMsgs + pInfo->consumeMsgCnt) == g_stConfInfo.consumeMsgCnt) {
|
||||
printf("success");
|
||||
} else {
|
||||
printf("fail, consumer msg cnt: %d, %d", totalMsgs, pInfo->consumeMsgCnt);
|
||||
}
|
||||
} else if (1 == g_stConfInfo.checkMode) {
|
||||
if ((totalMsgs == g_stConfInfo.consumeMsgCnt) && (pInfo->consumeMsgCnt == g_stConfInfo.consumeMsgCnt)) {
|
||||
printf("success");
|
||||
} else {
|
||||
printf("fail, consumer msg cnt: %d, %d", totalMsgs, pInfo->consumeMsgCnt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue