topbot.sim 6.4 KB
Newer Older
H
Haojun Liao 已提交
1 2 3 4
system sh/stop_dnodes.sh

system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 0
H
Haojun Liao 已提交
5 6
system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 200

H
Haojun Liao 已提交
7
system sh/exec.sh -n dnode1 -s start
H
Haojun Liao 已提交
8
sleep 500
H
Haojun Liao 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
sql connect

$dbPrefix = tb_db
$tbPrefix = tb_tb
$stbPrefix = tb_stb
$tbNum = 10
$rowNum = 1000
$totalNum = $tbNum * $rowNum
$loops = 200000
$log = 10000
$ts0 = 1537146000000
$delta = 600000
print ========== topbot.sim
$i = 0
$db = $dbPrefix . $i
$stb = $stbPrefix . $i

sql drop database $db -x step1
step1:
H
Haojun Liao 已提交
28
sql create database $db cache 16 maxrows 4096 keep 36500
H
Haojun Liao 已提交
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
print ====== create tables
sql use $db
sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int)

$i = 0
$ts = $ts0
$halfNum = $tbNum / 2
while $i < $halfNum
  $tbId = $i + $halfNum
  $tb = $tbPrefix . $i
  $tb1 = $tbPrefix . $tbId
  sql create table $tb using $stb tags( $i )
  sql create table $tb1 using $stb tags( $tbId )

  $x = 0
  while $x < $rowNum
    $xs = $x * $delta
    $ts = $ts0 + $xs
    $c = $x / 10
    $c = $c * 10
    $c = $x - $c
    $binary = 'binary . $c
    $binary = $binary . '
    $nchar = 'nchar . $c
    $nchar = $nchar . '
    sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar )
    sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar )
    $x = $x + 1
  endw

  $i = $i + 1
endw
print ====== tables created

sql use $db
##### select from table
print ====== select top/bot from table and check num of rows returned
sql select top(c1, 100) from tb_stb0
if $row != 100 then
  return -1
endi

H
Haojun Liao 已提交
71 72 73 74 75
sql select bottom(c1, 100) from tb_stb0
if $row != 100 then
  return -1
endi

H
Haojun Liao 已提交
76
sql select last(*) from tb_tb9
H
Haojun Liao 已提交
77 78 79 80
if $row != 1 then
  return -1
endi

H
Haojun Liao 已提交
81 82 83 84 85 86 87 88 89 90
sql select last(c2) from tb_tb9
if $row != 0 then
  return -1
endi

sql select first(c2), last(c2) from tb_tb9
if $row != 0 then
  return -1
endi

H
Haojun Liao 已提交
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
sql create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20));
sql create table test1 using test tags('beijing');
sql insert into test1 values(1537146000000, 1, 1, 1, 1, 0.100000, 0.100000, 0, 'taosdata1', '涛思数据1');
sql insert into test1 values(1537146000001, 2, 2, 2, 2, 1.100000, 1.100000, 1, 'taosdata2', '涛思数据2');
sql insert into test1 values(1537146000002, 3, 3, 3, 3, 2.100000, 2.100000, 0, 'taosdata3', '涛思数据3');
sql insert into test1 values(1537146000003, 4, 4, 4, 4, 3.100000, 3.100000, 1, 'taosdata4', '涛思数据4');
sql insert into test1 values(1537146000004, 5, 5, 5, 5, 4.100000, 4.100000, 0, 'taosdata5', '涛思数据5');
sql insert into test1 values(1537146000005, 6, 6, 6, 6, 5.100000, 5.100000, 1, 'taosdata6', '涛思数据6');
sql insert into test1 values(1537146000006, 7, 7, 7, 7, 6.100000, 6.100000, 0, 'taosdata7', '涛思数据7');
sql insert into test1 values(1537146000007, 8, 8, 8, 8, 7.100000, 7.100000, 1, 'taosdata8', '涛思数据8');
sql insert into test1 values(1537146000008, 9, 9, 9, 9, 8.100000, 8.100000, 0, 'taosdata9', '涛思数据9');
sql insert into test1 values(1537146000009, 10, 10, 10, 10, 9.100000, 9.100000, 1, 'taosdata10', '涛思数据10');
sql select bottom(col5, 10) from test
if $rows != 10 then
  return -1
endi

if $data01 != 0.10000 then
  print expect 0.10000 actual: $data01
  return -1
