basic3.sim 2.9 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
42
sql_error create mnode on dnode 4
S
Shengliang Guan 已提交
43 44 45 46 47

$x = 0
step2: 
	$x = $x + 1
	sleep 1000
48
	if $x == 10 then
S
Shengliang Guan 已提交
49 50
		return -1
	endi
S
Shengliang Guan 已提交
51
sql show mnodes -x step2
52
if $data(1)[2] != leader then
S
Shengliang Guan 已提交
53 54
  goto step2
endi
55
if $data(2)[2] != follower then
S
Shengliang Guan 已提交
56 57
  goto step2
endi
58
if $data(3)[2] != follower then
S
Shengliang Guan 已提交
59 60 61 62 63 64 65 66 67 68
  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 已提交
69
# wait mnode2 mnode3 recv data finish
S
Shengliang Guan 已提交
70 71 72 73 74
sleep 10000

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

S
Shengliang Guan 已提交
75 76 77 78
$x = 0
step4: 
	$x = $x + 1
	sleep 1000
79
	if $x == 10 then
S
Shengliang Guan 已提交
80 81 82 83 84 85
		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 已提交
86

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

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

S
Shengliang Guan 已提交
101 102 103 104 105 106 107 108
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
109
	if $x == 10 then
S
Shengliang Guan 已提交
110 111 112 113 114 115 116
		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] 

117
if $data(2)[2] != offline then
118 119 120
  goto step5
endi

S
Shengliang Guan 已提交
121 122 123 124 125
sql show users
if $rows != 2 then 
  return -1
endi

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

S
Shengliang Guan 已提交
130 131 132 133
$x = 0
step6: 
	$x = $x + 1
	sleep 1000
134
	if $x == 10 then
S
Shengliang Guan 已提交
135 136 137 138 139 140 141 142 143 144 145
		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 已提交
146 147

system sh/exec.sh -n dnode1 -s stop
S
Shengliang Guan 已提交
148
system sh/exec.sh -n dnode2 -s stop
149 150
system sh/exec.sh -n dnode3 -s stop
system sh/exec.sh -n dnode4 -s stop