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 1
system sh/cfg.sh -n dnode2 -c walLevel            -v 1
system sh/cfg.sh -n dnode1 -c httpMaxThreads      -v 2
system sh/cfg.sh -n dnode2 -c httpMaxThreads      -v 2
system sh/cfg.sh -n dnode1 -c monitor             -v 1
system sh/cfg.sh -n dnode1 -c monitor             -v 2
system sh/cfg.sh -n dnode2 -c http                -v 1
system sh/cfg.sh -n dnode1 -c enableHttp          -v 1
system sh/cfg.sh -n dnode2 -c monitor             -v 1
system sh/cfg.sh -n dnode1 -c monitorInterval     -v 1
system sh/cfg.sh -n dnode2 -c monitorInterval     -v 1

system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect

sql create database testdb
sql use testdb
sql create table meter1 (ts timestamp, val int)

$x = 0
$v = -100
while $x < 30
    $v = $v + 1
	$ms = $v . m 
	sql insert into meter1 values (now  $ms , $x ) 
	$x = $x + 1
endw 

sleep 2000
system sh/exec.sh -n dnode2 -s start
sql create dnode $hostname2


sleep 10000

sql show log.tables;
if $rows > 6 then
  return -1
endi

sql select * from log.dn1
print ===>rows $rows
print $data00 $data01 $data02
print $data10 $data11 $data12
print $data20 $data21 $data22
if $rows < 10 then
  return -1
endi

#sql create table sys.st as select avg(taosd), avg(system) from sys.cpu interval(30s)

sql show log.vgroups
if $data05 != master then
  return -1
endi
if $data15 != master then
  return -1
endi