endi

if $data11 != 1.10000 then
  print expect 1.10000 actual: $data11
  return -1
endi

if $data21 != 2.10000 then
  print expect 2.10000 actual: $data21
  return -1
endi

H
Haojun Liao 已提交
123 124 125 126 127 128 129 130
print =====================td-1302 case
sql create database t1 keep 36500;
sql use t1;
sql create table test(ts timestamp, k int);
sql insert into test values(29999, 1)(70000, 2)(80000, 3)

print ================== restart server to commit data into disk
system sh/exec.sh -n dnode1 -s stop -x SIGINT
H
Haojun Liao 已提交
131
sleep 3000
H
Haojun Liao 已提交
132 133 134
system sh/exec.sh -n dnode1 -s start
print ================== server restart completed
sql connect
H
Haojun Liao 已提交
135
sleep 500
H
Haojun Liao 已提交
136 137 138 139 140 141

sql select count(*) from t1.test where ts>10000 and ts<90000 interval(5000a)
if $rows != 3 then
 return -1
endi

H
Haojun Liao 已提交
142 143
print ==============>td-1308
sql create database db keep 36500;
H
Haojun Liao 已提交
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
sql use db;

sql create table stb (ts timestamp, c1 int, c2 binary(10)) tags(t1 binary(10));
sql create table tb1 using stb tags('a1');

sql insert into tb1 values('2020-09-03 15:30:48.812', 0, 'tb1');
sql select count(*) from stb where ts > '2020-09-03 15:30:44' interval(4s);
if $rows != 1 then
  return -1
endi

sql create table tb4 using stb tags('a4');
sql select count(*) from stb where ts > '2020-09-03 15:30:44' interval(4s);
if $rows != 1 then
  return -1
endi

H
Haojun Liao 已提交
161 162 163 164 165 166 167 168 169 170 171
print =======================>td-1446
sql create table t(ts timestamp, k int)
$ts = 6000
while $ts < 7000
  sql insert into t values ( $ts , $ts )
  $ts = $ts + 1
endw

system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start
sql connect
H
Haojun Liao 已提交
172
sleep 500
H
Haojun Liao 已提交
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
sql use db;

$ts = 1000
while $ts < 5096
  sql insert into t values ( $ts , $ts )
  $ts = $ts + 1
endw

sql select * from t where ts < 6500
if $rows != 4596 then
  print expect 4596, actual: $rows
  return -1
endi

sql select * from t where ts < 7000
if $rows != 5096 then
  return -1
endi

sql select * from t where ts <= 6000
if $rows != 4097 then
  return -1
endi

sql select * from t where ts <= 6001
if $rows != 4098 then
  return -1
endi

H
Haojun Liao 已提交
202 203 204 205 206 207 208 209 210 211 212 213 214 215
print ======================>td-1454
sql select count(*)/10, count(*)+99 from t
if $rows != 1  then
  return -1
endi

if $data00 != 509.600000000 then
  return -1
endi

if $data01 != 5195.000000000 then
  return -1
endi

H
Haojun Liao 已提交
216 217 218 219 220 221 222 223
print =======================>td-1596
sql create table t2(ts timestamp, k int)
sql insert into t2 values('2020-1-2 1:1:1', 1);
sql insert into t2 values('2020-2-2 1:1:1', 1);

system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start
sql connect
H
Haojun Liao 已提交
224
sleep 500
H
Haojun Liao 已提交
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264

sql use db
sql select count(*), first(ts), last(ts) from t2 interval(1d);
if $rows != 2 then
  return -1
endi

if $data00 != @20-01-02 00:00:00.000@ then
  print expect 20-01-02 00:00:00.000, actual: $data00
  return -1
endi

if $data10 != @20-02-02 00:00:00.000@ then
  return -1
endi

if $data01 != 1 then
  return -1
endi

if $data11 != 1 then
  return -1
endi

if $data02 != @20-01-02 01:01:01.000@ then
  return -1
endi

if $data12 != @20-02-02 01:01:01.000@ then
  return -1
endi

if $data03 != @20-01-02 01:01:01.000@ then
  return -1
endi

if $data13 != @20-02-02 01:01:01.000@ then
  return -1
endi

H
Haojun Liao 已提交
265
system sh/exec.sh -n dnode1 -s stop -x SIGINT