Revision 2214cf14 qa/qa_utils.py
b/qa/qa_utils.py | ||
---|---|---|
31 | 31 |
|
32 | 32 |
from ganeti import utils |
33 | 33 |
from ganeti import compat |
34 |
from ganeti import constants |
|
34 | 35 |
|
35 | 36 |
import qa_config |
36 | 37 |
import qa_error |
... | ... | |
139 | 140 |
raise qa_error.Error("Command '%s' on node %s failed, exit code %s" % |
140 | 141 |
(cmdstr, nodename, rcode)) |
141 | 142 |
|
143 |
return rcode |
|
144 |
|
|
142 | 145 |
|
143 | 146 |
def GetSSHCommand(node, cmd, strict=True): |
144 | 147 |
"""Builds SSH command to be executed. |
... | ... | |
352 | 355 |
rnd.shuffle(randnames) |
353 | 356 |
AssertEqual(namelist_fn(randnames), randnames) |
354 | 357 |
|
358 |
# Listing unknown items must fail |
|
359 |
AssertCommand([cmd, "list", "this.name.certainly.does.not.exist"], fail=True) |
|
360 |
|
|
361 |
# Check exit code for listing unknown field |
|
362 |
AssertEqual(AssertCommand([cmd, "list", "--output=field/does/not/exist"], |
|
363 |
fail=True), |
|
364 |
constants.EXIT_UNKNOWN_FIELD) |
|
365 |
|
|
366 |
|
|
367 |
def GenericQueryFieldsTest(cmd, fields): |
|
368 |
master = qa_config.GetMasterNode() |
|
369 |
|
|
370 |
# Listing fields |
|
371 |
AssertCommand([cmd, "list-fields"]) |
|
372 |
AssertCommand([cmd, "list-fields"] + fields) |
|
373 |
|
|
374 |
# Check listed fields (all, must be sorted) |
|
375 |
realcmd = [cmd, "list-fields", "--separator=|", "--no-headers"] |
|
376 |
output = GetCommandOutput(master["primary"], |
|
377 |
utils.ShellQuoteArgs(realcmd)).splitlines() |
|
378 |
AssertEqual([line.split("|", 1)[0] for line in output], |
|
379 |
sorted(fields)) |
|
380 |
|
|
381 |
# Check exit code for listing unknown field |
|
382 |
AssertEqual(AssertCommand([cmd, "list-fields", "field/does/not/exist"], |
|
383 |
fail=True), |
|
384 |
constants.EXIT_UNKNOWN_FIELD) |
|
385 |
|
|
355 | 386 |
|
356 | 387 |
def _FormatWithColor(text, seq): |
357 | 388 |
if not seq: |
Also available in: Unified diff