basic3.sim 3.0 KB
Newer Older
S
Shengliang Guan 已提交
1 2 3 4
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
5
system sh/deploy.sh -n dnode4 -i 4
6 7 8 9
system sh/cfg.sh -n dnode1 -c transPullupInterval -v 1
system sh/cfg.sh -n dnode2 -c transPullupInterval -v 1
system sh/cfg.sh -n dnode3 -c transPullupInterval -v 1
system sh/cfg.sh -n dnode4 -c transPullupInterval -v 1
S
Shengliang Guan 已提交
10 11 12
system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start
13
system sh/exec.sh -n dnode4 -s start
S
Shengliang Guan 已提交
14 15 16 17 18
sql connect

print =============== step1: create dnodes
sql create dnode $hostname port 7200
sql create dnode $hostname port 7300
19
sql create dnode $hostname port 7400
S
Shengliang Guan 已提交
20 21 22 23 24

$x = 0
step1: 
	$x = $x + 1
	sleep 1000
25
	if $x == 10 then
S
Shengliang Guan 已提交
26 27
		return -1
	endi
S
Shengliang Guan 已提交
28
sql show dnodes -x step1
S
Shengliang Guan 已提交
29 30 31 32 33 34 35 36 37 38 39 40 41
if $data(1)[4] != ready then
  goto step1
endi
if $data(2)[4] != ready then
  goto step1
endi
if $data(3)[4] != ready then
  goto step1
endi

print =============== step2: create mnode 2
sql create mnode on dnode 2
sql create mnode on dnode 3
S
Shengliang Guan 已提交
42
system sh/exec.sh -n dnode1 -s stop -x SIGKILL
43
sql_error create mnode on dnode 4
S
Shengliang Guan 已提交
44

S
Shengliang Guan 已提交
45 46
return

S
Shengliang Guan 已提交
47 48 49 50
$x = 0
step2: 
	$x = $x + 1
	sleep 1000
51
	if $x == 10 then
S
Shengliang Guan 已提交
52 53
		return -1
	endi
S
Shengliang Guan 已提交
54
sql show mnodes -x step2
55
if $data(1)[2] != leader then
S
Shengliang Guan 已提交
56 57
  goto step2
endi
58
if $data(2)[2] != follower then
S
Shengliang Guan 已提交
59 60
  goto step2
endi
61
if $data(3)[2] != follower then
S
Shengliang Guan 已提交
62 63 64 65 66 67 68 69 70 71
  goto step2
endi

print =============== step3: create user
sql create user user1 PASS 'user1'
sql show users
if $rows != 2 then 
  return -1
endi

S
Shengliang Guan 已提交
72
# wait mnode2 mnode3 recv data finish
S
Shengliang Guan 已提交
73 74 75 76 77
sleep 10000

print =============== step4: stop dnode1
system sh/exec.sh -n dnode1 -s stop

S
Shengliang Guan 已提交
78 79 80 81
$x = 0
step4: 
	$x = $x + 1
	sleep 1000
82
	if $x == 10 then
S
Shengliang Guan 已提交
83 84 85 86 87 88
		return -1
	endi
sql show mnodes -x step4
print $data(1)[0] $data(1)[1] $data(1)[2] 
print $data(2)[0] $data(2)[1] $data(2)[2] 
print $data(3)[0] $data(3)[1] $data(3)[2] 
S
Shengliang Guan 已提交
89

S
Shengliang Guan 已提交
90
sql show users
S
Shengliang Guan 已提交
91 92 93
if $rows != 2 then 
  return -1
endi
S
Shengliang Guan 已提交
94 95 96 97

sleep 1000
sql show dnodes
if $data(2)[4] != ready then
S
Shengliang Guan 已提交
98 99
  return -1
endi
S
Shengliang Guan 已提交
100
if $data(3)[4] != ready then
S
Shengliang Guan 已提交
101 102 103
  return -1
endi

S
Shengliang Guan 已提交
104 105 106 107 108 109 110 111
print =============== step5: stop dnode1
system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode2 -s stop

$x = 0
step5: 
	$x = $x + 1
	sleep 1000
112
	if $x == 10 then
S
Shengliang Guan 已提交
113 114 115 116 117 118 119
		return -1
	endi
sql show mnodes -x step5
print $data(1)[0] $data(1)[1] $data(1)[2] 
print $data(2)[0] $data(2)[1] $data(2)[2] 
print $data(3)[0] $data(3)[1] $data(3)[2] 

120
if $data(2)[2] != offline then
121 122 123
  goto step5
endi

S
Shengliang Guan 已提交
124 125 126 127 128
sql show users
if $rows != 2 then 
  return -1
endi

S
Shengliang Guan 已提交
129 130 131
print =============== step6: stop dnode1
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s stop
S
Shengliang Guan 已提交
132

S
Shengliang Guan 已提交
133 134 135 136
$x = 0
step6: 
	$x = $x + 1
	sleep 1000
137
	if $x == 10 then
S
Shengliang Guan 已提交
138 139 140 141 142 143 144 145 146 147 148
		return -1
	endi
sql show mnodes -x step6
print $data(1)[0] $data(1)[1] $data(1)[2] 
print $data(2)[0] $data(2)[1] $data(2)[2] 
print $data(3)[0] $data(3)[1] $data(3)[2] 

sql show users
if $rows != 2 then 
  return -1
endi
S
Shengliang Guan 已提交
149 150

system sh/exec.sh -n dnode1 -s stop
S
Shengliang Guan 已提交
151
system sh/exec.sh -n dnode2 -s stop
152 153
system sh/exec.sh -n dnode3 -s stop
system sh/exec.sh -n dnode4 -s stop