homework-jianmu/tests/script/tsim/parser/commit.sim

107 lines
2.4 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 = sc_db
$tbPrefix = sc_tb
$stbPrefix = sc_stb
$tbNum = 10
$rowNum = 1000
$totalNum = $tbNum * $rowNum
$loops = 5
$log = 1
$ts0 = 1537146000000
$delta = 600000
print ========== commit.sim
$i = 0
$db = $dbPrefix . $i
$stb = $stbPrefix . $i
sql drop database $db -x step1
step1:
sql create database $db maxrows 255
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 ) $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 from table and check num of rows returned
$loop = 1
$i = 0
while $loop <= $loops
print repeat = $loop
while $i < 10
sql select count(*) from $stb where t1 = $i
if $data00 != $rowNum then
print expect $rowNum , actual: $data00
return -1
endi
$i = $i + 1
endw
sql select count(*) from $stb
if $data00 != $totalNum then
return -1
endi
$loop = $loop + 1
endw
print ================== restart server to commit data into disk
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start
print ================== server restart completed
sql connect
print ====== select from table and check num of rows returned
sql use $db
$loop = 1
$i = 0
while $loop <= $loops
print repeat = $loop
while $i < 10
sql select count(*) from $stb where t1 = $i
if $data00 != $rowNum then
return -1
endi
$i = $i + 1
endw
sql select count(*) from $stb
if $data00 != $totalNum then
print expect $totalNum , actual: $data00
return -1
endi
$loop = $loop + 1
endw
system sh/exec.sh -n dnode1 -s stop -x SIGINT