111 |
111 |
" %ss: %s" % (etype, utils.CommaJoin(missing)))
|
112 |
112 |
|
113 |
113 |
|
114 |
|
def AssertClusterVerify(fail=False, errors=None, warnings=None):
|
115 |
|
"""Run cluster-verify and check the result
|
|
114 |
def _CheckVerifyNoWarnings(actual, expected):
|
|
115 |
exp_codes = compat.UniqueFrozenset(e for (_, e, _) in expected)
|
|
116 |
excess = actual.intersection(exp_codes)
|
|
117 |
if excess:
|
|
118 |
raise qa_error.Error("Cluster-verify returned these warnings:"
|
|
119 |
" %s" % (utils.CommaJoin(excess)))
|
|
120 |
|
|
121 |
|
|
122 |
def AssertClusterVerify(fail=False, errors=None,
|
|
123 |
warnings=None, no_warnings=None):
|
|
124 |
"""Run cluster-verify and check the result, ignoring warnings by default.
|
116 |
125 |
|
117 |
126 |
@type fail: bool
|
118 |
|
@param fail: if cluster-verify is expected to fail instead of succeeding
|
|
127 |
@param fail: if cluster-verify is expected to fail instead of succeeding.
|
119 |
128 |
@type errors: list of tuples
|
120 |
129 |
@param errors: List of CV_XXX errors that are expected; if specified, all the
|
121 |
130 |
errors listed must appear in cluster-verify output. A non-empty value
|
122 |
131 |
implies C{fail=True}.
|
123 |
132 |
@type warnings: list of tuples
|
124 |
|
@param warnings: Same as C{errors} but for warnings.
|
125 |
|
|
|
133 |
@param warnings: List of CV_XXX warnings that are expected to be raised; if
|
|
134 |
specified, all the errors listed must appear in cluster-verify output.
|
|
135 |
@type no_warnings: list of tuples
|
|
136 |
@param no_warnings: List of CV_XXX warnings that we expect NOT to be raised.
|
126 |
137 |
"""
|
127 |
138 |
cvcmd = "gnt-cluster verify"
|
128 |
139 |
mnode = qa_config.GetMasterNode()
|
129 |
|
if errors or warnings:
|
|
140 |
if errors or warnings or no_warnings:
|
130 |
141 |
cvout = GetCommandOutput(mnode.primary, cvcmd + " --error-codes",
|
131 |
142 |
fail=(fail or errors))
|
|
143 |
print cvout
|
132 |
144 |
(act_errs, act_warns) = _GetCVErrorCodes(cvout)
|
133 |
145 |
if errors:
|
134 |
146 |
_CheckVerifyErrors(act_errs, errors, "error")
|
135 |
147 |
if warnings:
|
136 |
148 |
_CheckVerifyErrors(act_warns, warnings, "warning")
|
|
149 |
if no_warnings:
|
|
150 |
_CheckVerifyNoWarnings(act_warns, no_warnings)
|
|
151 |
|
137 |
152 |
else:
|
138 |
153 |
AssertCommand(cvcmd, fail=fail, node=mnode)
|
139 |
154 |
|
... | ... | |
420 |
435 |
vgname = qa_config.get("vg-name", constants.DEFAULT_VG)
|
421 |
436 |
lvname = _QA_LV_PREFIX + "test"
|
422 |
437 |
lvfullname = "/".join([vgname, lvname])
|
423 |
|
for fail, cmd in [
|
424 |
|
(False, _CLUSTER_VERIFY),
|
425 |
|
(False, ["gnt-cluster", "modify", "--reserved-lvs", ""]),
|
426 |
|
(False, ["lvcreate", "-L1G", "-n", lvname, vgname]),
|
427 |
|
(True, _CLUSTER_VERIFY),
|
428 |
|
(False, ["gnt-cluster", "modify", "--reserved-lvs",
|
429 |
|
"%s,.*/other-test" % lvfullname]),
|
430 |
|
(False, _CLUSTER_VERIFY),
|
431 |
|
(False, ["gnt-cluster", "modify", "--reserved-lvs",
|
432 |
|
".*/%s.*" % _QA_LV_PREFIX]),
|
433 |
|
(False, _CLUSTER_VERIFY),
|
434 |
|
(False, ["gnt-cluster", "modify", "--reserved-lvs", ""]),
|
435 |
|
(True, _CLUSTER_VERIFY),
|
436 |
|
(False, ["lvremove", "-f", lvfullname]),
|
437 |
|
(False, _CLUSTER_VERIFY),
|
438 |
|
]:
|
439 |
|
AssertCommand(cmd, fail=fail)
|
|
438 |
|
|
439 |
# Clean cluster
|
|
440 |
AssertClusterVerify()
|
|
441 |
|
|
442 |
AssertCommand(["gnt-cluster", "modify", "--reserved-lvs", ""])
|
|
443 |
AssertCommand(["lvcreate", "-L1G", "-n", lvname, vgname])
|
|
444 |
AssertClusterVerify(fail=False,
|
|
445 |
warnings=[constants.CV_ENODEORPHANLV])
|
|
446 |
|
|
447 |
AssertCommand(["gnt-cluster", "modify", "--reserved-lvs",
|
|
448 |
"%s,.*/other-test" % lvfullname])
|
|
449 |
AssertClusterVerify(no_warnings=[constants.CV_ENODEORPHANLV])
|
|
450 |
|
|
451 |
AssertCommand(["gnt-cluster", "modify", "--reserved-lvs",
|
|
452 |
".*/%s.*" % _QA_LV_PREFIX])
|
|
453 |
AssertClusterVerify(no_warnings=[constants.CV_ENODEORPHANLV])
|
|
454 |
|
|
455 |
AssertCommand(["gnt-cluster", "modify", "--reserved-lvs", ""])
|
|
456 |
AssertClusterVerify(fail=False,
|
|
457 |
warnings=[constants.CV_ENODEORPHANLV])
|
|
458 |
|
|
459 |
AssertCommand(["lvremove", "-f", lvfullname])
|
|
460 |
AssertClusterVerify()
|
440 |
461 |
|
441 |
462 |
|
442 |
463 |
def TestClusterModifyEmpty():
|
... | ... | |
1304 |
1325 |
lvname2 = _QA_LV_PREFIX + "vol2"
|
1305 |
1326 |
node_name = node.primary
|
1306 |
1327 |
AssertCommand(["lvcreate", "-L1G", "-n", lvname1, vgname], node=node_name)
|
1307 |
|
AssertClusterVerify(fail=True, errors=[constants.CV_ENODEORPHANLV])
|
|
1328 |
AssertClusterVerify(fail=False,
|
|
1329 |
warnings=[constants.CV_ENODEORPHANLV])
|
1308 |
1330 |
AssertCommand(["lvcreate", "-L1G", "-n", lvname2, vgname], node=node_name)
|
1309 |
|
AssertClusterVerify(fail=True, errors=[constants.CV_ENODELVM,
|
1310 |
|
constants.CV_ENODEORPHANLV])
|
|
1331 |
AssertClusterVerify(fail=True,
|
|
1332 |
errors=[constants.CV_ENODELVM],
|
|
1333 |
warnings=[constants.CV_ENODEORPHANLV])
|
1311 |
1334 |
AssertCommand(["lvremove", "-f", "/".join([vgname, lvname1])], node=node_name)
|
1312 |
1335 |
AssertCommand(["lvremove", "-f", "/".join([vgname, lvname2])], node=node_name)
|
1313 |
1336 |
AssertClusterVerify()
|