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