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