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
$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

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 45
sql create mnode on dnode 2

$x = 0
46
step2: 
S
Shengliang Guan 已提交
47 48 49 50 51 52 53 54
	$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] 
55 56 57 58

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

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

S
Shengliang Guan 已提交
81 82 83 84 85 86 87 88 89 90
$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] 
91

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

S
Shengliang Guan 已提交
108
sleep 2000
109

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

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

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

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