system sh/stop_dnodes.sh



system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/cfg.sh -n dnode1 -c walLevel -v 0
system sh/cfg.sh -n dnode2 -c walLevel -v 0
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2
system sh/exec.sh -n dnode1 -s start

sql connect

sql create dnode $hostname2
system sh/exec.sh -n dnode2 -s start
$x = 0
createDnode: 
	$x = $x + 1
	sleep 1000
	if $x == 20 then 
	  return -1
	endi
sql show dnodes;
if $data4_192.168.0.2 == offline then
  goto createDnode
endi  
print ======================== dnode start

$dbPrefix = db
$tbPrefix = tb
$mtPrefix = mt
$stPrefix = st
$tbNum = 10
$rowNum = 20
$totalNum = 200

print =============== step1
$i = 0
$db = $dbPrefix . $i
$mt = $mtPrefix . $i
$st = $stPrefix . $i

sql create database $db replica 2
sql use $db
sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int)

$i = 0
while $i < $tbNum
  $tb = $tbPrefix . $i
  sql create table $tb using $mt tags( $i )
  
  $x = -1440
  $y = 0
  while $y < $rowNum
    $ms = $x . m 
    sql insert into $tb values (now $ms , $y , $y ) 
    $x = $x + 1
	$y = $y + 1
  endw 
 
  $i = $i + 1
endw 

sleep 100

print =============== step2 c1
$i = 1
$tb = $tbPrefix . $i

sql select count(*) from $mt interval(1d)
print select count(*) from $mt interval(1d) ===> $data00 $data01
if $data01 != 200 then 
  return -1
endi

$st = $stPrefix . c1
sql create table $st as select count(*) from $mt interval(1d)

print =============== step3  
system sh/exec.sh -n dnode2 -s stop

print =============== step4
print sleep 22 seconds
sleep 22000 

print =============== step5
$st = $stPrefix . c1
sql select * from $st
print ===> select * from $st ===> $data00 $data01
if $data01 != 200 then 
  return -1
endi

print =============   step6

sql close
system sh/exec.sh -n dnode1 -s stop
system sh/exec.sh -n dnode2 -s stop
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/cfg.sh -n dnode1 -c walLevel -v 0
system sh/cfg.sh -n dnode2 -c walLevel -v 0
system sh/exec.sh -n dnode2 -s start
sleep 2000

$x = 0
connectTbase2: 
	$x = $x + 1
	sleep 1000
	if $x == 20 then 
	  return -1
	endi
sql connect -x connectTbase2
sleep 3000

sql create dnode $hostname1
system sh/exec.sh -n dnode1 -s start
sleep 3000
print ======================== dnode start

$dbPrefix = db
$tbPrefix = tb
$mtPrefix = mt
$stPrefix = st
$tbNum = 10
$rowNum = 20
$totalNum = 200

print =============== step7
$i = 0
$db = $dbPrefix . $i
$mt = $mtPrefix . $i
$st = $stPrefix . $i

sql create database $db replica 2
sql use $db
sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int)

$i = 0
while $i < $tbNum
  $tb = $tbPrefix . $i
  sql create table $tb using $mt tags( $i )
  
  $x = -1440
  $y = 0
  while $y < $rowNum
    $ms = $x . m 
    sql insert into $tb values (now $ms , $y , $y ) 
    $x = $x + 1
	$y = $y + 1
  endw 
 
  $i = $i + 1
endw 

sleep 100

print =============== step8 c1
$i = 1
$tb = $tbPrefix . $i

sql select count(*) from $mt interval(1d)
print select count(*) from $mt interval(1d) ===> $data00 $data01
if $data01 != 200 then 
  return -1
endi

$st = $stPrefix . c1
sql create table $st as select count(*) from $mt interval(1d)

print =============== step9 
system sh/exec.sh -n dnode1 -s stop

print =============== step10
print sleep 22 seconds
sleep 22000 

print =============== step11
$st = $stPrefix . c1
sql select * from $st
print ===> select * from $st ===> $data00 $data01
if $data01 != 200 then 
  return -1
endi



