homework-jianmu/tests/script/tsim/table/basic1.sim

213 lines
3.7 KiB
Plaintext

system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print =============== create database
sql create database d1
sql show databases
if $rows != 1 then
return -1
endi
print $data00 $data01 $data02
sql use d1
print =============== create super table
sql create table st (ts timestamp, i int) tags (j int)
sql create table if not exists st (ts timestamp, i int) tags (j int)
sql create table if not exists st (ts timestamp, i int) tags (j int)
sql show stables
if $rows != 1 then
return -1
endi
print $data00 $data01 $data02
sql create table st2 (ts timestamp, i float) tags (j int)
sql show stables
if $rows != 2 then
return -1
endi
print $data00 $data01 $data02
print $data10 $data11 $data12
sql drop table st2
sql show stables
if $rows != 1 then
return -1
endi
print $data00 $data01 $data02
print $data10 $data11 $data12
print =============== create child table
sql create table c1 using st tags(1)
sql create table c2 using st tags(2)
sql show tables
if $rows != 2 then
return -1
endi
sql create table c3 using st tags(3) c4 using st tags(4) c5 using st tags(5) c6 using st tags(6) c7 using st tags(7)
sql show tables
if $rows != 7 then
return -1
endi
print $data00 $data01 $data02
print $data10 $data11 $data22
print $data20 $data11 $data22
print =============== insert data
sql insert into c1 values(now+1s, 1)
sql insert into c1 values(now+2s, 2)
sql insert into c1 values(now+3s, 3)
sql insert into c2 values(now+1s, 1)
sql insert into c2 values(now+2s, 2)
sql insert into c2 values(now+3s, 3)
sql insert into c3 values(now+1s, 1)
sql insert into c3 values(now+2s, 2)
sql insert into c3 values(now+3s, 3)
sql insert into c4 values(now+1s, 1)
sql insert into c4 values(now+2s, 2)
sql insert into c4 values(now+3s, 3)
sql insert into c5 values(now+1s, 1)
sql insert into c5 values(now+2s, 2)
sql insert into c5 values(now+3s, 3)
sql insert into c6 values(now+1s, 1)
sql insert into c6 values(now+2s, 2)
sql insert into c6 values(now+3s, 3)
sql insert into c7 values(now+1s, 1)
sql insert into c7 values(now+2s, 2)
sql insert into c7 values(now+3s, 3)
print =============== query data
sql select * from c1
if $rows != 3 then
return -1
endi
print $data00 $data01
print $data10 $data11
print $data20 $data11
if $data01 != 1 then
return -1
endi
if $data11 != 2 then
return -1
endi
if $data21 != 3 then
return -1
endi
sql select * from c2
if $rows != 3 then
return -1
endi
sql select * from c3
if $rows != 3 then
return -1
endi
sql select * from c4
if $rows != 3 then
return -1
endi
sql select * from c5
if $rows != 3 then
return -1
endi
sql select * from c6
if $rows != 3 then
return -1
endi
sql select * from c7
if $rows != 3 then
return -1
endi
print =============== query data from st
sql select * from st
if $rows != 21 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start
sleep 2000
print =============== query data
sql select * from c1
if $rows != 3 then
print $rows
return -1
endi
print $data00 $data01
print $data10 $data11
print $data20 $data11
if $data01 != 1 then
return -1
endi
if $data11 != 2 then
return -1
endi
if $data21 != 3 then
return -1
endi
sql select * from c2
if $rows != 3 then
return -1
endi
sql select * from c3
if $rows != 3 then
return -1
endi
sql select * from c4
if $rows != 3 then
return -1
endi
sql select * from c5
if $rows != 3 then
return -1
endi
sql select * from c6
if $rows != 3 then
return -1
endi
sql select * from c7
if $rows != 3 then
return -1
endi
print =============== query data from st
sql select * from st
if $rows != 21 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT