prepareBasicEnv-1vgrp.sim 2.3 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 29 30 31 32 33 34 35 36 37 38 39 40 41
# stop all dnodes before start this case
system sh/stop_dnodes.sh

# deploy dnode 1
system sh/deploy.sh -n dnode1 -i 1

# add some config items for this case
#system sh/cfg.sh -n dnode1 -c supportVnodes -v 0

# start dnode 1
system sh/exec.sh -n dnode1 -s start

sql connect

#---- global parameters start ----#
$dbName     = db
$vgroups    = 1
$stbPrefix  = stb
$ctbPrefix  = ctb
$ntbPrefix  = ntb
$stbNum     = 1
$ctbNum     = 10
$ntbNum     = 10
$rowsPerCtb = 10
$tstart     = 1640966400000  # 2022-01-01 00:00:00.000
#---- global parameters end ----#

print == create database $dbName vgroups $vgroups
sql create database $dbName vgroups $vgroups

#wait database ready
$loop_cnt = 0
check_db_ready:
if $loop_cnt == 10 then
  print ====> database not ready!
	return -1
endi
sql show databases
print ==> rows: $rows
print ==> $data(db)[0] $data(db)[1] $data(db)[2] $data(db)[3] $data(db)[4] $data(db)[5] $data(db)[6] $data(db)[7] $data(db)[8] $data(db)[9] $data(db)[10] $data(db)[11] $data(db)[12]
print     $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $data(db)[18] $data(db)[19] $data(db)[20]
42
if $data(db)[19] != nostrict then
P
plum-lihui 已提交
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
  sleep 100
  $loop_cnt = $loop_cnt + 1
  goto check_db_ready  
endi

sql use $dbName

print == create consume info table and consume result table
sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)
sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)

sql show tables
if $rows != 2 then 
  return -1
endi

print == create super table
sql create table $stbPrefix (ts timestamp, c1 int, c2 float, c3 binary(16)) tags (t1 int)
sql show stables
if $rows != 1 then 
  return -1
endi

print == create child table, normal table and insert data
$i = 0
while $i < $ctbNum
  $ctb = $ctbPrefix . $i
  $ntb = $ntbPrefix . $i
  sql create table $ctb using $stbPrefix tags( $i )
  sql create table $ntb (ts timestamp, c1 int, c2 float, c3 binary(16))

  $x = 0
  while $x < $rowsPerCtb
    $binary = ' . binary-
    $binary = $binary . $i
    $binary = $binary . '

    sql insert into $ctb values ($tstart , $i , $x , $binary )
    sql insert into $ntb values ($tstart , $i , $x , $binary )
    $tstart = $tstart + 1
    $x = $x + 1
  endw

  $i = $i + 1
  $tstart = 1640966400000
endw