interval.sim 4.5 KB
Newer Older
P
plum-lihui 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
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 )
C
cpwu 已提交
29

P
plum-lihui 已提交
30 31 32 33 34
  $x = 0
  while $x < $rowNum
    $cc = $x * 60000
    $ms = 1601481600000 + $cc

C
cpwu 已提交
35
    sql insert into $tb values ($ms , $x )
P
plum-lihui 已提交
36
    $x = $x + 1
C
cpwu 已提交
37 38
  endw

P
plum-lihui 已提交
39
  $i = $i + 1
C
cpwu 已提交
40
endw
P
plum-lihui 已提交
41 42 43 44 45 46

print =============== step2
$i = 1
$tb = $tbPrefix . $i

sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m)
P
plum-lihui 已提交
47 48
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m)
print ===> $rows $data01 $data05
C
cpwu 已提交
49
if $rows != $rowNum then
P
plum-lihui 已提交
50 51
  return -1
endi
C
cpwu 已提交
52
if $data00 != 1 then
P
plum-lihui 已提交
53 54
  return -1
endi
C
cpwu 已提交
55
if $data04 != 1 then
P
plum-lihui 已提交
56 57 58
  return -1
endi

C
cpwu 已提交
59
print =============== step3
P
plum-lihui 已提交
60 61 62 63 64
#$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
C
cpwu 已提交
65
#if $rows != 5 then
P
plum-lihui 已提交
66 67
#  return -1
#endi
C
cpwu 已提交
68
#if $data00 != 1 then
P
plum-lihui 已提交
69 70
#  return -1
#endi
C
cpwu 已提交
71
#if $data04 != 1 then
P
plum-lihui 已提交
72 73 74
#  return -1
#endi

C
cpwu 已提交
75
print =============== step4
P
plum-lihui 已提交
76 77 78 79 80 81
#$cc = 40 * 60000
#$ms = 1601481600000 + $cc

#$cc = 1 * 60000
#$ms2 = 1601481600000 - $cc

82 83
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)
C
cpwu 已提交
84 85 86 87 88 89 90 91 92 93
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
P
plum-lihui 已提交
94 95 96 97 98 99 100 101 102 103 104

#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
C
cpwu 已提交
105
#if $rows != 42 then
P
plum-lihui 已提交
106 107
#  return -1
#endi
C
cpwu 已提交
108
#if $data20 != 1 then
P
plum-lihui 已提交
109 110
#  return -1
#endi
C
cpwu 已提交
111
#if $data24 != 1 then
P
plum-lihui 已提交
112 113 114 115 116 117 118
#  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
C
cpwu 已提交
119
#if $rows != 20 then
P
plum-lihui 已提交
120 121
#  return -1
#endi
C
cpwu 已提交
122
#if $data11 != 10 then
P
plum-lihui 已提交
123 124 125 126 127 128 129 130 131
#  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
C
cpwu 已提交
132
#if $rows != 5 then
P
plum-lihui 已提交
133 134
#  return -1
#endi
C
cpwu 已提交
135
#if $data11 != 10 then
P
plum-lihui 已提交
136 137 138 139 140 141 142 143 144 145 146 147 148
#  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
C
cpwu 已提交
149
#if $rows != 20 then
P
plum-lihui 已提交
150 151
#  return -1
#endi
C
cpwu 已提交
152
#if $data11 != 10 then
P
plum-lihui 已提交
153 154 155 156 157 158 159 160 161 162 163 164 165
#  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
C
cpwu 已提交
166
#if $rows != 42 then
P
plum-lihui 已提交
167 168
#  return -1
#endi
C
cpwu 已提交
169
#if $data11 != 10 then
P
plum-lihui 已提交
170 171
#  return -1
#endi
P
plum-lihui 已提交
172 173

print =============== clear
P
plum-lihui 已提交
174
#sql drop database $db
X
Xiaoyu Wang 已提交
175
#sql select * from information_schema.ins_databases
C
cpwu 已提交
176
#if $rows != 0 then
P
plum-lihui 已提交
177 178
#  return -1
#endi
P
plum-lihui 已提交
179

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