basic1.sim 2.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
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

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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
$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
endi
if $data(2)[4] != ready then
  goto step1
endi

print =============== create drop mnode 1
sql_error create mnode on dnode 1
sql_error drop mnode on dnode 1
sql create mnode on dnode 2

$x = 0
step1: 
	$x = $x + 1
	sleep 1000
	if $x == 20 then
		return -1
	endi
sql show mnodes
print $data(1)[0] $data(1)[1] $data(1)[2] 
print $data(2)[0] $data(2)[1] $data(2)[2] 
54 55 56 57

if $rows != 2 then 
  return -1
endi
S
Shengliang Guan 已提交
58
if $data(1)[0] != 1 then 
59 60
  return -1
endi
S
Shengliang Guan 已提交
61
if $data(1)[2] != LEADER then 
62 63
  return -1
endi
S
Shengliang Guan 已提交
64
if $data(2)[0] != 2 then 
65 66
  return -1
endi
S
Shengliang Guan 已提交
67 68
if $data(2)[2] != FOLLOWER then 
  goto step1
69 70
endi

S
Shengliang Guan 已提交
71 72 73 74 75
sleep 2000
print ============ drop mnodes
sql drop mnode on dnode 2
sql show mnodes
if $rows != 1 then 
76 77
  return -1
endi
S
Shengliang Guan 已提交
78
sql_error drop mnode on dnode 2
79

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

S
Shengliang Guan 已提交
91
if $rows != 2 then 
92 93
  return -1
endi
S
Shengliang Guan 已提交
94
if $data(1)[0] != 1 then 
95 96
  return -1
endi
S
Shengliang Guan 已提交
97
if $data(1)[2] != LEADER then 
98 99
  return -1
endi
S
Shengliang Guan 已提交
100 101 102 103 104 105
if $data(2)[0] != NULL then 
  goto step2
endi
if $data(2)[2] != NULL then 
  goto step2
endi
106

S
Shengliang Guan 已提交
107
sleep 2000
108

S
Shengliang Guan 已提交
109
print =============== create drop mnodes
110 111 112 113 114 115
sql create mnode on dnode 2
sql show mnodes
if $rows != 2 then 
  return -1
endi

S
Shengliang Guan 已提交
116 117 118 119 120 121 122
$x = 0
step3: 
	$x = $x + 1
	sleep 1000
	if $x == 20 then
		return -1
	endi
123
sql show mnodes
S
Shengliang Guan 已提交
124 125
print $data(1)[0] $data(1)[1] $data(1)[2] 
print $data(2)[0] $data(2)[1] $data(2)[2] 
126 127 128 129

if $rows != 2 then 
  return -1
endi
S
Shengliang Guan 已提交
130 131 132 133 134 135 136
if $data(1)[0] != 1 then 
  return -1
endi
if $data(1)[2] != LEADER then 
  return -1
endi
if $data(2)[0] != 2 then 
137 138
  return -1
endi
S
Shengliang Guan 已提交
139 140 141
if $data(2)[2] != FOLLOWER then 
  goto step3
endi
142 143 144

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