root / qa / qa_cluster.py @ 13d2e231
History | View | Annotate | Download (16.4 kB)
1 | c68d1f43 | Michael Hanselmann | #
|
---|---|---|---|
2 | c68d1f43 | Michael Hanselmann | #
|
3 | c68d1f43 | Michael Hanselmann | |
4 | 69df9d2b | Iustin Pop | # Copyright (C) 2007, 2010, 2011 Google Inc.
|
5 | cec9845c | Michael Hanselmann | #
|
6 | cec9845c | Michael Hanselmann | # This program is free software; you can redistribute it and/or modify
|
7 | cec9845c | Michael Hanselmann | # it under the terms of the GNU General Public License as published by
|
8 | cec9845c | Michael Hanselmann | # the Free Software Foundation; either version 2 of the License, or
|
9 | cec9845c | Michael Hanselmann | # (at your option) any later version.
|
10 | cec9845c | Michael Hanselmann | #
|
11 | cec9845c | Michael Hanselmann | # This program is distributed in the hope that it will be useful, but
|
12 | cec9845c | Michael Hanselmann | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | cec9845c | Michael Hanselmann | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | cec9845c | Michael Hanselmann | # General Public License for more details.
|
15 | cec9845c | Michael Hanselmann | #
|
16 | cec9845c | Michael Hanselmann | # You should have received a copy of the GNU General Public License
|
17 | cec9845c | Michael Hanselmann | # along with this program; if not, write to the Free Software
|
18 | cec9845c | Michael Hanselmann | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 | cec9845c | Michael Hanselmann | # 02110-1301, USA.
|
20 | cec9845c | Michael Hanselmann | |
21 | cec9845c | Michael Hanselmann | |
22 | cec9845c | Michael Hanselmann | """Cluster related QA tests.
|
23 | cec9845c | Michael Hanselmann |
|
24 | cec9845c | Michael Hanselmann | """
|
25 | cec9845c | Michael Hanselmann | |
26 | cec9845c | Michael Hanselmann | import tempfile |
27 | 49ceab21 | Michael Hanselmann | import os.path |
28 | cec9845c | Michael Hanselmann | |
29 | 6d4a1656 | Michael Hanselmann | from ganeti import constants |
30 | 66d1f035 | René Nussbaumer | from ganeti import compat |
31 | cec9845c | Michael Hanselmann | from ganeti import utils |
32 | cec9845c | Michael Hanselmann | |
33 | cec9845c | Michael Hanselmann | import qa_config |
34 | cec9845c | Michael Hanselmann | import qa_utils |
35 | cec9845c | Michael Hanselmann | import qa_error |
36 | cec9845c | Michael Hanselmann | |
37 | 66d1f035 | René Nussbaumer | from qa_utils import AssertEqual, AssertCommand, GetCommandOutput |
38 | cec9845c | Michael Hanselmann | |
39 | cec9845c | Michael Hanselmann | |
40 | c2a0947d | Iustin Pop | #: cluster verify command
|
41 | c2a0947d | Iustin Pop | _CLUSTER_VERIFY = ["gnt-cluster", "verify"] |
42 | c2a0947d | Iustin Pop | |
43 | 21bf2e2e | Andrea Spadaccini | |
44 | 830da270 | Michael Hanselmann | def _RemoveFileFromAllNodes(filename): |
45 | 830da270 | Michael Hanselmann | """Removes a file from all nodes.
|
46 | 830da270 | Michael Hanselmann |
|
47 | 830da270 | Michael Hanselmann | """
|
48 | 2f4b4f78 | Iustin Pop | for node in qa_config.get("nodes"): |
49 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", filename], node=node) |
50 | 830da270 | Michael Hanselmann | |
51 | 830da270 | Michael Hanselmann | |
52 | 830da270 | Michael Hanselmann | def _CheckFileOnAllNodes(filename, content): |
53 | 830da270 | Michael Hanselmann | """Verifies the content of the given file on all nodes.
|
54 | 830da270 | Michael Hanselmann |
|
55 | 830da270 | Michael Hanselmann | """
|
56 | 830da270 | Michael Hanselmann | cmd = utils.ShellQuoteArgs(["cat", filename])
|
57 | 2f4b4f78 | Iustin Pop | for node in qa_config.get("nodes"): |
58 | 2f4b4f78 | Iustin Pop | AssertEqual(qa_utils.GetCommandOutput(node["primary"], cmd), content)
|
59 | 830da270 | Michael Hanselmann | |
60 | 830da270 | Michael Hanselmann | |
61 | 725ec2f1 | René Nussbaumer | def TestClusterInit(rapi_user, rapi_secret): |
62 | cec9845c | Michael Hanselmann | """gnt-cluster init"""
|
63 | 13d2e231 | Andrea Spadaccini | # data for testing failures due to bad keys/values for disk parameters
|
64 | 13d2e231 | Andrea Spadaccini | fail_params = ("-D nonexistent:resync-rate=1",
|
65 | 13d2e231 | Andrea Spadaccini | "-D drbd:nonexistent=1",
|
66 | 13d2e231 | Andrea Spadaccini | "-D drbd:resync-rate=invalid")
|
67 | 13d2e231 | Andrea Spadaccini | |
68 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
69 | cec9845c | Michael Hanselmann | |
70 | 49ceab21 | Michael Hanselmann | rapi_dir = os.path.dirname(constants.RAPI_USERS_FILE) |
71 | 49ceab21 | Michael Hanselmann | |
72 | 725ec2f1 | René Nussbaumer | # First create the RAPI credentials
|
73 | a62d1901 | Michael Hanselmann | fh = tempfile.NamedTemporaryFile() |
74 | a62d1901 | Michael Hanselmann | try:
|
75 | a62d1901 | Michael Hanselmann | fh.write("%s %s write\n" % (rapi_user, rapi_secret))
|
76 | a62d1901 | Michael Hanselmann | fh.flush() |
77 | a62d1901 | Michael Hanselmann | |
78 | a62d1901 | Michael Hanselmann | tmpru = qa_utils.UploadFile(master["primary"], fh.name)
|
79 | a62d1901 | Michael Hanselmann | try:
|
80 | 49ceab21 | Michael Hanselmann | AssertCommand(["mkdir", "-p", rapi_dir]) |
81 | 2f4b4f78 | Iustin Pop | AssertCommand(["mv", tmpru, constants.RAPI_USERS_FILE])
|
82 | a62d1901 | Michael Hanselmann | finally:
|
83 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", tmpru]) |
84 | a62d1901 | Michael Hanselmann | finally:
|
85 | a62d1901 | Michael Hanselmann | fh.close() |
86 | a62d1901 | Michael Hanselmann | |
87 | a62d1901 | Michael Hanselmann | # Initialize cluster
|
88 | d0c8c01d | Iustin Pop | cmd = ["gnt-cluster", "init"] |
89 | cec9845c | Michael Hanselmann | |
90 | 9486f6ae | Manuel Franceschini | cmd.append("--primary-ip-version=%d" %
|
91 | 9486f6ae | Manuel Franceschini | qa_config.get("primary_ip_version", 4)) |
92 | 9486f6ae | Manuel Franceschini | |
93 | d0c8c01d | Iustin Pop | if master.get("secondary", None): |
94 | d0c8c01d | Iustin Pop | cmd.append("--secondary-ip=%s" % master["secondary"]) |
95 | cec9845c | Michael Hanselmann | |
96 | d0c8c01d | Iustin Pop | bridge = qa_config.get("bridge", None) |
97 | cec9845c | Michael Hanselmann | if bridge:
|
98 | d0c8c01d | Iustin Pop | cmd.append("--bridge=%s" % bridge)
|
99 | d0c8c01d | Iustin Pop | cmd.append("--master-netdev=%s" % bridge)
|
100 | cec9845c | Michael Hanselmann | |
101 | d0c8c01d | Iustin Pop | htype = qa_config.get("enabled-hypervisors", None) |
102 | b32f9859 | Iustin Pop | if htype:
|
103 | d0c8c01d | Iustin Pop | cmd.append("--enabled-hypervisors=%s" % htype)
|
104 | b32f9859 | Iustin Pop | |
105 | 13d2e231 | Andrea Spadaccini | # test gnt-cluster init failures due to bad keys/values in disk parameters
|
106 | 13d2e231 | Andrea Spadaccini | for param in fail_params: |
107 | 13d2e231 | Andrea Spadaccini | cmd.extend([param, qa_config.get("name")])
|
108 | 13d2e231 | Andrea Spadaccini | AssertCommand(cmd, fail=True)
|
109 | 13d2e231 | Andrea Spadaccini | cmd.pop() |
110 | 13d2e231 | Andrea Spadaccini | cmd.pop() |
111 | cec9845c | Michael Hanselmann | |
112 | 13d2e231 | Andrea Spadaccini | cmd.append(qa_config.get("name"))
|
113 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd) |
114 | cec9845c | Michael Hanselmann | |
115 | 5abecc1c | Iustin Pop | cmd = ["gnt-cluster", "modify"] |
116 | 13d2e231 | Andrea Spadaccini | # test gnt-cluster modify failures due to bad keys/values in disk parameters
|
117 | 13d2e231 | Andrea Spadaccini | for param in fail_params: |
118 | 13d2e231 | Andrea Spadaccini | cmd.append(param) |
119 | 13d2e231 | Andrea Spadaccini | AssertCommand(cmd, fail=True)
|
120 | 13d2e231 | Andrea Spadaccini | cmd.pop() |
121 | 13d2e231 | Andrea Spadaccini | |
122 | 5abecc1c | Iustin Pop | # hypervisor parameter modifications
|
123 | 5abecc1c | Iustin Pop | hvp = qa_config.get("hypervisor-parameters", {})
|
124 | 5abecc1c | Iustin Pop | for k, v in hvp.items(): |
125 | 5abecc1c | Iustin Pop | cmd.extend(["-H", "%s:%s" % (k, v)]) |
126 | 5abecc1c | Iustin Pop | # backend parameter modifications
|
127 | 5abecc1c | Iustin Pop | bep = qa_config.get("backend-parameters", "") |
128 | 5abecc1c | Iustin Pop | if bep:
|
129 | 5abecc1c | Iustin Pop | cmd.extend(["-B", bep])
|
130 | 5abecc1c | Iustin Pop | |
131 | 5abecc1c | Iustin Pop | if len(cmd) > 2: |
132 | 5abecc1c | Iustin Pop | AssertCommand(cmd) |
133 | 5abecc1c | Iustin Pop | |
134 | 5abecc1c | Iustin Pop | # OS parameters
|
135 | 5abecc1c | Iustin Pop | osp = qa_config.get("os-parameters", {})
|
136 | 5abecc1c | Iustin Pop | for k, v in osp.items(): |
137 | 5abecc1c | Iustin Pop | AssertCommand(["gnt-os", "modify", "-O", v, k]) |
138 | 5abecc1c | Iustin Pop | |
139 | 5abecc1c | Iustin Pop | # OS hypervisor parameters
|
140 | 5abecc1c | Iustin Pop | os_hvp = qa_config.get("os-hvp", {})
|
141 | 5abecc1c | Iustin Pop | for os_name in os_hvp: |
142 | 5abecc1c | Iustin Pop | for hv, hvp in os_hvp[os_name].items(): |
143 | 5abecc1c | Iustin Pop | AssertCommand(["gnt-os", "modify", "-H", "%s:%s" % (hv, hvp), os_name]) |
144 | 5abecc1c | Iustin Pop | |
145 | cec9845c | Michael Hanselmann | |
146 | caea3b32 | Iustin Pop | def TestClusterRename(): |
147 | caea3b32 | Iustin Pop | """gnt-cluster rename"""
|
148 | d0c8c01d | Iustin Pop | cmd = ["gnt-cluster", "rename", "-f"] |
149 | caea3b32 | Iustin Pop | |
150 | d0c8c01d | Iustin Pop | original_name = qa_config.get("name")
|
151 | d0c8c01d | Iustin Pop | rename_target = qa_config.get("rename", None) |
152 | caea3b32 | Iustin Pop | if rename_target is None: |
153 | caea3b32 | Iustin Pop | print qa_utils.FormatError('"rename" entry is missing') |
154 | caea3b32 | Iustin Pop | return
|
155 | caea3b32 | Iustin Pop | |
156 | 2f4b4f78 | Iustin Pop | for data in [ |
157 | 2f4b4f78 | Iustin Pop | cmd + [rename_target], |
158 | c2a0947d | Iustin Pop | _CLUSTER_VERIFY, |
159 | 2f4b4f78 | Iustin Pop | cmd + [original_name], |
160 | c2a0947d | Iustin Pop | _CLUSTER_VERIFY, |
161 | 2f4b4f78 | Iustin Pop | ]: |
162 | 2f4b4f78 | Iustin Pop | AssertCommand(data) |
163 | caea3b32 | Iustin Pop | |
164 | caea3b32 | Iustin Pop | |
165 | 69df9d2b | Iustin Pop | def TestClusterOob(): |
166 | 69df9d2b | Iustin Pop | """out-of-band framework"""
|
167 | f55312bd | René Nussbaumer | oob_path_exists = "/tmp/ganeti-qa-oob-does-exist-%s" % utils.NewUUID()
|
168 | f55312bd | René Nussbaumer | |
169 | c2a0947d | Iustin Pop | AssertCommand(_CLUSTER_VERIFY) |
170 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "modify", "--node-parameters", |
171 | f55312bd | René Nussbaumer | "oob_program=/tmp/ganeti-qa-oob-does-not-exist-%s" %
|
172 | f55312bd | René Nussbaumer | utils.NewUUID()]) |
173 | f55312bd | René Nussbaumer | |
174 | c2a0947d | Iustin Pop | AssertCommand(_CLUSTER_VERIFY, fail=True)
|
175 | f55312bd | René Nussbaumer | |
176 | 69df9d2b | Iustin Pop | AssertCommand(["touch", oob_path_exists])
|
177 | 69df9d2b | Iustin Pop | AssertCommand(["chmod", "0400", oob_path_exists]) |
178 | 69df9d2b | Iustin Pop | AssertCommand(["gnt-cluster", "copyfile", oob_path_exists]) |
179 | f55312bd | René Nussbaumer | |
180 | f55312bd | René Nussbaumer | try:
|
181 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "modify", "--node-parameters", |
182 | f55312bd | René Nussbaumer | "oob_program=%s" % oob_path_exists])
|
183 | f55312bd | René Nussbaumer | |
184 | c2a0947d | Iustin Pop | AssertCommand(_CLUSTER_VERIFY, fail=True)
|
185 | f55312bd | René Nussbaumer | |
186 | 69df9d2b | Iustin Pop | AssertCommand(["chmod", "0500", oob_path_exists]) |
187 | 69df9d2b | Iustin Pop | AssertCommand(["gnt-cluster", "copyfile", oob_path_exists]) |
188 | f55312bd | René Nussbaumer | |
189 | c2a0947d | Iustin Pop | AssertCommand(_CLUSTER_VERIFY) |
190 | f55312bd | René Nussbaumer | finally:
|
191 | 69df9d2b | Iustin Pop | AssertCommand(["gnt-cluster", "command", "rm", oob_path_exists]) |
192 | f55312bd | René Nussbaumer | |
193 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "modify", "--node-parameters", |
194 | f55312bd | René Nussbaumer | "oob_program="])
|
195 | 69df9d2b | Iustin Pop | |
196 | 69df9d2b | Iustin Pop | |
197 | 66d1f035 | René Nussbaumer | def TestClusterEpo(): |
198 | 66d1f035 | René Nussbaumer | """gnt-cluster epo"""
|
199 | 66d1f035 | René Nussbaumer | master = qa_config.GetMasterNode() |
200 | 66d1f035 | René Nussbaumer | |
201 | 66d1f035 | René Nussbaumer | # Assert that OOB is unavailable for all nodes
|
202 | 66d1f035 | René Nussbaumer | result_output = GetCommandOutput(master["primary"],
|
203 | 66d1f035 | René Nussbaumer | "gnt-node list --verbose --no-header -o"
|
204 | 66d1f035 | René Nussbaumer | " powered")
|
205 | 66d1f035 | René Nussbaumer | AssertEqual(compat.all(powered == "(unavail)"
|
206 | 66d1f035 | René Nussbaumer | for powered in result_output.splitlines()), True) |
207 | 66d1f035 | René Nussbaumer | |
208 | 66d1f035 | René Nussbaumer | # Conflicting
|
209 | 66d1f035 | René Nussbaumer | AssertCommand(["gnt-cluster", "epo", "--groups", "--all"], fail=True) |
210 | 66d1f035 | René Nussbaumer | # --all doesn't expect arguments
|
211 | 66d1f035 | René Nussbaumer | AssertCommand(["gnt-cluster", "epo", "--all", "some_arg"], fail=True) |
212 | 66d1f035 | René Nussbaumer | |
213 | 66d1f035 | René Nussbaumer | # Unless --all is given master is not allowed to be in the list
|
214 | 66d1f035 | René Nussbaumer | AssertCommand(["gnt-cluster", "epo", "-f", master["primary"]], fail=True) |
215 | 66d1f035 | René Nussbaumer | |
216 | 66d1f035 | René Nussbaumer | # This shouldn't fail
|
217 | 66d1f035 | René Nussbaumer | AssertCommand(["gnt-cluster", "epo", "-f", "--all"]) |
218 | 66d1f035 | René Nussbaumer | |
219 | 66d1f035 | René Nussbaumer | # All instances should have been stopped now
|
220 | 66d1f035 | René Nussbaumer | result_output = GetCommandOutput(master["primary"],
|
221 | 66d1f035 | René Nussbaumer | "gnt-instance list --no-header -o status")
|
222 | 66d1f035 | René Nussbaumer | AssertEqual(compat.all(status == "ADMIN_down"
|
223 | 66d1f035 | René Nussbaumer | for status in result_output.splitlines()), True) |
224 | 66d1f035 | René Nussbaumer | |
225 | 66d1f035 | René Nussbaumer | # Now start everything again
|
226 | 66d1f035 | René Nussbaumer | AssertCommand(["gnt-cluster", "epo", "--on", "-f", "--all"]) |
227 | 66d1f035 | René Nussbaumer | |
228 | 66d1f035 | René Nussbaumer | # All instances should have been started now
|
229 | 66d1f035 | René Nussbaumer | result_output = GetCommandOutput(master["primary"],
|
230 | 66d1f035 | René Nussbaumer | "gnt-instance list --no-header -o status")
|
231 | 66d1f035 | René Nussbaumer | AssertEqual(compat.all(status == "running"
|
232 | 66d1f035 | René Nussbaumer | for status in result_output.splitlines()), True) |
233 | 66d1f035 | René Nussbaumer | |
234 | 66d1f035 | René Nussbaumer | |
235 | 69df9d2b | Iustin Pop | def TestClusterVerify(): |
236 | 69df9d2b | Iustin Pop | """gnt-cluster verify"""
|
237 | c2a0947d | Iustin Pop | AssertCommand(_CLUSTER_VERIFY) |
238 | c6953b6e | Iustin Pop | AssertCommand(["gnt-cluster", "verify-disks"]) |
239 | cec9845c | Michael Hanselmann | |
240 | 1377433b | Michael Hanselmann | |
241 | 1377433b | Michael Hanselmann | def TestJobqueue(): |
242 | 1377433b | Michael Hanselmann | """gnt-debug test-jobqueue"""
|
243 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-debug", "test-jobqueue"]) |
244 | 1377433b | Michael Hanselmann | |
245 | 1377433b | Michael Hanselmann | |
246 | 5a85b99e | Michael Hanselmann | def TestDelay(node): |
247 | 5a85b99e | Michael Hanselmann | """gnt-debug delay"""
|
248 | 5a85b99e | Michael Hanselmann | AssertCommand(["gnt-debug", "delay", "1"]) |
249 | 5a85b99e | Michael Hanselmann | AssertCommand(["gnt-debug", "delay", "--no-master", "1"]) |
250 | 5a85b99e | Michael Hanselmann | AssertCommand(["gnt-debug", "delay", "--no-master", |
251 | 5a85b99e | Michael Hanselmann | "-n", node["primary"], "1"]) |
252 | 5a85b99e | Michael Hanselmann | |
253 | 5a85b99e | Michael Hanselmann | |
254 | 452913ed | Iustin Pop | def TestClusterReservedLvs(): |
255 | 452913ed | Iustin Pop | """gnt-cluster reserved lvs"""
|
256 | 2f4b4f78 | Iustin Pop | for fail, cmd in [ |
257 | c2a0947d | Iustin Pop | (False, _CLUSTER_VERIFY),
|
258 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "--reserved-lvs", ""]), |
259 | 2f4b4f78 | Iustin Pop | (False, ["lvcreate", "-L1G", "-nqa-test", "xenvg"]), |
260 | 21bf2e2e | Andrea Spadaccini | (True, _CLUSTER_VERIFY),
|
261 | 84d7e26b | Dmitry Chernyak | (False, ["gnt-cluster", "modify", "--reserved-lvs", |
262 | 84d7e26b | Dmitry Chernyak | "xenvg/qa-test,.*/other-test"]),
|
263 | c2a0947d | Iustin Pop | (False, _CLUSTER_VERIFY),
|
264 | 84d7e26b | Dmitry Chernyak | (False, ["gnt-cluster", "modify", "--reserved-lvs", ".*/qa-.*"]), |
265 | c2a0947d | Iustin Pop | (False, _CLUSTER_VERIFY),
|
266 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "--reserved-lvs", ""]), |
267 | 21bf2e2e | Andrea Spadaccini | (True, _CLUSTER_VERIFY),
|
268 | 2f4b4f78 | Iustin Pop | (False, ["lvremove", "-f", "xenvg/qa-test"]), |
269 | c2a0947d | Iustin Pop | (False, _CLUSTER_VERIFY),
|
270 | 452913ed | Iustin Pop | ]: |
271 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, fail=fail) |
272 | 452913ed | Iustin Pop | |
273 | cec9845c | Michael Hanselmann | |
274 | 9738ca94 | Iustin Pop | def TestClusterModifyBe(): |
275 | 9738ca94 | Iustin Pop | """gnt-cluster modify -B"""
|
276 | 2f4b4f78 | Iustin Pop | for fail, cmd in [ |
277 | 8ccbbe4b | Guido Trotter | # max/min mem
|
278 | 8ccbbe4b | Guido Trotter | (False, ["gnt-cluster", "modify", "-B", "maxmem=256"]), |
279 | 8ccbbe4b | Guido Trotter | (False, ["sh", "-c", "gnt-cluster info|grep '^ *maxmem: 256$'"]), |
280 | 8ccbbe4b | Guido Trotter | (False, ["gnt-cluster", "modify", "-B", "minmem=256"]), |
281 | 8ccbbe4b | Guido Trotter | (False, ["sh", "-c", "gnt-cluster info|grep '^ *minmem: 256$'"]), |
282 | 8ccbbe4b | Guido Trotter | (True, ["gnt-cluster", "modify", "-B", "maxmem=a"]), |
283 | 8ccbbe4b | Guido Trotter | (False, ["sh", "-c", "gnt-cluster info|grep '^ *maxmem: 256$'"]), |
284 | 8ccbbe4b | Guido Trotter | (True, ["gnt-cluster", "modify", "-B", "minmem=a"]), |
285 | 8ccbbe4b | Guido Trotter | (False, ["sh", "-c", "gnt-cluster info|grep '^ *minmem: 256$'"]), |
286 | 8ccbbe4b | Guido Trotter | (False, ["gnt-cluster", "modify", "-B", "maxmem=128,minmem=128"]), |
287 | 8ccbbe4b | Guido Trotter | (False, ["sh", "-c", "gnt-cluster info|grep '^ *maxmem: 128$'"]), |
288 | 8ccbbe4b | Guido Trotter | (False, ["sh", "-c", "gnt-cluster info|grep '^ *minmem: 128$'"]), |
289 | 9738ca94 | Iustin Pop | # vcpus
|
290 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "vcpus=4"]), |
291 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *vcpus: 4$'"]), |
292 | 21bf2e2e | Andrea Spadaccini | (True, ["gnt-cluster", "modify", "-B", "vcpus=a"]), |
293 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "vcpus=1"]), |
294 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *vcpus: 1$'"]), |
295 | 9738ca94 | Iustin Pop | # auto_balance
|
296 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "auto_balance=False"]), |
297 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *auto_balance: False$'"]), |
298 | 21bf2e2e | Andrea Spadaccini | (True, ["gnt-cluster", "modify", "-B", "auto_balance=1"]), |
299 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "auto_balance=True"]), |
300 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *auto_balance: True$'"]), |
301 | 9738ca94 | Iustin Pop | ]: |
302 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, fail=fail) |
303 | 9738ca94 | Iustin Pop | |
304 | 5abecc1c | Iustin Pop | # redo the original-requested BE parameters, if any
|
305 | 5abecc1c | Iustin Pop | bep = qa_config.get("backend-parameters", "") |
306 | 5abecc1c | Iustin Pop | if bep:
|
307 | 5abecc1c | Iustin Pop | AssertCommand(["gnt-cluster", "modify", "-B", bep]) |
308 | 9738ca94 | Iustin Pop | |
309 | 21bf2e2e | Andrea Spadaccini | |
310 | cec9845c | Michael Hanselmann | def TestClusterInfo(): |
311 | cec9845c | Michael Hanselmann | """gnt-cluster info"""
|
312 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "info"]) |
313 | 283f9d4c | Michael Hanselmann | |
314 | 283f9d4c | Michael Hanselmann | |
315 | 3e8b5a9c | Iustin Pop | def TestClusterRedistConf(): |
316 | 3e8b5a9c | Iustin Pop | """gnt-cluster redist-conf"""
|
317 | 3e8b5a9c | Iustin Pop | AssertCommand(["gnt-cluster", "redist-conf"]) |
318 | 3e8b5a9c | Iustin Pop | |
319 | 3e8b5a9c | Iustin Pop | |
320 | 283f9d4c | Michael Hanselmann | def TestClusterGetmaster(): |
321 | 283f9d4c | Michael Hanselmann | """gnt-cluster getmaster"""
|
322 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "getmaster"]) |
323 | 283f9d4c | Michael Hanselmann | |
324 | 283f9d4c | Michael Hanselmann | |
325 | 283f9d4c | Michael Hanselmann | def TestClusterVersion(): |
326 | 283f9d4c | Michael Hanselmann | """gnt-cluster version"""
|
327 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "version"]) |
328 | cec9845c | Michael Hanselmann | |
329 | cec9845c | Michael Hanselmann | |
330 | 6d4a1656 | Michael Hanselmann | def TestClusterRenewCrypto(): |
331 | 6d4a1656 | Michael Hanselmann | """gnt-cluster renew-crypto"""
|
332 | 6d4a1656 | Michael Hanselmann | master = qa_config.GetMasterNode() |
333 | 6d4a1656 | Michael Hanselmann | |
334 | 6d4a1656 | Michael Hanselmann | # Conflicting options
|
335 | 6d4a1656 | Michael Hanselmann | cmd = ["gnt-cluster", "renew-crypto", "--force", |
336 | 3db3eb2a | Michael Hanselmann | "--new-cluster-certificate", "--new-confd-hmac-key"] |
337 | 3db3eb2a | Michael Hanselmann | conflicting = [ |
338 | 3db3eb2a | Michael Hanselmann | ["--new-rapi-certificate", "--rapi-certificate=/dev/null"], |
339 | 3db3eb2a | Michael Hanselmann | ["--new-cluster-domain-secret", "--cluster-domain-secret=/dev/null"], |
340 | 3db3eb2a | Michael Hanselmann | ] |
341 | 3db3eb2a | Michael Hanselmann | for i in conflicting: |
342 | 21bf2e2e | Andrea Spadaccini | AssertCommand(cmd + i, fail=True)
|
343 | 6d4a1656 | Michael Hanselmann | |
344 | 6d4a1656 | Michael Hanselmann | # Invalid RAPI certificate
|
345 | 6d4a1656 | Michael Hanselmann | cmd = ["gnt-cluster", "renew-crypto", "--force", |
346 | 6d4a1656 | Michael Hanselmann | "--rapi-certificate=/dev/null"]
|
347 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, fail=True)
|
348 | 6d4a1656 | Michael Hanselmann | |
349 | 502f5236 | Michael Hanselmann | rapi_cert_backup = qa_utils.BackupFile(master["primary"],
|
350 | 502f5236 | Michael Hanselmann | constants.RAPI_CERT_FILE) |
351 | 502f5236 | Michael Hanselmann | try:
|
352 | 502f5236 | Michael Hanselmann | # Custom RAPI certificate
|
353 | 502f5236 | Michael Hanselmann | fh = tempfile.NamedTemporaryFile() |
354 | 6d4a1656 | Michael Hanselmann | |
355 | 502f5236 | Michael Hanselmann | # Ensure certificate doesn't cause "gnt-cluster verify" to complain
|
356 | 502f5236 | Michael Hanselmann | validity = constants.SSL_CERT_EXPIRATION_WARN * 3
|
357 | 6d4a1656 | Michael Hanselmann | |
358 | 5e26633b | Michael Hanselmann | utils.GenerateSelfSignedSslCert(fh.name, validity=validity) |
359 | 6d4a1656 | Michael Hanselmann | |
360 | 502f5236 | Michael Hanselmann | tmpcert = qa_utils.UploadFile(master["primary"], fh.name)
|
361 | 502f5236 | Michael Hanselmann | try:
|
362 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
363 | 2f4b4f78 | Iustin Pop | "--rapi-certificate=%s" % tmpcert])
|
364 | 502f5236 | Michael Hanselmann | finally:
|
365 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", tmpcert]) |
366 | 502f5236 | Michael Hanselmann | |
367 | 5e26633b | Michael Hanselmann | # Custom cluster domain secret
|
368 | 5e26633b | Michael Hanselmann | cds_fh = tempfile.NamedTemporaryFile() |
369 | 5e26633b | Michael Hanselmann | cds_fh.write(utils.GenerateSecret()) |
370 | 5e26633b | Michael Hanselmann | cds_fh.write("\n")
|
371 | 5e26633b | Michael Hanselmann | cds_fh.flush() |
372 | 5e26633b | Michael Hanselmann | |
373 | 5e26633b | Michael Hanselmann | tmpcds = qa_utils.UploadFile(master["primary"], cds_fh.name)
|
374 | 5e26633b | Michael Hanselmann | try:
|
375 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
376 | 2f4b4f78 | Iustin Pop | "--cluster-domain-secret=%s" % tmpcds])
|
377 | 5e26633b | Michael Hanselmann | finally:
|
378 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", tmpcds]) |
379 | 5e26633b | Michael Hanselmann | |
380 | 502f5236 | Michael Hanselmann | # Normal case
|
381 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
382 | 2f4b4f78 | Iustin Pop | "--new-cluster-certificate", "--new-confd-hmac-key", |
383 | 2f4b4f78 | Iustin Pop | "--new-rapi-certificate", "--new-cluster-domain-secret"]) |
384 | 3db3eb2a | Michael Hanselmann | |
385 | 502f5236 | Michael Hanselmann | # Restore RAPI certificate
|
386 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
387 | 2f4b4f78 | Iustin Pop | "--rapi-certificate=%s" % rapi_cert_backup])
|
388 | 3db3eb2a | Michael Hanselmann | finally:
|
389 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", rapi_cert_backup]) |
390 | 3db3eb2a | Michael Hanselmann | |
391 | 6d4a1656 | Michael Hanselmann | |
392 | cec9845c | Michael Hanselmann | def TestClusterBurnin(): |
393 | cec9845c | Michael Hanselmann | """Burnin"""
|
394 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
395 | cec9845c | Michael Hanselmann | |
396 | d0c8c01d | Iustin Pop | options = qa_config.get("options", {})
|
397 | d0c8c01d | Iustin Pop | disk_template = options.get("burnin-disk-template", "drbd") |
398 | d0c8c01d | Iustin Pop | parallel = options.get("burnin-in-parallel", False) |
399 | d0c8c01d | Iustin Pop | check_inst = options.get("burnin-check-instances", False) |
400 | d0c8c01d | Iustin Pop | do_rename = options.get("burnin-rename", "") |
401 | d0c8c01d | Iustin Pop | do_reboot = options.get("burnin-reboot", True) |
402 | 1d103c02 | Iustin Pop | reboot_types = options.get("reboot-types", constants.REBOOT_TYPES)
|
403 | 23103544 | Michael Hanselmann | |
404 | cec9845c | Michael Hanselmann | # Get as many instances as we need
|
405 | cec9845c | Michael Hanselmann | instances = [] |
406 | cec9845c | Michael Hanselmann | try:
|
407 | 23103544 | Michael Hanselmann | try:
|
408 | d0c8c01d | Iustin Pop | num = qa_config.get("options", {}).get("burnin-instances", 1) |
409 | f1501b3f | Michael Hanselmann | for _ in range(0, num): |
410 | 23103544 | Michael Hanselmann | instances.append(qa_config.AcquireInstance()) |
411 | 23103544 | Michael Hanselmann | except qa_error.OutOfInstancesError:
|
412 | 23103544 | Michael Hanselmann | print "Not enough instances, continuing anyway." |
413 | cec9845c | Michael Hanselmann | |
414 | 23103544 | Michael Hanselmann | if len(instances) < 1: |
415 | 23103544 | Michael Hanselmann | raise qa_error.Error("Burnin needs at least one instance") |
416 | cec9845c | Michael Hanselmann | |
417 | d0c8c01d | Iustin Pop | script = qa_utils.UploadFile(master["primary"], "../tools/burnin") |
418 | cec9845c | Michael Hanselmann | try:
|
419 | 23103544 | Michael Hanselmann | # Run burnin
|
420 | cec9845c | Michael Hanselmann | cmd = [script, |
421 | d0c8c01d | Iustin Pop | "--os=%s" % qa_config.get("os"), |
422 | d0c8c01d | Iustin Pop | "--disk-size=%s" % ",".join(qa_config.get("disk")), |
423 | d0c8c01d | Iustin Pop | "--disk-growth=%s" % ",".join(qa_config.get("disk-growth")), |
424 | d0c8c01d | Iustin Pop | "--disk-template=%s" % disk_template]
|
425 | 0b0a150a | Iustin Pop | if parallel:
|
426 | d0c8c01d | Iustin Pop | cmd.append("--parallel")
|
427 | d0c8c01d | Iustin Pop | cmd.append("--early-release")
|
428 | 0b0a150a | Iustin Pop | if check_inst:
|
429 | d0c8c01d | Iustin Pop | cmd.append("--http-check")
|
430 | 4dc76b24 | Iustin Pop | if do_rename:
|
431 | d0c8c01d | Iustin Pop | cmd.append("--rename=%s" % do_rename)
|
432 | 58598264 | Iustin Pop | if not do_reboot: |
433 | d0c8c01d | Iustin Pop | cmd.append("--no-reboot")
|
434 | 1d103c02 | Iustin Pop | else:
|
435 | d0c8c01d | Iustin Pop | cmd.append("--reboot-types=%s" % ",".join(reboot_types)) |
436 | d0c8c01d | Iustin Pop | cmd += [inst["name"] for inst in instances] |
437 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd) |
438 | cec9845c | Michael Hanselmann | finally:
|
439 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", script]) |
440 | 2f4b4f78 | Iustin Pop | |
441 | cec9845c | Michael Hanselmann | finally:
|
442 | cec9845c | Michael Hanselmann | for inst in instances: |
443 | cec9845c | Michael Hanselmann | qa_config.ReleaseInstance(inst) |
444 | cec9845c | Michael Hanselmann | |
445 | cec9845c | Michael Hanselmann | |
446 | cec9845c | Michael Hanselmann | def TestClusterMasterFailover(): |
447 | c28502b1 | Iustin Pop | """gnt-cluster master-failover"""
|
448 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
449 | cec9845c | Michael Hanselmann | failovermaster = qa_config.AcquireNode(exclude=master) |
450 | cec9845c | Michael Hanselmann | |
451 | 2f4b4f78 | Iustin Pop | cmd = ["gnt-cluster", "master-failover"] |
452 | 2f4b4f78 | Iustin Pop | try:
|
453 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, node=failovermaster) |
454 | ff699aa9 | Michael Hanselmann | # Back to original master node
|
455 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, node=master) |
456 | cec9845c | Michael Hanselmann | finally:
|
457 | cec9845c | Michael Hanselmann | qa_config.ReleaseNode(failovermaster) |
458 | cec9845c | Michael Hanselmann | |
459 | cec9845c | Michael Hanselmann | |
460 | ff699aa9 | Michael Hanselmann | def TestClusterMasterFailoverWithDrainedQueue(): |
461 | ff699aa9 | Michael Hanselmann | """gnt-cluster master-failover with drained queue"""
|
462 | ff699aa9 | Michael Hanselmann | drain_check = ["test", "-f", constants.JOB_QUEUE_DRAIN_FILE] |
463 | ff699aa9 | Michael Hanselmann | |
464 | ff699aa9 | Michael Hanselmann | master = qa_config.GetMasterNode() |
465 | ff699aa9 | Michael Hanselmann | failovermaster = qa_config.AcquireNode(exclude=master) |
466 | ff699aa9 | Michael Hanselmann | |
467 | ff699aa9 | Michael Hanselmann | # Ensure queue is not drained
|
468 | ff699aa9 | Michael Hanselmann | for node in [master, failovermaster]: |
469 | ff699aa9 | Michael Hanselmann | AssertCommand(drain_check, node=node, fail=True)
|
470 | ff699aa9 | Michael Hanselmann | |
471 | ff699aa9 | Michael Hanselmann | # Drain queue on failover master
|
472 | ff699aa9 | Michael Hanselmann | AssertCommand(["touch", constants.JOB_QUEUE_DRAIN_FILE], node=failovermaster)
|
473 | ff699aa9 | Michael Hanselmann | |
474 | ff699aa9 | Michael Hanselmann | cmd = ["gnt-cluster", "master-failover"] |
475 | ff699aa9 | Michael Hanselmann | try:
|
476 | ff699aa9 | Michael Hanselmann | AssertCommand(drain_check, node=failovermaster) |
477 | ff699aa9 | Michael Hanselmann | AssertCommand(cmd, node=failovermaster) |
478 | ff699aa9 | Michael Hanselmann | AssertCommand(drain_check, fail=True)
|
479 | ff699aa9 | Michael Hanselmann | AssertCommand(drain_check, node=failovermaster, fail=True)
|
480 | ff699aa9 | Michael Hanselmann | |
481 | ff699aa9 | Michael Hanselmann | # Back to original master node
|
482 | ff699aa9 | Michael Hanselmann | AssertCommand(cmd, node=master) |
483 | ff699aa9 | Michael Hanselmann | finally:
|
484 | ff699aa9 | Michael Hanselmann | qa_config.ReleaseNode(failovermaster) |
485 | ff699aa9 | Michael Hanselmann | |
486 | ff699aa9 | Michael Hanselmann | AssertCommand(drain_check, fail=True)
|
487 | ff699aa9 | Michael Hanselmann | AssertCommand(drain_check, node=failovermaster, fail=True)
|
488 | ff699aa9 | Michael Hanselmann | |
489 | ff699aa9 | Michael Hanselmann | |
490 | cec9845c | Michael Hanselmann | def TestClusterCopyfile(): |
491 | cec9845c | Michael Hanselmann | """gnt-cluster copyfile"""
|
492 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
493 | cec9845c | Michael Hanselmann | |
494 | 24818e8f | Michael Hanselmann | uniqueid = utils.NewUUID() |
495 | 830da270 | Michael Hanselmann | |
496 | cec9845c | Michael Hanselmann | # Create temporary file
|
497 | cec9845c | Michael Hanselmann | f = tempfile.NamedTemporaryFile() |
498 | 830da270 | Michael Hanselmann | f.write(uniqueid) |
499 | cec9845c | Michael Hanselmann | f.flush() |
500 | cec9845c | Michael Hanselmann | f.seek(0)
|
501 | cec9845c | Michael Hanselmann | |
502 | cec9845c | Michael Hanselmann | # Upload file to master node
|
503 | d0c8c01d | Iustin Pop | testname = qa_utils.UploadFile(master["primary"], f.name)
|
504 | cec9845c | Michael Hanselmann | try:
|
505 | cec9845c | Michael Hanselmann | # Copy file to all nodes
|
506 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "copyfile", testname]) |
507 | 830da270 | Michael Hanselmann | _CheckFileOnAllNodes(testname, uniqueid) |
508 | cec9845c | Michael Hanselmann | finally:
|
509 | 830da270 | Michael Hanselmann | _RemoveFileFromAllNodes(testname) |
510 | 830da270 | Michael Hanselmann | |
511 | 830da270 | Michael Hanselmann | |
512 | 830da270 | Michael Hanselmann | def TestClusterCommand(): |
513 | 830da270 | Michael Hanselmann | """gnt-cluster command"""
|
514 | 24818e8f | Michael Hanselmann | uniqueid = utils.NewUUID() |
515 | 24818e8f | Michael Hanselmann | rfile = "/tmp/gnt%s" % utils.NewUUID()
|
516 | d0c8c01d | Iustin Pop | rcmd = utils.ShellQuoteArgs(["echo", "-n", uniqueid]) |
517 | d0c8c01d | Iustin Pop | cmd = utils.ShellQuoteArgs(["gnt-cluster", "command", |
518 | 830da270 | Michael Hanselmann | "%s >%s" % (rcmd, rfile)])
|
519 | 830da270 | Michael Hanselmann | |
520 | 830da270 | Michael Hanselmann | try:
|
521 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd) |
522 | 830da270 | Michael Hanselmann | _CheckFileOnAllNodes(rfile, uniqueid) |
523 | 830da270 | Michael Hanselmann | finally:
|
524 | 830da270 | Michael Hanselmann | _RemoveFileFromAllNodes(rfile) |
525 | cec9845c | Michael Hanselmann | |
526 | cec9845c | Michael Hanselmann | |
527 | cec9845c | Michael Hanselmann | def TestClusterDestroy(): |
528 | cec9845c | Michael Hanselmann | """gnt-cluster destroy"""
|
529 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "destroy", "--yes-do-it"]) |
530 | 65a884ef | Iustin Pop | |
531 | 65a884ef | Iustin Pop | |
532 | 65a884ef | Iustin Pop | def TestClusterRepairDiskSizes(): |
533 | 65a884ef | Iustin Pop | """gnt-cluster repair-disk-sizes"""
|
534 | 65a884ef | Iustin Pop | AssertCommand(["gnt-cluster", "repair-disk-sizes"]) |