selectResNum.sim 4.3 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 200
S
slguan 已提交
6
system sh/exec.sh -n dnode1 -s start
H
Haojun Liao 已提交
7
sleep 1000
S
slguan 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
sql connect

$dbPrefix = sc_db
$tbPrefix = sc_tb
$stbPrefix = sc_stb
$tbNum = 10
$rowNum = 10000
$totalNum = $tbNum * $rowNum
$loops = 200000
$log = 10000
$ts0 = 1537146000000
$delta = 600000
print ========== selectResNum.sim
$i = 0
$db = $dbPrefix . $i
$stb = $stbPrefix . $i

sql drop database $db -x step1
step1:
H
Haojun Liao 已提交
27
sql create database $db cache 16
S
slguan 已提交
28 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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 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
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 from table and check num of rows returned
$loop = 1
$i = 0
while $loop <= $loops
  $remainder = $loop / $log
  $remainder = $remainder * $log
  $remainder = $loop - $remainder
  if $remainder == 0 then
     print loop: $loop
  endi
  while $i < 10
    sql select ts from $stb where t1 = $i 
    if $rows != $rowNum then
      return -1
    endi
    sql select c1 from $stb where t1 = $i 
    if $rows != $rowNum then
      return -1
    endi
    sql select c2 from $stb where t1 = $i 
    if $rows != $rowNum then
      return -1
    endi
    sql select c3 from $stb where t1 = $i 
    if $rows != $rowNum then
      return -1
    endi
    sql select c4 from $stb where t1 = $i 
    if $rows != $rowNum then
      return -1
    endi
    sql select c5 from $stb where t1 = $i 
    if $rows != $rowNum then
      return -1
    endi
    sql select c6 from $stb where t1 = $i 
    if $rows != $rowNum then
      return -1
    endi
    sql select c7 from $stb where t1 = $i 
    if $rows != $rowNum then
      return -1
    endi
    sql select c8 from $stb where t1 = $i 
    if $rows != $rowNum then
      return -1
    endi
    sql select c9 from $stb where t1 = $i 
    if $rows != $rowNum then
      return -1
    endi
    $i = $i + 1
  endw
  $loop = $loop + 1
endw

print ====== restart server to commit data into disk
system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 6000
system sh/exec.sh -n dnode1 -s start
print ====== server restart completed
H
Haojun Liao 已提交
125
sleep 1000
S
slguan 已提交
126
sql connect
H
Haojun Liao 已提交
127
sleep 1000
S
slguan 已提交
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
sql use $db

##### repeat test after server restart
print ====== repeat test after restarting server
$loop = 1
$i = 0
while $loop <= $loops
  $remainder = $loop / $log
  $remainder = $remainder * $log
  $remainder = $loop - $remainder
  if $remainder == 0 then
     print loop: $loop
  endi
  while $i < 10
    sql select ts from $stb where t1 = $i 
    if $rows != $rowNum then
      return -1
    endi
    sql select c1 from $stb where t1 = $i 
    if $rows != $rowNum then
      return -1
    endi
    sql select c2 from $stb where t1 = $i 
    if $rows != $rowNum then
      return -1
    endi
    sql select c3 from $stb where t1 = $i 
    if $rows != $rowNum then
      return -1
    endi
    sql select c4 from $stb where t1 = $i 
    if $rows != $rowNum then
      return -1
    endi
    sql select c5 from $stb where t1 = $i 
    if $rows != $rowNum then
      return -1
    endi
    sql select c6 from $stb where t1 = $i 
    if $rows != $rowNum then
      return -1
    endi
    sql select c7 from $stb where t1 = $i 
    if $rows != $rowNum then
      return -1
    endi
    sql select c8 from $stb where t1 = $i 
    if $rows != $rowNum then
176
      print expect $rowNum, actual: $rows
S
slguan 已提交
177 178 179 180 181 182 183 184 185 186
      return -1
    endi
    sql select c9 from $stb where t1 = $i 
    if $rows != $rowNum then
      return -1
    endi
    $i = $i + 1
  endw
  $loop = $loop + 1
endw
S
scripts  
Shengliang Guan 已提交
187 188

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