system sh/stop_dnodes.sh

system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/deploy.sh -n dnode1 -i 1

print ========= start dnodes
system sh/exec.sh -n dnode1 -s start
sleep 3000
sql connect

print ======== step1 

$tbPrefix = t
$i = 0
while $i < 30
  $db = db . $i
  sql create database $db
  sql use $db

  $tb = $tbPrefix . $i
  sql create table $tb (ts timestamp, i int);

  sql insert into $tb values(now, 1);

  sleep 1000
  sql drop database $db

  print times $i
  $i = $i + 1

endw 

print ======== step2
sleep 1000
sql show databases
if $rows != 0 then 
  return -1
endi 

system sh/stop_dnodes.sh
sleep 3000

system sh/deploy.sh -n dnode1 -i 1
print ========= start dnodes
system sh/exec.sh -n dnode1 -s start
sql connect

print ======== step1

$tbPrefix = t
$i = 0
while $i < 10
  $db = db . $i
  sql create database $db
  sql use $db

  sql create table st (ts timestamp, i int) tags(j int);
  $tb = $tbPrefix . $i
  $tb = $tb . a

    $tb1 = $tb . 1
    sql create table $tb1 using st tags(1)
    sql insert into  $tb1 values(now, 1);

    $tb1 = $tb . 2
    sql create table $tb1 using st tags(1)
    sql insert into  $tb1 values(now, 1);

    $tb1 = $tb . 3
    sql create table $tb1 using st tags(1)
    sql insert into  $tb1 values(now, 1);

    $tb1 = $tb . 5
    sql create table $tb1 using st tags(1)
    sql insert into  $tb1 values(now, 1);

    $tb1 = $tb . 5
    sql create table $tb1 using st tags(1)
    sql insert into  $tb1 values(now, 1);

    $tb1 = $tb . 6
    sql create table $tb1 using st tags(1)
    sql insert into  $tb1 values(now, 1);

    $tb1 = $tb . 7
    sql create table $tb1 using st tags(1)
    sql insert into  $tb1 values(now, 1);

    $tb1 = $tb . 8
    sql create table $tb1 using st tags(1)
    sql insert into  $tb1 values(now, 1);

  sleep 1000
  sql drop database $db

  print times $i
  $i = $i + 1

endw

print ======== step2
sleep 1000
sql show databases
if $rows != 0 then
  return -1
endi

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