first_last.sim 2.8 KB
Newer Older
S
slguan 已提交
1
system sh/stop_dnodes.sh
S
slguan 已提交
2 3

system sh/deploy.sh -n dnode1 -i 1
H
hjxilinx 已提交
4
system sh/cfg.sh -n dnode1 -c walLevel -v 0
H
Haojun Liao 已提交
5
system sh/cfg.sh -n dnode1 -c maxTablespervnode -v 4
S
slguan 已提交
6
system sh/exec.sh -n dnode1 -s start
H
Haojun Liao 已提交
7
sleep 500
S
slguan 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
sql connect

$dbPrefix = first_db
$tbPrefix = first_tb
$stbPrefix = first_stb
$tbNum = 10
$rowNum = 1000
$totalNum = $tbNum * $rowNum
$ts0 = 1537146000000
$delta = 60000
print ========== first_last.sim
$i = 0
$db = $dbPrefix . $i
$stb = $stbPrefix . $i

sql drop database $db -x step1
step1:
25

H
Haojun Liao 已提交
26
sql create database $db maxrows 400 cache 1
27

S
slguan 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
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
while $i < $tbNum
  $tb = $tbPrefix . $i
  sql create table $tb using $stb tags( $i )
  
  $x = 0
  while $x < $rowNum
    $xs = $x * $delta
    $ts = $ts0 + $xs
    $c6 =  $x / 128 
    $c6 = $c6 * 128
    $c6 = $x - $c6
    sql insert into $tb values ( $ts , $x , $x , $x , $x , $x , $c6 , true, 'BINARY', 'NCHAR' ) 
    $x = $x + 1
  endw 
 
  $i = $i + 1
H
Haojun Liao 已提交
49 50
endw

S
slguan 已提交
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
$ts = $ts + 60000
$tb = $tbPrefix . 0
sql insert into $tb (ts) values ( $ts )
$tb = $tbPrefix . 1
sql insert into $tb (ts) values ( $ts )
$tb = $tbPrefix . 2
sql insert into $tb (ts) values ( $ts )
$tb = $tbPrefix . 3
sql insert into $tb (ts) values ( $ts )
$tb = $tbPrefix . 4
sql insert into $tb (ts) values ( $ts )
$ts = $ts0 - 60000
$tb = $tbPrefix . 0
sql import into $tb (ts) values ( $ts )
$tb = $tbPrefix . 1
sql import into $tb (ts) values ( $ts )
$tb = $tbPrefix . 2
sql import into $tb (ts) values ( $ts )
$tb = $tbPrefix . 3
sql import into $tb (ts) values ( $ts )
$tb = $tbPrefix . 4
sql import into $tb (ts) values ( $ts )

print ====== test data created

S
scripts  
slguan 已提交
76
run general/parser/first_last_query.sim
S
slguan 已提交
77 78 79

print ================== restart server to commit data into disk
system sh/exec.sh -n dnode1 -s stop -x SIGINT
H
Haojun Liao 已提交
80
sleep 3000
S
slguan 已提交
81 82 83
system sh/exec.sh -n dnode1 -s start
print ================== server restart completed
sql connect
H
Haojun Liao 已提交
84
sleep 500
S
slguan 已提交
85

S
scripts  
slguan 已提交
86
run general/parser/first_last_query.sim
S
slguan 已提交
87

H
Haojun Liao 已提交
88 89 90 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 123 124 125 126
print =================> insert data regression test
sql create database test keep 36500
sql use test
sql create table tm0 (ts timestamp, k int)

print =========================> td-2298
$ts0 = 1537146000000
$xs  = 6000

$x = 0
while $x < 5000
    $ts = $ts0 + $xs
    $ts1 = $ts + $xs
    $x1 = $x + 1

    sql insert into tm0 values ( $ts , $x ) ( $ts1 , $x1 )
    $x = $x1
    $ts0 = $ts1
endw

system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 3000
system sh/exec.sh -n dnode1 -s start
print ================== server restart completed
sql connect
sleep 500

sql use test
sql select count(*), last(ts) from tm0 interval(1s)
if $rows != 10000 then
  print expect 10000, actual: $rows
  return -1
endi

sql select last(ts) from tm0 interval(1s)
if $rows != 10000 then
  return -1
endi

S
scripts  
Shengliang Guan 已提交
127
system sh/exec.sh -n dnode1 -s stop -x SIGINT