root / qa / qa_cluster.py @ e8b919a1
History | View | Annotate | Download (20.6 kB)
1 | c68d1f43 | Michael Hanselmann | #
|
---|---|---|---|
2 | c68d1f43 | Michael Hanselmann | #
|
3 | c68d1f43 | Michael Hanselmann | |
4 | 587f8ff6 | Bernardo Dal Seno | # Copyright (C) 2007, 2010, 2011, 2012, 2013 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 | 587f8ff6 | Bernardo Dal Seno | import re |
27 | cec9845c | Michael Hanselmann | import tempfile |
28 | 49ceab21 | Michael Hanselmann | import os.path |
29 | cec9845c | Michael Hanselmann | |
30 | 6d4a1656 | Michael Hanselmann | from ganeti import constants |
31 | 66d1f035 | René Nussbaumer | from ganeti import compat |
32 | cec9845c | Michael Hanselmann | from ganeti import utils |
33 | 304d9f02 | Michael Hanselmann | from ganeti import pathutils |
34 | cec9845c | Michael Hanselmann | |
35 | cec9845c | Michael Hanselmann | import qa_config |
36 | cec9845c | Michael Hanselmann | import qa_utils |
37 | cec9845c | Michael Hanselmann | import qa_error |
38 | cec9845c | Michael Hanselmann | |
39 | 66d1f035 | René Nussbaumer | from qa_utils import AssertEqual, AssertCommand, GetCommandOutput |
40 | cec9845c | Michael Hanselmann | |
41 | cec9845c | Michael Hanselmann | |
42 | c2a0947d | Iustin Pop | #: cluster verify command
|
43 | c2a0947d | Iustin Pop | _CLUSTER_VERIFY = ["gnt-cluster", "verify"] |
44 | c2a0947d | Iustin Pop | |
45 | 21bf2e2e | Andrea Spadaccini | |
46 | 830da270 | Michael Hanselmann | def _RemoveFileFromAllNodes(filename): |
47 | 830da270 | Michael Hanselmann | """Removes a file from all nodes.
|
48 | 830da270 | Michael Hanselmann |
|
49 | 830da270 | Michael Hanselmann | """
|
50 | 2f4b4f78 | Iustin Pop | for node in qa_config.get("nodes"): |
51 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", filename], node=node) |
52 | 830da270 | Michael Hanselmann | |
53 | 830da270 | Michael Hanselmann | |
54 | 830da270 | Michael Hanselmann | def _CheckFileOnAllNodes(filename, content): |
55 | 830da270 | Michael Hanselmann | """Verifies the content of the given file on all nodes.
|
56 | 830da270 | Michael Hanselmann |
|
57 | 830da270 | Michael Hanselmann | """
|
58 | 830da270 | Michael Hanselmann | cmd = utils.ShellQuoteArgs(["cat", filename])
|
59 | 2f4b4f78 | Iustin Pop | for node in qa_config.get("nodes"): |
60 | 2f4b4f78 | Iustin Pop | AssertEqual(qa_utils.GetCommandOutput(node["primary"], cmd), content)
|
61 | 830da270 | Michael Hanselmann | |
62 | 830da270 | Michael Hanselmann | |
63 | 17cfeee9 | Bernardo Dal Seno | # "gnt-cluster info" fields
|
64 | 17cfeee9 | Bernardo Dal Seno | _CIFIELD_RE = re.compile(r"^[-\s]*(?P<field>[^\s:]+):\s*(?P<value>\S.*)$")
|
65 | 17cfeee9 | Bernardo Dal Seno | |
66 | 17cfeee9 | Bernardo Dal Seno | |
67 | 17cfeee9 | Bernardo Dal Seno | def _GetBoolClusterField(field): |
68 | 17cfeee9 | Bernardo Dal Seno | """Get the Boolean value of a cluster field.
|
69 | 17cfeee9 | Bernardo Dal Seno |
|
70 | 17cfeee9 | Bernardo Dal Seno | This function currently assumes that the field name is unique in the cluster
|
71 | 17cfeee9 | Bernardo Dal Seno | configuration. An assertion checks this assumption.
|
72 | 17cfeee9 | Bernardo Dal Seno |
|
73 | 17cfeee9 | Bernardo Dal Seno | @type field: string
|
74 | 17cfeee9 | Bernardo Dal Seno | @param field: Name of the field
|
75 | 17cfeee9 | Bernardo Dal Seno | @rtype: bool
|
76 | 17cfeee9 | Bernardo Dal Seno | @return: The effective value of the field
|
77 | 17cfeee9 | Bernardo Dal Seno |
|
78 | 17cfeee9 | Bernardo Dal Seno | """
|
79 | 17cfeee9 | Bernardo Dal Seno | master = qa_config.GetMasterNode() |
80 | 17cfeee9 | Bernardo Dal Seno | infocmd = "gnt-cluster info"
|
81 | 17cfeee9 | Bernardo Dal Seno | info_out = qa_utils.GetCommandOutput(master["primary"], infocmd)
|
82 | 17cfeee9 | Bernardo Dal Seno | ret = None
|
83 | 17cfeee9 | Bernardo Dal Seno | for l in info_out.splitlines(): |
84 | 17cfeee9 | Bernardo Dal Seno | m = _CIFIELD_RE.match(l) |
85 | 17cfeee9 | Bernardo Dal Seno | # FIXME: There should be a way to specify a field through a hierarchy
|
86 | 17cfeee9 | Bernardo Dal Seno | if m and m.group("field") == field: |
87 | 17cfeee9 | Bernardo Dal Seno | # Make sure that ignoring the hierarchy doesn't cause a double match
|
88 | 17cfeee9 | Bernardo Dal Seno | assert ret is None |
89 | 17cfeee9 | Bernardo Dal Seno | ret = (m.group("value").lower() == "true") |
90 | 17cfeee9 | Bernardo Dal Seno | if ret is not None: |
91 | 17cfeee9 | Bernardo Dal Seno | return ret
|
92 | 17cfeee9 | Bernardo Dal Seno | raise qa_error.Error("Field not found in cluster configuration: %s" % field) |
93 | 17cfeee9 | Bernardo Dal Seno | |
94 | 17cfeee9 | Bernardo Dal Seno | |
95 | 587f8ff6 | Bernardo Dal Seno | # Cluster-verify errors (date, "ERROR", then error code)
|
96 | 587f8ff6 | Bernardo Dal Seno | _CVERROR_RE = re.compile(r"^[\w\s:]+\s+- ERROR:([A-Z0-9_-]+):")
|
97 | 587f8ff6 | Bernardo Dal Seno | |
98 | 587f8ff6 | Bernardo Dal Seno | |
99 | 587f8ff6 | Bernardo Dal Seno | def _GetCVErrorCodes(cvout): |
100 | 587f8ff6 | Bernardo Dal Seno | ret = set()
|
101 | 587f8ff6 | Bernardo Dal Seno | for l in cvout.splitlines(): |
102 | 587f8ff6 | Bernardo Dal Seno | m = _CVERROR_RE.match(l) |
103 | 587f8ff6 | Bernardo Dal Seno | if m:
|
104 | 587f8ff6 | Bernardo Dal Seno | ecode = m.group(1)
|
105 | 587f8ff6 | Bernardo Dal Seno | ret.add(ecode) |
106 | 587f8ff6 | Bernardo Dal Seno | return ret
|
107 | 587f8ff6 | Bernardo Dal Seno | |
108 | 587f8ff6 | Bernardo Dal Seno | |
109 | 587f8ff6 | Bernardo Dal Seno | def AssertClusterVerify(fail=False, errors=None): |
110 | 587f8ff6 | Bernardo Dal Seno | """Run cluster-verify and check the result
|
111 | 587f8ff6 | Bernardo Dal Seno |
|
112 | 587f8ff6 | Bernardo Dal Seno | @type fail: bool
|
113 | 587f8ff6 | Bernardo Dal Seno | @param fail: if cluster-verify is expected to fail instead of succeeding
|
114 | 587f8ff6 | Bernardo Dal Seno | @type errors: list of tuples
|
115 | 587f8ff6 | Bernardo Dal Seno | @param errors: List of CV_XXX errors that are expected; if specified, all the
|
116 | 587f8ff6 | Bernardo Dal Seno | errors listed must appear in cluster-verify output. A non-empty value
|
117 | 587f8ff6 | Bernardo Dal Seno | implies C{fail=True}.
|
118 | 587f8ff6 | Bernardo Dal Seno |
|
119 | 587f8ff6 | Bernardo Dal Seno | """
|
120 | 587f8ff6 | Bernardo Dal Seno | cvcmd = "gnt-cluster verify"
|
121 | 587f8ff6 | Bernardo Dal Seno | mnode = qa_config.GetMasterNode() |
122 | 587f8ff6 | Bernardo Dal Seno | if errors:
|
123 | 587f8ff6 | Bernardo Dal Seno | cvout = GetCommandOutput(mnode["primary"], cvcmd + " --error-codes", |
124 | 587f8ff6 | Bernardo Dal Seno | fail=True)
|
125 | 587f8ff6 | Bernardo Dal Seno | actual = _GetCVErrorCodes(cvout) |
126 | 587f8ff6 | Bernardo Dal Seno | expected = compat.UniqueFrozenset(e for (_, e, _) in errors) |
127 | 587f8ff6 | Bernardo Dal Seno | if not actual.issuperset(expected): |
128 | 587f8ff6 | Bernardo Dal Seno | missing = expected.difference(actual) |
129 | 587f8ff6 | Bernardo Dal Seno | raise qa_error.Error("Cluster-verify didn't return these expected" |
130 | 587f8ff6 | Bernardo Dal Seno | " errors: %s" % utils.CommaJoin(missing))
|
131 | 587f8ff6 | Bernardo Dal Seno | else:
|
132 | 587f8ff6 | Bernardo Dal Seno | AssertCommand(cvcmd, fail=fail, node=mnode) |
133 | 587f8ff6 | Bernardo Dal Seno | |
134 | 587f8ff6 | Bernardo Dal Seno | |
135 | 92cb4940 | Andrea Spadaccini | # data for testing failures due to bad keys/values for disk parameters
|
136 | 92cb4940 | Andrea Spadaccini | _FAIL_PARAMS = ["nonexistent:resync-rate=1",
|
137 | 92cb4940 | Andrea Spadaccini | "drbd:nonexistent=1",
|
138 | 92cb4940 | Andrea Spadaccini | "drbd:resync-rate=invalid",
|
139 | 92cb4940 | Andrea Spadaccini | ] |
140 | 92cb4940 | Andrea Spadaccini | |
141 | 92cb4940 | Andrea Spadaccini | |
142 | 92cb4940 | Andrea Spadaccini | def TestClusterInitDisk(): |
143 | 92cb4940 | Andrea Spadaccini | """gnt-cluster init -D"""
|
144 | 92cb4940 | Andrea Spadaccini | name = qa_config.get("name")
|
145 | 92cb4940 | Andrea Spadaccini | for param in _FAIL_PARAMS: |
146 | 92cb4940 | Andrea Spadaccini | AssertCommand(["gnt-cluster", "init", "-D", param, name], fail=True) |
147 | 92cb4940 | Andrea Spadaccini | |
148 | 92cb4940 | Andrea Spadaccini | |
149 | 725ec2f1 | René Nussbaumer | def TestClusterInit(rapi_user, rapi_secret): |
150 | cec9845c | Michael Hanselmann | """gnt-cluster init"""
|
151 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
152 | cec9845c | Michael Hanselmann | |
153 | 304d9f02 | Michael Hanselmann | rapi_dir = os.path.dirname(pathutils.RAPI_USERS_FILE) |
154 | 49ceab21 | Michael Hanselmann | |
155 | 725ec2f1 | René Nussbaumer | # First create the RAPI credentials
|
156 | a62d1901 | Michael Hanselmann | fh = tempfile.NamedTemporaryFile() |
157 | a62d1901 | Michael Hanselmann | try:
|
158 | a62d1901 | Michael Hanselmann | fh.write("%s %s write\n" % (rapi_user, rapi_secret))
|
159 | a62d1901 | Michael Hanselmann | fh.flush() |
160 | a62d1901 | Michael Hanselmann | |
161 | a62d1901 | Michael Hanselmann | tmpru = qa_utils.UploadFile(master["primary"], fh.name)
|
162 | a62d1901 | Michael Hanselmann | try:
|
163 | 49ceab21 | Michael Hanselmann | AssertCommand(["mkdir", "-p", rapi_dir]) |
164 | 304d9f02 | Michael Hanselmann | AssertCommand(["mv", tmpru, pathutils.RAPI_USERS_FILE])
|
165 | a62d1901 | Michael Hanselmann | finally:
|
166 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", tmpru]) |
167 | a62d1901 | Michael Hanselmann | finally:
|
168 | a62d1901 | Michael Hanselmann | fh.close() |
169 | a62d1901 | Michael Hanselmann | |
170 | a62d1901 | Michael Hanselmann | # Initialize cluster
|
171 | e7b6183b | Michael Hanselmann | cmd = [ |
172 | e7b6183b | Michael Hanselmann | "gnt-cluster", "init", |
173 | e7b6183b | Michael Hanselmann | "--primary-ip-version=%d" % qa_config.get("primary_ip_version", 4), |
174 | 59c1d41e | Michael Hanselmann | "--enabled-hypervisors=%s" % ",".join(qa_config.GetEnabledHypervisors()), |
175 | e7b6183b | Michael Hanselmann | ] |
176 | 20286f7c | René Nussbaumer | |
177 | 20286f7c | René Nussbaumer | for spec_type in ("mem-size", "disk-size", "disk-count", "cpu-count", |
178 | 20286f7c | René Nussbaumer | "nic-count"):
|
179 | 20286f7c | René Nussbaumer | for spec_val in ("min", "max", "std"): |
180 | 20286f7c | René Nussbaumer | spec = qa_config.get("ispec_%s_%s" %
|
181 | 3601d488 | Michael Hanselmann | (spec_type.replace("-", "_"), spec_val), None) |
182 | 20286f7c | René Nussbaumer | if spec:
|
183 | 20286f7c | René Nussbaumer | cmd.append("--specs-%s=%s=%d" % (spec_type, spec_val, spec))
|
184 | 9486f6ae | Manuel Franceschini | |
185 | d0c8c01d | Iustin Pop | if master.get("secondary", None): |
186 | d0c8c01d | Iustin Pop | cmd.append("--secondary-ip=%s" % master["secondary"]) |
187 | cec9845c | Michael Hanselmann | |
188 | 3601d488 | Michael Hanselmann | master_netdev = qa_config.get("master-netdev", None) |
189 | 3601d488 | Michael Hanselmann | if master_netdev:
|
190 | 3601d488 | Michael Hanselmann | cmd.append("--master-netdev=%s" % master_netdev)
|
191 | 3601d488 | Michael Hanselmann | |
192 | 3601d488 | Michael Hanselmann | nicparams = qa_config.get("default-nicparams", None) |
193 | 3601d488 | Michael Hanselmann | if nicparams:
|
194 | 3601d488 | Michael Hanselmann | cmd.append("--nic-parameters=%s" %
|
195 | 3601d488 | Michael Hanselmann | ",".join(utils.FormatKeyValue(nicparams)))
|
196 | cec9845c | Michael Hanselmann | |
197 | 13d2e231 | Andrea Spadaccini | cmd.append(qa_config.get("name"))
|
198 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd) |
199 | cec9845c | Michael Hanselmann | |
200 | 5abecc1c | Iustin Pop | cmd = ["gnt-cluster", "modify"] |
201 | 13d2e231 | Andrea Spadaccini | |
202 | 5abecc1c | Iustin Pop | # hypervisor parameter modifications
|
203 | 5abecc1c | Iustin Pop | hvp = qa_config.get("hypervisor-parameters", {})
|
204 | 5abecc1c | Iustin Pop | for k, v in hvp.items(): |
205 | 5abecc1c | Iustin Pop | cmd.extend(["-H", "%s:%s" % (k, v)]) |
206 | 5abecc1c | Iustin Pop | # backend parameter modifications
|
207 | 5abecc1c | Iustin Pop | bep = qa_config.get("backend-parameters", "") |
208 | 5abecc1c | Iustin Pop | if bep:
|
209 | 5abecc1c | Iustin Pop | cmd.extend(["-B", bep])
|
210 | 5abecc1c | Iustin Pop | |
211 | 5abecc1c | Iustin Pop | if len(cmd) > 2: |
212 | 5abecc1c | Iustin Pop | AssertCommand(cmd) |
213 | 5abecc1c | Iustin Pop | |
214 | 5abecc1c | Iustin Pop | # OS parameters
|
215 | 5abecc1c | Iustin Pop | osp = qa_config.get("os-parameters", {})
|
216 | 5abecc1c | Iustin Pop | for k, v in osp.items(): |
217 | 5abecc1c | Iustin Pop | AssertCommand(["gnt-os", "modify", "-O", v, k]) |
218 | 5abecc1c | Iustin Pop | |
219 | 5abecc1c | Iustin Pop | # OS hypervisor parameters
|
220 | 5abecc1c | Iustin Pop | os_hvp = qa_config.get("os-hvp", {})
|
221 | 5abecc1c | Iustin Pop | for os_name in os_hvp: |
222 | 5abecc1c | Iustin Pop | for hv, hvp in os_hvp[os_name].items(): |
223 | 5abecc1c | Iustin Pop | AssertCommand(["gnt-os", "modify", "-H", "%s:%s" % (hv, hvp), os_name]) |
224 | 5abecc1c | Iustin Pop | |
225 | cec9845c | Michael Hanselmann | |
226 | caea3b32 | Iustin Pop | def TestClusterRename(): |
227 | caea3b32 | Iustin Pop | """gnt-cluster rename"""
|
228 | d0c8c01d | Iustin Pop | cmd = ["gnt-cluster", "rename", "-f"] |
229 | caea3b32 | Iustin Pop | |
230 | d0c8c01d | Iustin Pop | original_name = qa_config.get("name")
|
231 | d0c8c01d | Iustin Pop | rename_target = qa_config.get("rename", None) |
232 | caea3b32 | Iustin Pop | if rename_target is None: |
233 | caea3b32 | Iustin Pop | print qa_utils.FormatError('"rename" entry is missing') |
234 | caea3b32 | Iustin Pop | return
|
235 | caea3b32 | Iustin Pop | |
236 | 2f4b4f78 | Iustin Pop | for data in [ |
237 | 2f4b4f78 | Iustin Pop | cmd + [rename_target], |
238 | c2a0947d | Iustin Pop | _CLUSTER_VERIFY, |
239 | 2f4b4f78 | Iustin Pop | cmd + [original_name], |
240 | c2a0947d | Iustin Pop | _CLUSTER_VERIFY, |
241 | 2f4b4f78 | Iustin Pop | ]: |
242 | 2f4b4f78 | Iustin Pop | AssertCommand(data) |
243 | caea3b32 | Iustin Pop | |
244 | caea3b32 | Iustin Pop | |
245 | 69df9d2b | Iustin Pop | def TestClusterOob(): |
246 | 69df9d2b | Iustin Pop | """out-of-band framework"""
|
247 | f55312bd | René Nussbaumer | oob_path_exists = "/tmp/ganeti-qa-oob-does-exist-%s" % utils.NewUUID()
|
248 | f55312bd | René Nussbaumer | |
249 | c2a0947d | Iustin Pop | AssertCommand(_CLUSTER_VERIFY) |
250 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "modify", "--node-parameters", |
251 | f55312bd | René Nussbaumer | "oob_program=/tmp/ganeti-qa-oob-does-not-exist-%s" %
|
252 | f55312bd | René Nussbaumer | utils.NewUUID()]) |
253 | f55312bd | René Nussbaumer | |
254 | c2a0947d | Iustin Pop | AssertCommand(_CLUSTER_VERIFY, fail=True)
|
255 | f55312bd | René Nussbaumer | |
256 | 69df9d2b | Iustin Pop | AssertCommand(["touch", oob_path_exists])
|
257 | 69df9d2b | Iustin Pop | AssertCommand(["chmod", "0400", oob_path_exists]) |
258 | 69df9d2b | Iustin Pop | AssertCommand(["gnt-cluster", "copyfile", oob_path_exists]) |
259 | f55312bd | René Nussbaumer | |
260 | f55312bd | René Nussbaumer | try:
|
261 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "modify", "--node-parameters", |
262 | f55312bd | René Nussbaumer | "oob_program=%s" % oob_path_exists])
|
263 | f55312bd | René Nussbaumer | |
264 | c2a0947d | Iustin Pop | AssertCommand(_CLUSTER_VERIFY, fail=True)
|
265 | f55312bd | René Nussbaumer | |
266 | 69df9d2b | Iustin Pop | AssertCommand(["chmod", "0500", oob_path_exists]) |
267 | 69df9d2b | Iustin Pop | AssertCommand(["gnt-cluster", "copyfile", oob_path_exists]) |
268 | f55312bd | René Nussbaumer | |
269 | c2a0947d | Iustin Pop | AssertCommand(_CLUSTER_VERIFY) |
270 | f55312bd | René Nussbaumer | finally:
|
271 | 69df9d2b | Iustin Pop | AssertCommand(["gnt-cluster", "command", "rm", oob_path_exists]) |
272 | f55312bd | René Nussbaumer | |
273 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "modify", "--node-parameters", |
274 | f55312bd | René Nussbaumer | "oob_program="])
|
275 | 69df9d2b | Iustin Pop | |
276 | 69df9d2b | Iustin Pop | |
277 | 66d1f035 | René Nussbaumer | def TestClusterEpo(): |
278 | 66d1f035 | René Nussbaumer | """gnt-cluster epo"""
|
279 | 66d1f035 | René Nussbaumer | master = qa_config.GetMasterNode() |
280 | 66d1f035 | René Nussbaumer | |
281 | 66d1f035 | René Nussbaumer | # Assert that OOB is unavailable for all nodes
|
282 | 66d1f035 | René Nussbaumer | result_output = GetCommandOutput(master["primary"],
|
283 | 58ea8d17 | Michael Hanselmann | "gnt-node list --verbose --no-headers -o"
|
284 | 66d1f035 | René Nussbaumer | " powered")
|
285 | 66d1f035 | René Nussbaumer | AssertEqual(compat.all(powered == "(unavail)"
|
286 | 66d1f035 | René Nussbaumer | for powered in result_output.splitlines()), True) |
287 | 66d1f035 | René Nussbaumer | |
288 | 66d1f035 | René Nussbaumer | # Conflicting
|
289 | 66d1f035 | René Nussbaumer | AssertCommand(["gnt-cluster", "epo", "--groups", "--all"], fail=True) |
290 | 66d1f035 | René Nussbaumer | # --all doesn't expect arguments
|
291 | 66d1f035 | René Nussbaumer | AssertCommand(["gnt-cluster", "epo", "--all", "some_arg"], fail=True) |
292 | 66d1f035 | René Nussbaumer | |
293 | 66d1f035 | René Nussbaumer | # Unless --all is given master is not allowed to be in the list
|
294 | 66d1f035 | René Nussbaumer | AssertCommand(["gnt-cluster", "epo", "-f", master["primary"]], fail=True) |
295 | 66d1f035 | René Nussbaumer | |
296 | 66d1f035 | René Nussbaumer | # This shouldn't fail
|
297 | 66d1f035 | René Nussbaumer | AssertCommand(["gnt-cluster", "epo", "-f", "--all"]) |
298 | 66d1f035 | René Nussbaumer | |
299 | 66d1f035 | René Nussbaumer | # All instances should have been stopped now
|
300 | 66d1f035 | René Nussbaumer | result_output = GetCommandOutput(master["primary"],
|
301 | 58ea8d17 | Michael Hanselmann | "gnt-instance list --no-headers -o status")
|
302 | 3e0ed18c | René Nussbaumer | # ERROR_down because the instance is stopped but not recorded as such
|
303 | 3e0ed18c | René Nussbaumer | AssertEqual(compat.all(status == "ERROR_down"
|
304 | 66d1f035 | René Nussbaumer | for status in result_output.splitlines()), True) |
305 | 66d1f035 | René Nussbaumer | |
306 | 66d1f035 | René Nussbaumer | # Now start everything again
|
307 | 66d1f035 | René Nussbaumer | AssertCommand(["gnt-cluster", "epo", "--on", "-f", "--all"]) |
308 | 66d1f035 | René Nussbaumer | |
309 | 66d1f035 | René Nussbaumer | # All instances should have been started now
|
310 | 66d1f035 | René Nussbaumer | result_output = GetCommandOutput(master["primary"],
|
311 | 58ea8d17 | Michael Hanselmann | "gnt-instance list --no-headers -o status")
|
312 | 66d1f035 | René Nussbaumer | AssertEqual(compat.all(status == "running"
|
313 | 66d1f035 | René Nussbaumer | for status in result_output.splitlines()), True) |
314 | 66d1f035 | René Nussbaumer | |
315 | 66d1f035 | René Nussbaumer | |
316 | 69df9d2b | Iustin Pop | def TestClusterVerify(): |
317 | 69df9d2b | Iustin Pop | """gnt-cluster verify"""
|
318 | c2a0947d | Iustin Pop | AssertCommand(_CLUSTER_VERIFY) |
319 | c6953b6e | Iustin Pop | AssertCommand(["gnt-cluster", "verify-disks"]) |
320 | cec9845c | Michael Hanselmann | |
321 | 1377433b | Michael Hanselmann | |
322 | 1377433b | Michael Hanselmann | def TestJobqueue(): |
323 | 1377433b | Michael Hanselmann | """gnt-debug test-jobqueue"""
|
324 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-debug", "test-jobqueue"]) |
325 | 1377433b | Michael Hanselmann | |
326 | 1377433b | Michael Hanselmann | |
327 | 5a85b99e | Michael Hanselmann | def TestDelay(node): |
328 | 5a85b99e | Michael Hanselmann | """gnt-debug delay"""
|
329 | 5a85b99e | Michael Hanselmann | AssertCommand(["gnt-debug", "delay", "1"]) |
330 | 5a85b99e | Michael Hanselmann | AssertCommand(["gnt-debug", "delay", "--no-master", "1"]) |
331 | 5a85b99e | Michael Hanselmann | AssertCommand(["gnt-debug", "delay", "--no-master", |
332 | 5a85b99e | Michael Hanselmann | "-n", node["primary"], "1"]) |
333 | 5a85b99e | Michael Hanselmann | |
334 | 5a85b99e | Michael Hanselmann | |
335 | 452913ed | Iustin Pop | def TestClusterReservedLvs(): |
336 | 452913ed | Iustin Pop | """gnt-cluster reserved lvs"""
|
337 | 2f4b4f78 | Iustin Pop | for fail, cmd in [ |
338 | c2a0947d | Iustin Pop | (False, _CLUSTER_VERIFY),
|
339 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "--reserved-lvs", ""]), |
340 | 2f4b4f78 | Iustin Pop | (False, ["lvcreate", "-L1G", "-nqa-test", "xenvg"]), |
341 | 21bf2e2e | Andrea Spadaccini | (True, _CLUSTER_VERIFY),
|
342 | 84d7e26b | Dmitry Chernyak | (False, ["gnt-cluster", "modify", "--reserved-lvs", |
343 | 84d7e26b | Dmitry Chernyak | "xenvg/qa-test,.*/other-test"]),
|
344 | c2a0947d | Iustin Pop | (False, _CLUSTER_VERIFY),
|
345 | 84d7e26b | Dmitry Chernyak | (False, ["gnt-cluster", "modify", "--reserved-lvs", ".*/qa-.*"]), |
346 | c2a0947d | Iustin Pop | (False, _CLUSTER_VERIFY),
|
347 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "--reserved-lvs", ""]), |
348 | 21bf2e2e | Andrea Spadaccini | (True, _CLUSTER_VERIFY),
|
349 | 2f4b4f78 | Iustin Pop | (False, ["lvremove", "-f", "xenvg/qa-test"]), |
350 | c2a0947d | Iustin Pop | (False, _CLUSTER_VERIFY),
|
351 | 452913ed | Iustin Pop | ]: |
352 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, fail=fail) |
353 | 452913ed | Iustin Pop | |
354 | cec9845c | Michael Hanselmann | |
355 | 1e7acc3b | Iustin Pop | def TestClusterModifyEmpty(): |
356 | 1e7acc3b | Iustin Pop | """gnt-cluster modify"""
|
357 | 1e7acc3b | Iustin Pop | AssertCommand(["gnt-cluster", "modify"], fail=True) |
358 | 1e7acc3b | Iustin Pop | |
359 | 1e7acc3b | Iustin Pop | |
360 | 92cb4940 | Andrea Spadaccini | def TestClusterModifyDisk(): |
361 | 92cb4940 | Andrea Spadaccini | """gnt-cluster modify -D"""
|
362 | 92cb4940 | Andrea Spadaccini | for param in _FAIL_PARAMS: |
363 | 92cb4940 | Andrea Spadaccini | AssertCommand(["gnt-cluster", "modify", "-D", param], fail=True) |
364 | 92cb4940 | Andrea Spadaccini | |
365 | 92cb4940 | Andrea Spadaccini | |
366 | 9738ca94 | Iustin Pop | def TestClusterModifyBe(): |
367 | 9738ca94 | Iustin Pop | """gnt-cluster modify -B"""
|
368 | 2f4b4f78 | Iustin Pop | for fail, cmd in [ |
369 | 8ccbbe4b | Guido Trotter | # max/min mem
|
370 | 8ccbbe4b | Guido Trotter | (False, ["gnt-cluster", "modify", "-B", "maxmem=256"]), |
371 | 8ccbbe4b | Guido Trotter | (False, ["sh", "-c", "gnt-cluster info|grep '^ *maxmem: 256$'"]), |
372 | 8ccbbe4b | Guido Trotter | (False, ["gnt-cluster", "modify", "-B", "minmem=256"]), |
373 | 8ccbbe4b | Guido Trotter | (False, ["sh", "-c", "gnt-cluster info|grep '^ *minmem: 256$'"]), |
374 | 8ccbbe4b | Guido Trotter | (True, ["gnt-cluster", "modify", "-B", "maxmem=a"]), |
375 | 8ccbbe4b | Guido Trotter | (False, ["sh", "-c", "gnt-cluster info|grep '^ *maxmem: 256$'"]), |
376 | 8ccbbe4b | Guido Trotter | (True, ["gnt-cluster", "modify", "-B", "minmem=a"]), |
377 | 8ccbbe4b | Guido Trotter | (False, ["sh", "-c", "gnt-cluster info|grep '^ *minmem: 256$'"]), |
378 | 8ccbbe4b | Guido Trotter | (False, ["gnt-cluster", "modify", "-B", "maxmem=128,minmem=128"]), |
379 | 8ccbbe4b | Guido Trotter | (False, ["sh", "-c", "gnt-cluster info|grep '^ *maxmem: 128$'"]), |
380 | 8ccbbe4b | Guido Trotter | (False, ["sh", "-c", "gnt-cluster info|grep '^ *minmem: 128$'"]), |
381 | 9738ca94 | Iustin Pop | # vcpus
|
382 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "vcpus=4"]), |
383 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *vcpus: 4$'"]), |
384 | 21bf2e2e | Andrea Spadaccini | (True, ["gnt-cluster", "modify", "-B", "vcpus=a"]), |
385 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "vcpus=1"]), |
386 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *vcpus: 1$'"]), |
387 | 9738ca94 | Iustin Pop | # auto_balance
|
388 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "auto_balance=False"]), |
389 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *auto_balance: False$'"]), |
390 | 21bf2e2e | Andrea Spadaccini | (True, ["gnt-cluster", "modify", "-B", "auto_balance=1"]), |
391 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "auto_balance=True"]), |
392 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *auto_balance: True$'"]), |
393 | 9738ca94 | Iustin Pop | ]: |
394 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, fail=fail) |
395 | 9738ca94 | Iustin Pop | |
396 | 5abecc1c | Iustin Pop | # redo the original-requested BE parameters, if any
|
397 | 5abecc1c | Iustin Pop | bep = qa_config.get("backend-parameters", "") |
398 | 5abecc1c | Iustin Pop | if bep:
|
399 | 5abecc1c | Iustin Pop | AssertCommand(["gnt-cluster", "modify", "-B", bep]) |
400 | 9738ca94 | Iustin Pop | |
401 | 21bf2e2e | Andrea Spadaccini | |
402 | cec9845c | Michael Hanselmann | def TestClusterInfo(): |
403 | cec9845c | Michael Hanselmann | """gnt-cluster info"""
|
404 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "info"]) |
405 | 283f9d4c | Michael Hanselmann | |
406 | 283f9d4c | Michael Hanselmann | |
407 | 3e8b5a9c | Iustin Pop | def TestClusterRedistConf(): |
408 | 3e8b5a9c | Iustin Pop | """gnt-cluster redist-conf"""
|
409 | 3e8b5a9c | Iustin Pop | AssertCommand(["gnt-cluster", "redist-conf"]) |
410 | 3e8b5a9c | Iustin Pop | |
411 | 3e8b5a9c | Iustin Pop | |
412 | 283f9d4c | Michael Hanselmann | def TestClusterGetmaster(): |
413 | 283f9d4c | Michael Hanselmann | """gnt-cluster getmaster"""
|
414 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "getmaster"]) |
415 | 283f9d4c | Michael Hanselmann | |
416 | 283f9d4c | Michael Hanselmann | |
417 | 283f9d4c | Michael Hanselmann | def TestClusterVersion(): |
418 | 283f9d4c | Michael Hanselmann | """gnt-cluster version"""
|
419 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "version"]) |
420 | cec9845c | Michael Hanselmann | |
421 | cec9845c | Michael Hanselmann | |
422 | 6d4a1656 | Michael Hanselmann | def TestClusterRenewCrypto(): |
423 | 6d4a1656 | Michael Hanselmann | """gnt-cluster renew-crypto"""
|
424 | 6d4a1656 | Michael Hanselmann | master = qa_config.GetMasterNode() |
425 | 6d4a1656 | Michael Hanselmann | |
426 | 6d4a1656 | Michael Hanselmann | # Conflicting options
|
427 | 6d4a1656 | Michael Hanselmann | cmd = ["gnt-cluster", "renew-crypto", "--force", |
428 | 3db3eb2a | Michael Hanselmann | "--new-cluster-certificate", "--new-confd-hmac-key"] |
429 | 3db3eb2a | Michael Hanselmann | conflicting = [ |
430 | 3db3eb2a | Michael Hanselmann | ["--new-rapi-certificate", "--rapi-certificate=/dev/null"], |
431 | 3db3eb2a | Michael Hanselmann | ["--new-cluster-domain-secret", "--cluster-domain-secret=/dev/null"], |
432 | 3db3eb2a | Michael Hanselmann | ] |
433 | 3db3eb2a | Michael Hanselmann | for i in conflicting: |
434 | 21bf2e2e | Andrea Spadaccini | AssertCommand(cmd + i, fail=True)
|
435 | 6d4a1656 | Michael Hanselmann | |
436 | 6d4a1656 | Michael Hanselmann | # Invalid RAPI certificate
|
437 | 6d4a1656 | Michael Hanselmann | cmd = ["gnt-cluster", "renew-crypto", "--force", |
438 | 6d4a1656 | Michael Hanselmann | "--rapi-certificate=/dev/null"]
|
439 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, fail=True)
|
440 | 6d4a1656 | Michael Hanselmann | |
441 | 502f5236 | Michael Hanselmann | rapi_cert_backup = qa_utils.BackupFile(master["primary"],
|
442 | 304d9f02 | Michael Hanselmann | pathutils.RAPI_CERT_FILE) |
443 | 502f5236 | Michael Hanselmann | try:
|
444 | 502f5236 | Michael Hanselmann | # Custom RAPI certificate
|
445 | 502f5236 | Michael Hanselmann | fh = tempfile.NamedTemporaryFile() |
446 | 6d4a1656 | Michael Hanselmann | |
447 | 502f5236 | Michael Hanselmann | # Ensure certificate doesn't cause "gnt-cluster verify" to complain
|
448 | 502f5236 | Michael Hanselmann | validity = constants.SSL_CERT_EXPIRATION_WARN * 3
|
449 | 6d4a1656 | Michael Hanselmann | |
450 | 5e26633b | Michael Hanselmann | utils.GenerateSelfSignedSslCert(fh.name, validity=validity) |
451 | 6d4a1656 | Michael Hanselmann | |
452 | 502f5236 | Michael Hanselmann | tmpcert = qa_utils.UploadFile(master["primary"], fh.name)
|
453 | 502f5236 | Michael Hanselmann | try:
|
454 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
455 | 2f4b4f78 | Iustin Pop | "--rapi-certificate=%s" % tmpcert])
|
456 | 502f5236 | Michael Hanselmann | finally:
|
457 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", tmpcert]) |
458 | 502f5236 | Michael Hanselmann | |
459 | 5e26633b | Michael Hanselmann | # Custom cluster domain secret
|
460 | 5e26633b | Michael Hanselmann | cds_fh = tempfile.NamedTemporaryFile() |
461 | 5e26633b | Michael Hanselmann | cds_fh.write(utils.GenerateSecret()) |
462 | 5e26633b | Michael Hanselmann | cds_fh.write("\n")
|
463 | 5e26633b | Michael Hanselmann | cds_fh.flush() |
464 | 5e26633b | Michael Hanselmann | |
465 | 5e26633b | Michael Hanselmann | tmpcds = qa_utils.UploadFile(master["primary"], cds_fh.name)
|
466 | 5e26633b | Michael Hanselmann | try:
|
467 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
468 | 2f4b4f78 | Iustin Pop | "--cluster-domain-secret=%s" % tmpcds])
|
469 | 5e26633b | Michael Hanselmann | finally:
|
470 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", tmpcds]) |
471 | 5e26633b | Michael Hanselmann | |
472 | 502f5236 | Michael Hanselmann | # Normal case
|
473 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
474 | 2f4b4f78 | Iustin Pop | "--new-cluster-certificate", "--new-confd-hmac-key", |
475 | 2f4b4f78 | Iustin Pop | "--new-rapi-certificate", "--new-cluster-domain-secret"]) |
476 | 3db3eb2a | Michael Hanselmann | |
477 | 502f5236 | Michael Hanselmann | # Restore RAPI certificate
|
478 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
479 | 2f4b4f78 | Iustin Pop | "--rapi-certificate=%s" % rapi_cert_backup])
|
480 | 3db3eb2a | Michael Hanselmann | finally:
|
481 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", rapi_cert_backup]) |
482 | 3db3eb2a | Michael Hanselmann | |
483 | 6d4a1656 | Michael Hanselmann | |
484 | cec9845c | Michael Hanselmann | def TestClusterBurnin(): |
485 | cec9845c | Michael Hanselmann | """Burnin"""
|
486 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
487 | cec9845c | Michael Hanselmann | |
488 | d0c8c01d | Iustin Pop | options = qa_config.get("options", {})
|
489 | d0c8c01d | Iustin Pop | disk_template = options.get("burnin-disk-template", "drbd") |
490 | d0c8c01d | Iustin Pop | parallel = options.get("burnin-in-parallel", False) |
491 | d0c8c01d | Iustin Pop | check_inst = options.get("burnin-check-instances", False) |
492 | d0c8c01d | Iustin Pop | do_rename = options.get("burnin-rename", "") |
493 | d0c8c01d | Iustin Pop | do_reboot = options.get("burnin-reboot", True) |
494 | 1d103c02 | Iustin Pop | reboot_types = options.get("reboot-types", constants.REBOOT_TYPES)
|
495 | 23103544 | Michael Hanselmann | |
496 | cec9845c | Michael Hanselmann | # Get as many instances as we need
|
497 | cec9845c | Michael Hanselmann | instances = [] |
498 | cec9845c | Michael Hanselmann | try:
|
499 | 23103544 | Michael Hanselmann | try:
|
500 | d0c8c01d | Iustin Pop | num = qa_config.get("options", {}).get("burnin-instances", 1) |
501 | f1501b3f | Michael Hanselmann | for _ in range(0, num): |
502 | 23103544 | Michael Hanselmann | instances.append(qa_config.AcquireInstance()) |
503 | 23103544 | Michael Hanselmann | except qa_error.OutOfInstancesError:
|
504 | 23103544 | Michael Hanselmann | print "Not enough instances, continuing anyway." |
505 | cec9845c | Michael Hanselmann | |
506 | 23103544 | Michael Hanselmann | if len(instances) < 1: |
507 | 23103544 | Michael Hanselmann | raise qa_error.Error("Burnin needs at least one instance") |
508 | cec9845c | Michael Hanselmann | |
509 | d0c8c01d | Iustin Pop | script = qa_utils.UploadFile(master["primary"], "../tools/burnin") |
510 | cec9845c | Michael Hanselmann | try:
|
511 | 23103544 | Michael Hanselmann | # Run burnin
|
512 | cec9845c | Michael Hanselmann | cmd = [script, |
513 | d0c8c01d | Iustin Pop | "--os=%s" % qa_config.get("os"), |
514 | f356202a | Guido Trotter | "--minmem-size=%s" % qa_config.get(constants.BE_MINMEM),
|
515 | f356202a | Guido Trotter | "--maxmem-size=%s" % qa_config.get(constants.BE_MAXMEM),
|
516 | d0c8c01d | Iustin Pop | "--disk-size=%s" % ",".join(qa_config.get("disk")), |
517 | d0c8c01d | Iustin Pop | "--disk-growth=%s" % ",".join(qa_config.get("disk-growth")), |
518 | d0c8c01d | Iustin Pop | "--disk-template=%s" % disk_template]
|
519 | 0b0a150a | Iustin Pop | if parallel:
|
520 | d0c8c01d | Iustin Pop | cmd.append("--parallel")
|
521 | d0c8c01d | Iustin Pop | cmd.append("--early-release")
|
522 | 0b0a150a | Iustin Pop | if check_inst:
|
523 | d0c8c01d | Iustin Pop | cmd.append("--http-check")
|
524 | 4dc76b24 | Iustin Pop | if do_rename:
|
525 | d0c8c01d | Iustin Pop | cmd.append("--rename=%s" % do_rename)
|
526 | 58598264 | Iustin Pop | if not do_reboot: |
527 | d0c8c01d | Iustin Pop | cmd.append("--no-reboot")
|
528 | 1d103c02 | Iustin Pop | else:
|
529 | d0c8c01d | Iustin Pop | cmd.append("--reboot-types=%s" % ",".join(reboot_types)) |
530 | d0c8c01d | Iustin Pop | cmd += [inst["name"] for inst in instances] |
531 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd) |
532 | cec9845c | Michael Hanselmann | finally:
|
533 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", script]) |
534 | 2f4b4f78 | Iustin Pop | |
535 | cec9845c | Michael Hanselmann | finally:
|
536 | cec9845c | Michael Hanselmann | for inst in instances: |
537 | cec9845c | Michael Hanselmann | qa_config.ReleaseInstance(inst) |
538 | cec9845c | Michael Hanselmann | |
539 | cec9845c | Michael Hanselmann | |
540 | cec9845c | Michael Hanselmann | def TestClusterMasterFailover(): |
541 | c28502b1 | Iustin Pop | """gnt-cluster master-failover"""
|
542 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
543 | cec9845c | Michael Hanselmann | failovermaster = qa_config.AcquireNode(exclude=master) |
544 | cec9845c | Michael Hanselmann | |
545 | 2f4b4f78 | Iustin Pop | cmd = ["gnt-cluster", "master-failover"] |
546 | 2f4b4f78 | Iustin Pop | try:
|
547 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, node=failovermaster) |
548 | ff699aa9 | Michael Hanselmann | # Back to original master node
|
549 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, node=master) |
550 | cec9845c | Michael Hanselmann | finally:
|
551 | cec9845c | Michael Hanselmann | qa_config.ReleaseNode(failovermaster) |
552 | cec9845c | Michael Hanselmann | |
553 | cec9845c | Michael Hanselmann | |
554 | ff699aa9 | Michael Hanselmann | def TestClusterMasterFailoverWithDrainedQueue(): |
555 | ff699aa9 | Michael Hanselmann | """gnt-cluster master-failover with drained queue"""
|
556 | 304d9f02 | Michael Hanselmann | drain_check = ["test", "-f", pathutils.JOB_QUEUE_DRAIN_FILE] |
557 | ff699aa9 | Michael Hanselmann | |
558 | ff699aa9 | Michael Hanselmann | master = qa_config.GetMasterNode() |
559 | ff699aa9 | Michael Hanselmann | failovermaster = qa_config.AcquireNode(exclude=master) |
560 | ff699aa9 | Michael Hanselmann | |
561 | ff699aa9 | Michael Hanselmann | # Ensure queue is not drained
|
562 | ff699aa9 | Michael Hanselmann | for node in [master, failovermaster]: |
563 | ff699aa9 | Michael Hanselmann | AssertCommand(drain_check, node=node, fail=True)
|
564 | ff699aa9 | Michael Hanselmann | |
565 | ff699aa9 | Michael Hanselmann | # Drain queue on failover master
|
566 | 304d9f02 | Michael Hanselmann | AssertCommand(["touch", pathutils.JOB_QUEUE_DRAIN_FILE], node=failovermaster)
|
567 | ff699aa9 | Michael Hanselmann | |
568 | ff699aa9 | Michael Hanselmann | cmd = ["gnt-cluster", "master-failover"] |
569 | ff699aa9 | Michael Hanselmann | try:
|
570 | ff699aa9 | Michael Hanselmann | AssertCommand(drain_check, node=failovermaster) |
571 | ff699aa9 | Michael Hanselmann | AssertCommand(cmd, node=failovermaster) |
572 | ff699aa9 | Michael Hanselmann | AssertCommand(drain_check, fail=True)
|
573 | ff699aa9 | Michael Hanselmann | AssertCommand(drain_check, node=failovermaster, fail=True)
|
574 | ff699aa9 | Michael Hanselmann | |
575 | ff699aa9 | Michael Hanselmann | # Back to original master node
|
576 | ff699aa9 | Michael Hanselmann | AssertCommand(cmd, node=master) |
577 | ff699aa9 | Michael Hanselmann | finally:
|
578 | ff699aa9 | Michael Hanselmann | qa_config.ReleaseNode(failovermaster) |
579 | ff699aa9 | Michael Hanselmann | |
580 | ff699aa9 | Michael Hanselmann | AssertCommand(drain_check, fail=True)
|
581 | ff699aa9 | Michael Hanselmann | AssertCommand(drain_check, node=failovermaster, fail=True)
|
582 | ff699aa9 | Michael Hanselmann | |
583 | ff699aa9 | Michael Hanselmann | |
584 | cec9845c | Michael Hanselmann | def TestClusterCopyfile(): |
585 | cec9845c | Michael Hanselmann | """gnt-cluster copyfile"""
|
586 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
587 | cec9845c | Michael Hanselmann | |
588 | 24818e8f | Michael Hanselmann | uniqueid = utils.NewUUID() |
589 | 830da270 | Michael Hanselmann | |
590 | cec9845c | Michael Hanselmann | # Create temporary file
|
591 | cec9845c | Michael Hanselmann | f = tempfile.NamedTemporaryFile() |
592 | 830da270 | Michael Hanselmann | f.write(uniqueid) |
593 | cec9845c | Michael Hanselmann | f.flush() |
594 | cec9845c | Michael Hanselmann | f.seek(0)
|
595 | cec9845c | Michael Hanselmann | |
596 | cec9845c | Michael Hanselmann | # Upload file to master node
|
597 | d0c8c01d | Iustin Pop | testname = qa_utils.UploadFile(master["primary"], f.name)
|
598 | cec9845c | Michael Hanselmann | try:
|
599 | cec9845c | Michael Hanselmann | # Copy file to all nodes
|
600 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "copyfile", testname]) |
601 | 830da270 | Michael Hanselmann | _CheckFileOnAllNodes(testname, uniqueid) |
602 | cec9845c | Michael Hanselmann | finally:
|
603 | 830da270 | Michael Hanselmann | _RemoveFileFromAllNodes(testname) |
604 | 830da270 | Michael Hanselmann | |
605 | 830da270 | Michael Hanselmann | |
606 | 830da270 | Michael Hanselmann | def TestClusterCommand(): |
607 | 830da270 | Michael Hanselmann | """gnt-cluster command"""
|
608 | 24818e8f | Michael Hanselmann | uniqueid = utils.NewUUID() |
609 | 24818e8f | Michael Hanselmann | rfile = "/tmp/gnt%s" % utils.NewUUID()
|
610 | d0c8c01d | Iustin Pop | rcmd = utils.ShellQuoteArgs(["echo", "-n", uniqueid]) |
611 | d0c8c01d | Iustin Pop | cmd = utils.ShellQuoteArgs(["gnt-cluster", "command", |
612 | 830da270 | Michael Hanselmann | "%s >%s" % (rcmd, rfile)])
|
613 | 830da270 | Michael Hanselmann | |
614 | 830da270 | Michael Hanselmann | try:
|
615 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd) |
616 | 830da270 | Michael Hanselmann | _CheckFileOnAllNodes(rfile, uniqueid) |
617 | 830da270 | Michael Hanselmann | finally:
|
618 | 830da270 | Michael Hanselmann | _RemoveFileFromAllNodes(rfile) |
619 | cec9845c | Michael Hanselmann | |
620 | cec9845c | Michael Hanselmann | |
621 | cec9845c | Michael Hanselmann | def TestClusterDestroy(): |
622 | cec9845c | Michael Hanselmann | """gnt-cluster destroy"""
|
623 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "destroy", "--yes-do-it"]) |
624 | 65a884ef | Iustin Pop | |
625 | 65a884ef | Iustin Pop | |
626 | 65a884ef | Iustin Pop | def TestClusterRepairDiskSizes(): |
627 | 65a884ef | Iustin Pop | """gnt-cluster repair-disk-sizes"""
|
628 | 65a884ef | Iustin Pop | AssertCommand(["gnt-cluster", "repair-disk-sizes"]) |
629 | 50ef6a41 | Bernardo Dal Seno | |
630 | 50ef6a41 | Bernardo Dal Seno | |
631 | 50ef6a41 | Bernardo Dal Seno | def TestSetExclStorCluster(newvalue): |
632 | 50ef6a41 | Bernardo Dal Seno | """Set the exclusive_storage node parameter at the cluster level.
|
633 | 50ef6a41 | Bernardo Dal Seno |
|
634 | 50ef6a41 | Bernardo Dal Seno | @type newvalue: bool
|
635 | 50ef6a41 | Bernardo Dal Seno | @param newvalue: New value of exclusive_storage
|
636 | 50ef6a41 | Bernardo Dal Seno | @rtype: bool
|
637 | 50ef6a41 | Bernardo Dal Seno | @return: The old value of exclusive_storage
|
638 | 50ef6a41 | Bernardo Dal Seno |
|
639 | 50ef6a41 | Bernardo Dal Seno | """
|
640 | 50ef6a41 | Bernardo Dal Seno | oldvalue = _GetBoolClusterField("exclusive_storage")
|
641 | 50ef6a41 | Bernardo Dal Seno | AssertCommand(["gnt-cluster", "modify", "--node-parameters", |
642 | 50ef6a41 | Bernardo Dal Seno | "exclusive_storage=%s" % newvalue])
|
643 | 50ef6a41 | Bernardo Dal Seno | effvalue = _GetBoolClusterField("exclusive_storage")
|
644 | 50ef6a41 | Bernardo Dal Seno | if effvalue != newvalue:
|
645 | 50ef6a41 | Bernardo Dal Seno | raise qa_error.Error("exclusive_storage has the wrong value: %s instead" |
646 | 50ef6a41 | Bernardo Dal Seno | " of %s" % (effvalue, newvalue))
|
647 | 50ef6a41 | Bernardo Dal Seno | return oldvalue
|
648 | e8b919a1 | Bernardo Dal Seno | |
649 | e8b919a1 | Bernardo Dal Seno | |
650 | e8b919a1 | Bernardo Dal Seno | def _BuildSetESCmd(value, node_name): |
651 | e8b919a1 | Bernardo Dal Seno | return ["gnt-node", "modify", "--node-parameters", |
652 | e8b919a1 | Bernardo Dal Seno | "exclusive_storage=%s" % value, node_name]
|
653 | e8b919a1 | Bernardo Dal Seno | |
654 | e8b919a1 | Bernardo Dal Seno | |
655 | e8b919a1 | Bernardo Dal Seno | def TestExclStorSingleNode(node): |
656 | e8b919a1 | Bernardo Dal Seno | """cluster-verify reports exclusive_storage set only on one node.
|
657 | e8b919a1 | Bernardo Dal Seno |
|
658 | e8b919a1 | Bernardo Dal Seno | """
|
659 | e8b919a1 | Bernardo Dal Seno | node_name = node["primary"]
|
660 | e8b919a1 | Bernardo Dal Seno | es_val = _GetBoolClusterField("exclusive_storage")
|
661 | e8b919a1 | Bernardo Dal Seno | assert not es_val |
662 | e8b919a1 | Bernardo Dal Seno | AssertCommand(_BuildSetESCmd(True, node_name))
|
663 | e8b919a1 | Bernardo Dal Seno | AssertClusterVerify(fail=True, errors=[constants.CV_EGROUPMIXEDESFLAG])
|
664 | e8b919a1 | Bernardo Dal Seno | AssertCommand(_BuildSetESCmd("default", node_name))
|
665 | e8b919a1 | Bernardo Dal Seno | AssertClusterVerify() |