basic1.sim 2.7 KB
Newer Older
1 2 3 4 5 6 7
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

X
Xiaoyu Wang 已提交
8
print =============== select * from information_schema.ins_dnodes
X
Xiaoyu Wang 已提交
9
sql select * from information_schema.ins_mnodes;
10 11 12 13 14 15 16 17
if $rows != 1 then 
  return -1
endi

if $data00 != 1 then 
  return -1
endi

18
if $data02 != leader then 
19 20 21 22 23
  return -1
endi

print =============== create dnodes
sql create dnode $hostname port 7200
S
Shengliang Guan 已提交
24 25 26 27 28 29 30
$x = 0
step1: 
	$x = $x + 1
	sleep 500
	if $x == 20 then
		return -1
	endi
X
Xiaoyu Wang 已提交
31
sql select * from information_schema.ins_dnodes -x step1
S
Shengliang Guan 已提交
32 33 34 35 36 37 38 39 40
if $data(1)[4] != ready then
  goto step1
endi
if $data(2)[4] != ready then
  goto step1
endi

sql_error create mnode on dnode 1
sql_error drop mnode on dnode 1
41 42

print =============== create mnode 2
S
Shengliang Guan 已提交
43 44
sql create mnode on dnode 2

45
print =============== create mnode 2 finished
S
Shengliang Guan 已提交
46
$x = 0
47
step2: 
S
Shengliang Guan 已提交
48 49 50 51 52
	$x = $x + 1
	sleep 1000
	if $x == 20 then
		return -1
	endi
X
Xiaoyu Wang 已提交
53
sql select * from information_schema.ins_mnodes
S
Shengliang Guan 已提交
54 55
print $data(1)[0] $data(1)[1] $data(1)[2] 
print $data(2)[0] $data(2)[1] $data(2)[2] 
56 57 58 59

if $rows != 2 then 
  return -1
endi
S
Shengliang Guan 已提交
60
if $data(1)[0] != 1 then 
61 62
  return -1
endi
63
if $data(1)[2] != leader then 
64 65
  return -1
endi
S
Shengliang Guan 已提交
66
if $data(2)[0] != 2 then 
67 68
  return -1
endi
69
if $data(2)[2] != follower then 
70
  goto step2
71 72
endi

73
print ============ drop mnode 2
S
Shengliang Guan 已提交
74
sql drop mnode on dnode 2
75 76

print ============ drop mnode 2 finished
X
Xiaoyu Wang 已提交
77
sql select * from information_schema.ins_mnodes
S
Shengliang Guan 已提交
78
if $rows != 1 then 
79 80
  return -1
endi
S
Shengliang Guan 已提交
81
sql_error drop mnode on dnode 2
82

S
Shengliang Guan 已提交
83 84 85 86 87 88 89
$x = 0
step2: 
	$x = $x + 1
	sleep 1000
	if $x == 20 then
		return -1
	endi
X
Xiaoyu Wang 已提交
90
sql select * from information_schema.ins_mnodes
S
Shengliang Guan 已提交
91 92
print $data(1)[0] $data(1)[1] $data(1)[2] 
print $data(2)[0] $data(2)[1] $data(2)[2] 
93

S
Shengliang Guan 已提交
94
if $rows != 1 then 
95 96
  return -1
endi
S
Shengliang Guan 已提交
97
if $data(1)[0] != 1 then 
98 99
  return -1
endi
100
if $data(1)[2] != leader then 
101 102
  return -1
endi
S
Shengliang Guan 已提交
103
if $data(2)[0] != null then 
S
Shengliang Guan 已提交
104 105
  goto step2
endi
S
Shengliang Guan 已提交
106
if $data(2)[2] != null then 
S
Shengliang Guan 已提交
107 108
  goto step2
endi
109

S
Shengliang Guan 已提交
110
sleep 2000
111

S
Shengliang Guan 已提交
112
print =============== create mnodes
113
sql create mnode on dnode 2
114 115

print =============== create mnode 2 finished
X
Xiaoyu Wang 已提交
116
sql select * from information_schema.ins_mnodes
117 118 119 120
if $rows != 2 then 
  return -1
endi

S
Shengliang Guan 已提交
121 122 123 124 125 126 127
$x = 0
step3: 
	$x = $x + 1
	sleep 1000
	if $x == 20 then
		return -1
	endi
X
Xiaoyu Wang 已提交
128
sql select * from information_schema.ins_mnodes
S
Shengliang Guan 已提交
129 130
print $data(1)[0] $data(1)[1] $data(1)[2] 
print $data(2)[0] $data(2)[1] $data(2)[2] 
131 132 133 134

if $rows != 2 then 
  return -1
endi
S
Shengliang Guan 已提交
135 136 137
if $data(1)[0] != 1 then 
  return -1
endi
138
if $data(1)[2] != leader then 
S
Shengliang Guan 已提交
139 140 141
  return -1
endi
if $data(2)[0] != 2 then 
142 143
  return -1
endi
144
if $data(2)[2] != follower then 
S
Shengliang Guan 已提交
145 146
  goto step3
endi
147 148 149

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