system sh/stop_dnodes.sh
system sh/ip.sh -i 1 -s up
system sh/ip.sh -i 2 -s up
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2
system sh/cfg.sh -n dnode1 -c commitLog -v 0
system sh/cfg.sh -n dnode2 -c commitLog -v 0
system sh/cfg.sh -n dnode1 -c numofMpeers -v 3
system sh/cfg.sh -n dnode2 -c numofMpeers -v 3
system sh/exec.sh -n dnode1 -s start

sql connect
sql create dnode 192.168.0.2
system sh/exec.sh -n dnode2 -s start
sleep 3000

$N = 10
$db = d1
$table = table_r2

print =================== step 1 
sql create database $db replica 3
sql use $db
sql create table $table (ts timestamp, speed int) -x error_create
return -1
error_create:
sql drop database $db

print =================== step 2

sql create database $db replica 2 
sql use $db

sql create table $table (ts timestamp, speed int)
sleep 1000

print =================== step 3
$x = 1
$y = $x + $N
$expect = $N
while $x < $y
  $ms = $x . m 
  sql insert into $table values (now + $ms , $x ) 
  $x = $x + 1
endw 

sql select * from $table
print sql select * from $table -> $rows points 
if $rows != $expect then 
  return -1
endi

print =================== step 4
system sh/exec.sh -n dnode2 -s stop
sleep 2000
$y = $x + $N
$expect = $N * 2
while $x < $y
  $ms = $x . m 
  sql insert into $table values (now + $ms , $x ) 
  $x = $x + 1
endw 

sql select * from $table
print sql select * from $table -> $rows points 
if $rows != $expect then 
  return -1
endi

print =================== step 5
system sh/exec.sh -n dnode2 -s start
sleep 2000
$y = $x + $N
$expect = $N * 3
while $x < $y
  $ms = $x . m 
  sql insert into $table values (now + $ms , $x ) 
  $x = $x + 1
endw 

sql select * from $table
print sql select * from $table -> $rows points 
if $rows != $expect then 
  return -1
endi

print =================== step 6
system sh/exec.sh -n dnode1 -s stop
sleep 2000
$y = $x + $N
$expect = $N * 4
while $x < $y
$ms = $x . m
sql insert into $table values (now + $ms , $x )
$x = $x + 1
endw

sql select * from $table
print sql select * from $table -> $rows points
if $rows != $expect then
return -1
endi

print =================== step 7
system sh/exec.sh -n dnode1 -s start
sleep 2000
$y = $x + $N
$expect = $N * 5
while $x < $y
  $ms = $x . m 
  sql insert into $table values (now + $ms , $x ) 
  $x = $x + 1
endw 

sql select * from $table
print sql select * from $table -> $rows points 
if $rows != $expect then 
  return -1
endi

print =================== step 8
system sh/ip.sh -i 1 -s down
system sh/ip.sh -i 2 -s up
sleep 2000
$y = $x + $N
$expect = $N * 6
while $x < $y
  $ms = $x . m 
  sql insert into $table values (now + $ms , $x ) 
  $x = $x + 1
endw 

sql select * from $table
print sql select * from $table -> $rows points 
if $rows != $expect then 
  return -1
endi

print =================== step 9
system sh/ip.sh -i 2 -s up
sleep 2000
$y = $x + $N
$expect = $N * 7
while $x < $y
  $ms = $x . m 
  sql insert into $table values (now + $ms , $x ) 
  $x = $x + 1
endw 

sql select * from $table
print sql select * from $table -> $rows points 
if $rows != $expect then 
  return -1
endi

print =================== step 10
system sh/ip.sh -i 2 -s down
system sh/ip.sh -i 1 -s up
sleep 2000
$y = $x + $N
$expect = $N * 8
while $x < $y
  $ms = $x . m 
  sql insert into $table values (now + $ms , $x ) 
  $x = $x + 1
endw 

sql select * from $table
print sql select * from $table -> $rows points 
if $rows != $expect then 
  return -1
endi

print =================== step 11
system sh/ip.sh -i 2 -s up
sleep 2000
$y = $x + $N
$expect = $N * 9
while $x < $y
  $ms = $x . m 
  sql insert into $table values (now + $ms , $x ) 
  $x = $x + 1
endw 

sql select * from $table
print sql select * from $table -> $rows points 
if $rows != $expect then 
  return -1
endi

print =================== step 12
system sh/exec.sh -n dnode1 -s stop
system sh/exec.sh -n dnode2 -s stop
