361 lines
9.6 KiB
Plaintext
361 lines
9.6 KiB
Plaintext
system sh/stop_dnodes.sh
|
|
system sh/deploy.sh -n dnode1 -i 1
|
|
system sh/exec.sh -n dnode1 -s start
|
|
sql connect
|
|
|
|
$dbPrefix = m_in_db
|
|
$tbPrefix = m_in_tb
|
|
$mtPrefix = m_in_mt
|
|
$tbNum = 10
|
|
$rowNum = 20
|
|
$totalNum = 200
|
|
|
|
print =============== step1
|
|
$i = 0
|
|
$db = $dbPrefix . $i
|
|
$mt = $mtPrefix . $i
|
|
|
|
sql drop database $db -x step1
|
|
step1:
|
|
sql create database $db
|
|
sql use $db
|
|
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int)
|
|
|
|
print ====== start create child tables and insert data
|
|
$i = 0
|
|
while $i < $tbNum
|
|
$tb = $tbPrefix . $i
|
|
sql create table $tb using $mt tags( $i )
|
|
|
|
$x = 0
|
|
while $x < $rowNum
|
|
$cc = $x * 60000
|
|
$ms = 1601481600000 + $cc
|
|
|
|
sql insert into $tb values ($ms , $x )
|
|
$x = $x + 1
|
|
endw
|
|
|
|
$i = $i + 1
|
|
endw
|
|
|
|
print =============== step2
|
|
$i = 1
|
|
$tb = $tbPrefix . $i
|
|
|
|
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m)
|
|
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m)
|
|
print ===> $rows $data01 $data05
|
|
if $rows != $rowNum then
|
|
return -1
|
|
endi
|
|
if $data00 != 1 then
|
|
return -1
|
|
endi
|
|
if $data04 != 1 then
|
|
return -1
|
|
endi
|
|
|
|
print =============== step3
|
|
#$cc = 4 * 60000
|
|
#$ms = 1601481600000 + $cc
|
|
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms interval(1m)
|
|
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms interval(1m)
|
|
#print ===> $rows $data01 $data05
|
|
#if $rows != 5 then
|
|
# return -1
|
|
#endi
|
|
#if $data00 != 1 then
|
|
# return -1
|
|
#endi
|
|
#if $data04 != 1 then
|
|
# return -1
|
|
#endi
|
|
|
|
print =============== step4
|
|
#$cc = 40 * 60000
|
|
#$ms = 1601481600000 + $cc
|
|
|
|
#$cc = 1 * 60000
|
|
#$ms2 = 1601481600000 - $cc
|
|
|
|
sql select _wstart, _wend, _wduration, _qstart, _qend, count(tbcol) from $tb interval(1m)
|
|
print ===> select _wstart, _wend, _wduration, _qstart, _qend, count(tbcol) from $tb interval(1m)
|
|
print ===> $rows $data01 $data05
|
|
if $rows != $rowNum then
|
|
return -1
|
|
endi
|
|
if $data05 != 1 then
|
|
return -1
|
|
endi
|
|
if $data02 != 60000 then
|
|
return -1
|
|
endi
|
|
|
|
#print =============== step5
|
|
#$cc = 40 * 60000
|
|
#$ms = 1601481600000 + $cc
|
|
|
|
#$cc = 1 * 60000
|
|
#$ms2 = 1601481600000 - $cc
|
|
|
|
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0)
|
|
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0)
|
|
#print ===> $rows $data21 $data25
|
|
#if $rows != 42 then
|
|
# return -1
|
|
#endi
|
|
#if $data20 != 1 then
|
|
# return -1
|
|
#endi
|
|
#if $data24 != 1 then
|
|
# return -1
|
|
#endi
|
|
|
|
#print =============== step6
|
|
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m)
|
|
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m)
|
|
#print ===> $rows $data11
|
|
#if $rows != 20 then
|
|
# return -1
|
|
#endi
|
|
#if $data11 != 10 then
|
|
# return -1
|
|
#endi
|
|
|
|
#print =============== step7
|
|
#$cc = 4 * 60000
|
|
#$ms = 1601481600000 + $cc
|
|
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms interval(1m)
|
|
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms interval(1m)
|
|
#print ===> $rows $data11
|
|
#if $rows != 5 then
|
|
# return -1
|
|
#endi
|
|
#if $data11 != 10 then
|
|
# return -1
|
|
#endi
|
|
|
|
#print =============== step8
|
|
#$cc = 40 * 60000
|
|
#$ms1 = 1601481600000 + $cc
|
|
#
|
|
#$cc = 1 * 60000
|
|
#$ms2 = 1601481600000 - $cc
|
|
#
|
|
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m)
|
|
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m)
|
|
#print ===> $rows $data11
|
|
#if $rows != 20 then
|
|
# return -1
|
|
#endi
|
|
#if $data11 != 10 then
|
|
# return -1
|
|
#endi
|
|
#
|
|
#print =============== step9
|
|
#$cc = 40 * 60000
|
|
#$ms1 = 1601481600000 + $cc
|
|
#
|
|
#$cc = 1 * 60000
|
|
#$ms2 = 1601481600000 - $cc
|
|
#
|
|
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0)
|
|
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0)
|
|
#print ===> $rows $data11
|
|
#if $rows != 42 then
|
|
# return -1
|
|
#endi
|
|
#if $data11 != 10 then
|
|
# return -1
|
|
#endi
|
|
|
|
print ================ step10
|
|
print -------- create database and table
|
|
sql create database if not exists test
|
|
sql use test
|
|
sql create stable st (ts timestamp, c2 int) tags(tg int)
|
|
print -------- insert 300 rows data
|
|
$i = 0
|
|
while $i < 300
|
|
$t = 1577807983000
|
|
$cc = $i * 1000
|
|
$t = $t + $cc
|
|
sql select $i % 3
|
|
if $data00 != 0.000000000 then
|
|
goto continue_while
|
|
endi
|
|
sql select $i % 4
|
|
if $data00 == 0.000000000 then
|
|
goto continue_while
|
|
endi
|
|
sql insert into t1 using st tags(1) values ( $t , $i )
|
|
continue_while:
|
|
$i = $i + 1
|
|
endw
|
|
|
|
$ms1 = 1577808120000
|
|
$ms2 = 1577808000000
|
|
sql select * from (select _wstart, last(ts) as ts, avg(c2) as av from t1 where ts <= $ms1 and ts >= $ms2 interval(10s) sliding(1s) fill(NULL)) order by ts asc
|
|
print ----> select asc rows: $rows
|
|
$asc_rows = $rows
|
|
sql select * from (select _wstart, last(ts) as ts, avg(c2) as av from t1 where ts <= $ms1 and ts >= $ms2 interval(10s) sliding(1s) fill(NULL)) order by ts desc
|
|
print ----> select desc rows: $rows
|
|
$desc_rows = $rows
|
|
if $desc_rows != $asc_rows then
|
|
return -1
|
|
endi
|
|
|
|
print ================= step11
|
|
|
|
sql create database if not exists test0828
|
|
sql use test0828
|
|
sql create stable st (ts timestamp, c2 int) tags(tg int)
|
|
sql insert into ct1 using st tags(1) values('2021-08-01', 0)
|
|
sql insert into ct2 using st tags(2) values('2022-08-01', 1)
|
|
sql select _wstart, _wend, count(*) from st where ts>='2021-01-01' and ts < '2023-08-28' interval(1n) fill(value, 0) order by _wstart desc
|
|
print $rows
|
|
if $rows != 32 then
|
|
return -1
|
|
endi
|
|
sql drop database test0828
|
|
print =============== clear
|
|
#sql drop database $db
|
|
#sql select * from information_schema.ins_databases
|
|
#if $rows != 0 then
|
|
# return -1
|
|
#endi
|
|
|
|
print ================= step12
|
|
|
|
sql create database test2 vgroups 4;
|
|
sql use test2;
|
|
sql create stable stb (ts timestamp, c1 int) tags (t1 int);
|
|
sql create table t1 using stb tags (1);
|
|
sql create table t2 using stb tags (2);
|
|
sql create table t3 using stb tags (3);
|
|
sql create table t4 using stb tags (4);
|
|
sql create table t5 using stb tags (4);
|
|
sql create table t6 using stb tags (4);
|
|
sql insert into t1 values ("2024-03-01 14:29:07.051", 11);
|
|
sql insert into t2 values ("2024-03-01 14:29:07.051", 21);
|
|
sql insert into t3 values ("2024-03-01 14:29:07.051", 31);
|
|
sql insert into t4 values ("2024-03-01 14:29:07.051", 41);
|
|
sql insert into t5 values ("2024-03-01 14:29:07.051", 51);
|
|
sql insert into t6 values ("2024-03-01 14:29:07.051", 61);
|
|
sql insert into t1 values ("2024-03-01 14:30:07.051", 12);
|
|
sql insert into t2 values ("2024-03-01 14:30:07.051", 22);
|
|
sql insert into t3 values ("2024-03-01 14:30:07.051", 32);
|
|
sql insert into t4 values ("2024-03-01 14:30:07.051", 42);
|
|
sql insert into t5 values ("2024-03-01 14:30:07.051", 52);
|
|
sql insert into t6 values ("2024-03-01 14:30:07.051", 62);
|
|
sql insert into t1 values ("2024-03-01 14:31:07.051", 13);
|
|
sql insert into t2 values ("2024-03-01 14:31:07.051", 23);
|
|
sql insert into t3 values ("2024-03-01 14:31:07.051", 33);
|
|
sql insert into t4 values ("2024-03-01 14:31:07.051", 43);
|
|
sql insert into t5 values ("2024-03-01 14:31:07.051", 53);
|
|
sql insert into t6 values ("2024-03-01 14:31:07.051", 63);
|
|
sql insert into t1 values ("2024-03-01 14:32:07.051", 14);
|
|
sql insert into t2 values ("2024-03-01 14:32:07.051", 24);
|
|
sql insert into t3 values ("2024-03-01 14:32:07.051", 34);
|
|
sql insert into t4 values ("2024-03-01 14:32:07.051", 44);
|
|
sql insert into t5 values ("2024-03-01 14:32:07.051", 54);
|
|
sql insert into t6 values ("2024-03-01 14:32:07.051", 64);
|
|
sql insert into t1 values ("2024-03-01 14:33:07.051", 15);
|
|
sql insert into t2 values ("2024-03-01 14:33:07.051", 25);
|
|
sql insert into t3 values ("2024-03-01 14:33:07.051", 35);
|
|
sql insert into t4 values ("2024-03-01 14:33:07.051", 45);
|
|
sql insert into t5 values ("2024-03-01 14:33:07.051", 55);
|
|
sql insert into t6 values ("2024-03-01 14:33:07.051", 65);
|
|
sql insert into t1 values ("2024-03-01 14:34:07.051", 16);
|
|
sql insert into t2 values ("2024-03-01 14:34:07.051", 26);
|
|
sql insert into t3 values ("2024-03-01 14:34:07.051", 36);
|
|
sql insert into t4 values ("2024-03-01 14:34:07.051", 46);
|
|
sql insert into t5 values ("2024-03-01 14:34:07.051", 56);
|
|
sql insert into t6 values ("2024-03-01 14:34:07.051", 66);
|
|
|
|
sleep 300
|
|
|
|
sql select _wstart, count(*) from (select * from stb partition by tbname) interval(2s);
|
|
|
|
print $data00,$data01
|
|
print $data10,$data11
|
|
print $data20,$data21
|
|
print $data30,$data31
|
|
print $data40,$data41
|
|
print $data50,$data51
|
|
print $data60,$data61
|
|
print $data70,$data71
|
|
|
|
if $rows != 6 then
|
|
print $rows
|
|
return -1
|
|
endi
|
|
|
|
if $data01 != 6 then
|
|
print $data01
|
|
endi
|
|
|
|
if $data11 != 6 then
|
|
print $data11
|
|
endi
|
|
|
|
if $data21 != 6 then
|
|
print $data21
|
|
endi
|
|
|
|
if $data31 != 6 then
|
|
print $data31
|
|
endi
|
|
|
|
if $data41 != 6 then
|
|
print $data41
|
|
endi
|
|
|
|
if $data51 != 6 then
|
|
print $data51
|
|
endi
|
|
|
|
|
|
sql select _wstart, count(*) from (select * from stb partition by tbname slimit 2) interval(2s);
|
|
|
|
print $data00,$data01
|
|
print $data10,$data11
|
|
print $data20,$data21
|
|
print $data30,$data31
|
|
print $data40,$data41
|
|
print $data50,$data51
|
|
print $data60,$data61
|
|
print $data70,$data71
|
|
|
|
if $rows != 6 then
|
|
print $rows then
|
|
return -1
|
|
endi
|
|
|
|
if $data01 != 2 then
|
|
print $data01
|
|
endi
|
|
|
|
if $data11 != 2 then
|
|
print $data11
|
|
endi
|
|
|
|
if $data21 != 2 then
|
|
print $data21
|
|
endi
|
|
|
|
if $data31 != 2 then
|
|
print $data31
|
|
endi
|
|
|
|
if $data41 != 2 then
|
|
print $data41
|
|
endi
|
|
|
|
if $data51 != 2 then
|
|
print $data51
|
|
endi
|
|
|
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|