TDengine/tests/script/tsim/mnode/basic2.sim

134 lines
2.3 KiB
Text
Raw Normal View History

2022-05-24 07:05:01 +00:00
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode2 -s start
sql connect
print =============== show dnodes
sql show mnodes;
if $rows != 1 then
return -1
endi
if $data00 != 1 then
return -1
endi
2022-06-02 06:35:59 +00:00
if $data02 != leader then
2022-05-24 07:05:01 +00:00
return -1
endi
print =============== create dnodes
sql create dnode $hostname port 7200
2022-05-26 12:21:00 +00:00
$x = 0
step1:
$x = $x + 1
sleep 500
if $x == 20 then
return -1
endi
sql show dnodes -x step1
if $data(1)[4] != ready then
goto step1
2022-05-24 07:05:01 +00:00
endi
2022-05-26 12:21:00 +00:00
if $data(2)[4] != ready then
goto step1
2022-05-24 07:05:01 +00:00
endi
print =============== create mnode 2
sql create mnode on dnode 2
2022-05-26 12:21:00 +00:00
$x = 0
step2:
2022-05-26 12:21:00 +00:00
$x = $x + 1
sleep 1000
if $x == 20 then
return -1
endi
2022-05-24 07:05:01 +00:00
sql show mnodes
print $data(1)[0] $data(1)[1] $data(1)[2]
print $data(2)[0] $data(2)[1] $data(2)[2]
2022-05-24 07:05:01 +00:00
if $rows != 2 then
return -1
endi
if $data(1)[0] != 1 then
return -1
endi
2022-06-02 06:35:59 +00:00
if $data(1)[2] != leader then
return -1
endi
if $data(2)[0] != 2 then
return -1
endi
2022-06-02 06:35:59 +00:00
if $data(2)[2] != follower then
goto step2
endi
print =============== create user
sql create user user1 PASS 'user1'
sql show users
if $rows != 2 then
return -1
endi
2022-05-26 12:21:00 +00:00
sql create database db
sql show databases
if $rows != 3 then
return -1
endi
2022-05-26 08:47:37 +00:00
sleep 5000
2022-05-26 12:21:00 +00:00
print =============== restart
system sh/exec.sh -n dnode1 -s stop
system sh/exec.sh -n dnode2 -s stop
system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode2 -s start
sql connect
sql show mnodes
if $rows != 2 then
return -1
endi
2022-05-26 12:21:00 +00:00
sql show users
if $rows != 2 then
return -1
endi
2022-05-26 12:21:00 +00:00
sql show databases
if $rows != 3 then
return -1
endi
$x = 0
step3:
$x = $x + 1
sleep 500
if $x == 20 then
return -1
endi
sql show dnodes -x step3
2022-05-26 12:21:00 +00:00
if $data(1)[4] != ready then
goto step3
2022-05-26 12:21:00 +00:00
endi
if $data(2)[4] != ready then
goto step3
endi
2022-05-26 12:21:00 +00:00
print =============== insert data
2022-05-26 14:50:46 +00:00
sql create table db.stb (ts timestamp, c1 int, c2 binary(4)) tags(t1 int, t2 float, t3 binary(16)) comment "abd"
sql create table db.ctb using db.stb tags(101, 102, "103")
sql insert into db.ctb values(now, 1, "2")
2022-05-27 07:21:23 +00:00
sql select * from db.ctb
print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
if $rows != 1 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop
system sh/exec.sh -n dnode2 -s stop