root / qa / qa_cluster.py @ 68c8c3df
History | View | Annotate | Download (21.5 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 | becf9d5c | Michael Hanselmann | extra_args = qa_config.get("cluster-init-args")
|
213 | becf9d5c | Michael Hanselmann | if extra_args:
|
214 | becf9d5c | Michael Hanselmann | cmd.extend(extra_args) |
215 | becf9d5c | Michael Hanselmann | |
216 | 13d2e231 | Andrea Spadaccini | cmd.append(qa_config.get("name"))
|
217 | becf9d5c | Michael Hanselmann | |
218 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd) |
219 | cec9845c | Michael Hanselmann | |
220 | 5abecc1c | Iustin Pop | cmd = ["gnt-cluster", "modify"] |
221 | 13d2e231 | Andrea Spadaccini | |
222 | 5abecc1c | Iustin Pop | # hypervisor parameter modifications
|
223 | 5abecc1c | Iustin Pop | hvp = qa_config.get("hypervisor-parameters", {})
|
224 | 5abecc1c | Iustin Pop | for k, v in hvp.items(): |
225 | 5abecc1c | Iustin Pop | cmd.extend(["-H", "%s:%s" % (k, v)]) |
226 | 5abecc1c | Iustin Pop | # backend parameter modifications
|
227 | 5abecc1c | Iustin Pop | bep = qa_config.get("backend-parameters", "") |
228 | 5abecc1c | Iustin Pop | if bep:
|
229 | 5abecc1c | Iustin Pop | cmd.extend(["-B", bep])
|
230 | 5abecc1c | Iustin Pop | |
231 | 5abecc1c | Iustin Pop | if len(cmd) > 2: |
232 | 5abecc1c | Iustin Pop | AssertCommand(cmd) |
233 | 5abecc1c | Iustin Pop | |
234 | 5abecc1c | Iustin Pop | # OS parameters
|
235 | 5abecc1c | Iustin Pop | osp = qa_config.get("os-parameters", {})
|
236 | 5abecc1c | Iustin Pop | for k, v in osp.items(): |
237 | 5abecc1c | Iustin Pop | AssertCommand(["gnt-os", "modify", "-O", v, k]) |
238 | 5abecc1c | Iustin Pop | |
239 | 5abecc1c | Iustin Pop | # OS hypervisor parameters
|
240 | 5abecc1c | Iustin Pop | os_hvp = qa_config.get("os-hvp", {})
|
241 | 5abecc1c | Iustin Pop | for os_name in os_hvp: |
242 | 5abecc1c | Iustin Pop | for hv, hvp in os_hvp[os_name].items(): |
243 | 5abecc1c | Iustin Pop | AssertCommand(["gnt-os", "modify", "-H", "%s:%s" % (hv, hvp), os_name]) |
244 | 5abecc1c | Iustin Pop | |
245 | cec9845c | Michael Hanselmann | |
246 | caea3b32 | Iustin Pop | def TestClusterRename(): |
247 | caea3b32 | Iustin Pop | """gnt-cluster rename"""
|
248 | d0c8c01d | Iustin Pop | cmd = ["gnt-cluster", "rename", "-f"] |
249 | caea3b32 | Iustin Pop | |
250 | d0c8c01d | Iustin Pop | original_name = qa_config.get("name")
|
251 | d0c8c01d | Iustin Pop | rename_target = qa_config.get("rename", None) |
252 | caea3b32 | Iustin Pop | if rename_target is None: |
253 | caea3b32 | Iustin Pop | print qa_utils.FormatError('"rename" entry is missing') |
254 | caea3b32 | Iustin Pop | return
|
255 | caea3b32 | Iustin Pop | |
256 | 2f4b4f78 | Iustin Pop | for data in [ |
257 | 2f4b4f78 | Iustin Pop | cmd + [rename_target], |
258 | c2a0947d | Iustin Pop | _CLUSTER_VERIFY, |
259 | 2f4b4f78 | Iustin Pop | cmd + [original_name], |
260 | c2a0947d | Iustin Pop | _CLUSTER_VERIFY, |
261 | 2f4b4f78 | Iustin Pop | ]: |
262 | 2f4b4f78 | Iustin Pop | AssertCommand(data) |
263 | caea3b32 | Iustin Pop | |
264 | caea3b32 | Iustin Pop | |
265 | 69df9d2b | Iustin Pop | def TestClusterOob(): |
266 | 69df9d2b | Iustin Pop | """out-of-band framework"""
|
267 | f55312bd | René Nussbaumer | oob_path_exists = "/tmp/ganeti-qa-oob-does-exist-%s" % utils.NewUUID()
|
268 | f55312bd | René Nussbaumer | |
269 | c2a0947d | Iustin Pop | AssertCommand(_CLUSTER_VERIFY) |
270 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "modify", "--node-parameters", |
271 | f55312bd | René Nussbaumer | "oob_program=/tmp/ganeti-qa-oob-does-not-exist-%s" %
|
272 | f55312bd | René Nussbaumer | utils.NewUUID()]) |
273 | f55312bd | René Nussbaumer | |
274 | c2a0947d | Iustin Pop | AssertCommand(_CLUSTER_VERIFY, fail=True)
|
275 | f55312bd | René Nussbaumer | |
276 | 69df9d2b | Iustin Pop | AssertCommand(["touch", oob_path_exists])
|
277 | 69df9d2b | Iustin Pop | AssertCommand(["chmod", "0400", oob_path_exists]) |
278 | 69df9d2b | Iustin Pop | AssertCommand(["gnt-cluster", "copyfile", oob_path_exists]) |
279 | f55312bd | René Nussbaumer | |
280 | f55312bd | René Nussbaumer | try:
|
281 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "modify", "--node-parameters", |
282 | f55312bd | René Nussbaumer | "oob_program=%s" % oob_path_exists])
|
283 | f55312bd | René Nussbaumer | |
284 | c2a0947d | Iustin Pop | AssertCommand(_CLUSTER_VERIFY, fail=True)
|
285 | f55312bd | René Nussbaumer | |
286 | 69df9d2b | Iustin Pop | AssertCommand(["chmod", "0500", oob_path_exists]) |
287 | 69df9d2b | Iustin Pop | AssertCommand(["gnt-cluster", "copyfile", oob_path_exists]) |
288 | f55312bd | René Nussbaumer | |
289 | c2a0947d | Iustin Pop | AssertCommand(_CLUSTER_VERIFY) |
290 | f55312bd | René Nussbaumer | finally:
|
291 | 69df9d2b | Iustin Pop | AssertCommand(["gnt-cluster", "command", "rm", oob_path_exists]) |
292 | f55312bd | René Nussbaumer | |
293 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "modify", "--node-parameters", |
294 | f55312bd | René Nussbaumer | "oob_program="])
|
295 | 69df9d2b | Iustin Pop | |
296 | 69df9d2b | Iustin Pop | |
297 | 66d1f035 | René Nussbaumer | def TestClusterEpo(): |
298 | 66d1f035 | René Nussbaumer | """gnt-cluster epo"""
|
299 | 66d1f035 | René Nussbaumer | master = qa_config.GetMasterNode() |
300 | 66d1f035 | René Nussbaumer | |
301 | 66d1f035 | René Nussbaumer | # Assert that OOB is unavailable for all nodes
|
302 | aecba21e | Michael Hanselmann | result_output = GetCommandOutput(master.primary, |
303 | 58ea8d17 | Michael Hanselmann | "gnt-node list --verbose --no-headers -o"
|
304 | 66d1f035 | René Nussbaumer | " powered")
|
305 | 66d1f035 | René Nussbaumer | AssertEqual(compat.all(powered == "(unavail)"
|
306 | 66d1f035 | René Nussbaumer | for powered in result_output.splitlines()), True) |
307 | 66d1f035 | René Nussbaumer | |
308 | 66d1f035 | René Nussbaumer | # Conflicting
|
309 | 66d1f035 | René Nussbaumer | AssertCommand(["gnt-cluster", "epo", "--groups", "--all"], fail=True) |
310 | 66d1f035 | René Nussbaumer | # --all doesn't expect arguments
|
311 | 66d1f035 | René Nussbaumer | AssertCommand(["gnt-cluster", "epo", "--all", "some_arg"], fail=True) |
312 | 66d1f035 | René Nussbaumer | |
313 | 66d1f035 | René Nussbaumer | # Unless --all is given master is not allowed to be in the list
|
314 | aecba21e | Michael Hanselmann | AssertCommand(["gnt-cluster", "epo", "-f", master.primary], fail=True) |
315 | 66d1f035 | René Nussbaumer | |
316 | 66d1f035 | René Nussbaumer | # This shouldn't fail
|
317 | 66d1f035 | René Nussbaumer | AssertCommand(["gnt-cluster", "epo", "-f", "--all"]) |
318 | 66d1f035 | René Nussbaumer | |
319 | 66d1f035 | René Nussbaumer | # All instances should have been stopped now
|
320 | aecba21e | Michael Hanselmann | result_output = GetCommandOutput(master.primary, |
321 | 58ea8d17 | Michael Hanselmann | "gnt-instance list --no-headers -o status")
|
322 | 3e0ed18c | René Nussbaumer | # ERROR_down because the instance is stopped but not recorded as such
|
323 | 3e0ed18c | René Nussbaumer | AssertEqual(compat.all(status == "ERROR_down"
|
324 | 66d1f035 | René Nussbaumer | for status in result_output.splitlines()), True) |
325 | 66d1f035 | René Nussbaumer | |
326 | 66d1f035 | René Nussbaumer | # Now start everything again
|
327 | 66d1f035 | René Nussbaumer | AssertCommand(["gnt-cluster", "epo", "--on", "-f", "--all"]) |
328 | 66d1f035 | René Nussbaumer | |
329 | 66d1f035 | René Nussbaumer | # All instances should have been started now
|
330 | aecba21e | Michael Hanselmann | result_output = GetCommandOutput(master.primary, |
331 | 58ea8d17 | Michael Hanselmann | "gnt-instance list --no-headers -o status")
|
332 | 66d1f035 | René Nussbaumer | AssertEqual(compat.all(status == "running"
|
333 | 66d1f035 | René Nussbaumer | for status in result_output.splitlines()), True) |
334 | 66d1f035 | René Nussbaumer | |
335 | 66d1f035 | René Nussbaumer | |
336 | 69df9d2b | Iustin Pop | def TestClusterVerify(): |
337 | 69df9d2b | Iustin Pop | """gnt-cluster verify"""
|
338 | c2a0947d | Iustin Pop | AssertCommand(_CLUSTER_VERIFY) |
339 | c6953b6e | Iustin Pop | AssertCommand(["gnt-cluster", "verify-disks"]) |
340 | cec9845c | Michael Hanselmann | |
341 | 1377433b | Michael Hanselmann | |
342 | 1377433b | Michael Hanselmann | def TestJobqueue(): |
343 | 1377433b | Michael Hanselmann | """gnt-debug test-jobqueue"""
|
344 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-debug", "test-jobqueue"]) |
345 | 1377433b | Michael Hanselmann | |
346 | 1377433b | Michael Hanselmann | |
347 | 5a85b99e | Michael Hanselmann | def TestDelay(node): |
348 | 5a85b99e | Michael Hanselmann | """gnt-debug delay"""
|
349 | 5a85b99e | Michael Hanselmann | AssertCommand(["gnt-debug", "delay", "1"]) |
350 | 5a85b99e | Michael Hanselmann | AssertCommand(["gnt-debug", "delay", "--no-master", "1"]) |
351 | 5a85b99e | Michael Hanselmann | AssertCommand(["gnt-debug", "delay", "--no-master", |
352 | aecba21e | Michael Hanselmann | "-n", node.primary, "1"]) |
353 | 5a85b99e | Michael Hanselmann | |
354 | 5a85b99e | Michael Hanselmann | |
355 | 452913ed | Iustin Pop | def TestClusterReservedLvs(): |
356 | 452913ed | Iustin Pop | """gnt-cluster reserved lvs"""
|
357 | 23610ff8 | Bernardo Dal Seno | vgname = qa_config.get("vg-name", constants.DEFAULT_VG)
|
358 | 23610ff8 | Bernardo Dal Seno | lvname = _QA_LV_PREFIX + "test"
|
359 | 23610ff8 | Bernardo Dal Seno | lvfullname = "/".join([vgname, lvname])
|
360 | 2f4b4f78 | Iustin Pop | for fail, cmd in [ |
361 | c2a0947d | Iustin Pop | (False, _CLUSTER_VERIFY),
|
362 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "--reserved-lvs", ""]), |
363 | 23610ff8 | Bernardo Dal Seno | (False, ["lvcreate", "-L1G", "-n", lvname, vgname]), |
364 | 21bf2e2e | Andrea Spadaccini | (True, _CLUSTER_VERIFY),
|
365 | 84d7e26b | Dmitry Chernyak | (False, ["gnt-cluster", "modify", "--reserved-lvs", |
366 | 23610ff8 | Bernardo Dal Seno | "%s,.*/other-test" % lvfullname]),
|
367 | c2a0947d | Iustin Pop | (False, _CLUSTER_VERIFY),
|
368 | 23610ff8 | Bernardo Dal Seno | (False, ["gnt-cluster", "modify", "--reserved-lvs", |
369 | 23610ff8 | Bernardo Dal Seno | ".*/%s.*" % _QA_LV_PREFIX]),
|
370 | c2a0947d | Iustin Pop | (False, _CLUSTER_VERIFY),
|
371 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "--reserved-lvs", ""]), |
372 | 21bf2e2e | Andrea Spadaccini | (True, _CLUSTER_VERIFY),
|
373 | 23610ff8 | Bernardo Dal Seno | (False, ["lvremove", "-f", lvfullname]), |
374 | c2a0947d | Iustin Pop | (False, _CLUSTER_VERIFY),
|
375 | 452913ed | Iustin Pop | ]: |
376 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, fail=fail) |
377 | 452913ed | Iustin Pop | |
378 | cec9845c | Michael Hanselmann | |
379 | 1e7acc3b | Iustin Pop | def TestClusterModifyEmpty(): |
380 | 1e7acc3b | Iustin Pop | """gnt-cluster modify"""
|
381 | 1e7acc3b | Iustin Pop | AssertCommand(["gnt-cluster", "modify"], fail=True) |
382 | 1e7acc3b | Iustin Pop | |
383 | 1e7acc3b | Iustin Pop | |
384 | 92cb4940 | Andrea Spadaccini | def TestClusterModifyDisk(): |
385 | 92cb4940 | Andrea Spadaccini | """gnt-cluster modify -D"""
|
386 | 92cb4940 | Andrea Spadaccini | for param in _FAIL_PARAMS: |
387 | 92cb4940 | Andrea Spadaccini | AssertCommand(["gnt-cluster", "modify", "-D", param], fail=True) |
388 | 92cb4940 | Andrea Spadaccini | |
389 | 92cb4940 | Andrea Spadaccini | |
390 | 9738ca94 | Iustin Pop | def TestClusterModifyBe(): |
391 | 9738ca94 | Iustin Pop | """gnt-cluster modify -B"""
|
392 | 2f4b4f78 | Iustin Pop | for fail, cmd in [ |
393 | 8ccbbe4b | Guido Trotter | # max/min mem
|
394 | 8ccbbe4b | Guido Trotter | (False, ["gnt-cluster", "modify", "-B", "maxmem=256"]), |
395 | 8ccbbe4b | Guido Trotter | (False, ["sh", "-c", "gnt-cluster info|grep '^ *maxmem: 256$'"]), |
396 | 8ccbbe4b | Guido Trotter | (False, ["gnt-cluster", "modify", "-B", "minmem=256"]), |
397 | 8ccbbe4b | Guido Trotter | (False, ["sh", "-c", "gnt-cluster info|grep '^ *minmem: 256$'"]), |
398 | 8ccbbe4b | Guido Trotter | (True, ["gnt-cluster", "modify", "-B", "maxmem=a"]), |
399 | 8ccbbe4b | Guido Trotter | (False, ["sh", "-c", "gnt-cluster info|grep '^ *maxmem: 256$'"]), |
400 | 8ccbbe4b | Guido Trotter | (True, ["gnt-cluster", "modify", "-B", "minmem=a"]), |
401 | 8ccbbe4b | Guido Trotter | (False, ["sh", "-c", "gnt-cluster info|grep '^ *minmem: 256$'"]), |
402 | 8ccbbe4b | Guido Trotter | (False, ["gnt-cluster", "modify", "-B", "maxmem=128,minmem=128"]), |
403 | 8ccbbe4b | Guido Trotter | (False, ["sh", "-c", "gnt-cluster info|grep '^ *maxmem: 128$'"]), |
404 | 8ccbbe4b | Guido Trotter | (False, ["sh", "-c", "gnt-cluster info|grep '^ *minmem: 128$'"]), |
405 | 9738ca94 | Iustin Pop | # vcpus
|
406 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "vcpus=4"]), |
407 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *vcpus: 4$'"]), |
408 | 21bf2e2e | Andrea Spadaccini | (True, ["gnt-cluster", "modify", "-B", "vcpus=a"]), |
409 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "vcpus=1"]), |
410 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *vcpus: 1$'"]), |
411 | 9738ca94 | Iustin Pop | # auto_balance
|
412 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "auto_balance=False"]), |
413 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *auto_balance: False$'"]), |
414 | 21bf2e2e | Andrea Spadaccini | (True, ["gnt-cluster", "modify", "-B", "auto_balance=1"]), |
415 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "auto_balance=True"]), |
416 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *auto_balance: True$'"]), |
417 | 9738ca94 | Iustin Pop | ]: |
418 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, fail=fail) |
419 | 9738ca94 | Iustin Pop | |
420 | 5abecc1c | Iustin Pop | # redo the original-requested BE parameters, if any
|
421 | 5abecc1c | Iustin Pop | bep = qa_config.get("backend-parameters", "") |
422 | 5abecc1c | Iustin Pop | if bep:
|
423 | 5abecc1c | Iustin Pop | AssertCommand(["gnt-cluster", "modify", "-B", bep]) |
424 | 9738ca94 | Iustin Pop | |
425 | 21bf2e2e | Andrea Spadaccini | |
426 | cec9845c | Michael Hanselmann | def TestClusterInfo(): |
427 | cec9845c | Michael Hanselmann | """gnt-cluster info"""
|
428 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "info"]) |
429 | 283f9d4c | Michael Hanselmann | |
430 | 283f9d4c | Michael Hanselmann | |
431 | 3e8b5a9c | Iustin Pop | def TestClusterRedistConf(): |
432 | 3e8b5a9c | Iustin Pop | """gnt-cluster redist-conf"""
|
433 | 3e8b5a9c | Iustin Pop | AssertCommand(["gnt-cluster", "redist-conf"]) |
434 | 3e8b5a9c | Iustin Pop | |
435 | 3e8b5a9c | Iustin Pop | |
436 | 283f9d4c | Michael Hanselmann | def TestClusterGetmaster(): |
437 | 283f9d4c | Michael Hanselmann | """gnt-cluster getmaster"""
|
438 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "getmaster"]) |
439 | 283f9d4c | Michael Hanselmann | |
440 | 283f9d4c | Michael Hanselmann | |
441 | 283f9d4c | Michael Hanselmann | def TestClusterVersion(): |
442 | 283f9d4c | Michael Hanselmann | """gnt-cluster version"""
|
443 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "version"]) |
444 | cec9845c | Michael Hanselmann | |
445 | cec9845c | Michael Hanselmann | |
446 | 6d4a1656 | Michael Hanselmann | def TestClusterRenewCrypto(): |
447 | 6d4a1656 | Michael Hanselmann | """gnt-cluster renew-crypto"""
|
448 | 6d4a1656 | Michael Hanselmann | master = qa_config.GetMasterNode() |
449 | 6d4a1656 | Michael Hanselmann | |
450 | 6d4a1656 | Michael Hanselmann | # Conflicting options
|
451 | 6d4a1656 | Michael Hanselmann | cmd = ["gnt-cluster", "renew-crypto", "--force", |
452 | 3db3eb2a | Michael Hanselmann | "--new-cluster-certificate", "--new-confd-hmac-key"] |
453 | 3db3eb2a | Michael Hanselmann | conflicting = [ |
454 | 3db3eb2a | Michael Hanselmann | ["--new-rapi-certificate", "--rapi-certificate=/dev/null"], |
455 | 3db3eb2a | Michael Hanselmann | ["--new-cluster-domain-secret", "--cluster-domain-secret=/dev/null"], |
456 | 3db3eb2a | Michael Hanselmann | ] |
457 | 3db3eb2a | Michael Hanselmann | for i in conflicting: |
458 | 21bf2e2e | Andrea Spadaccini | AssertCommand(cmd + i, fail=True)
|
459 | 6d4a1656 | Michael Hanselmann | |
460 | 6d4a1656 | Michael Hanselmann | # Invalid RAPI certificate
|
461 | 6d4a1656 | Michael Hanselmann | cmd = ["gnt-cluster", "renew-crypto", "--force", |
462 | 6d4a1656 | Michael Hanselmann | "--rapi-certificate=/dev/null"]
|
463 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, fail=True)
|
464 | 6d4a1656 | Michael Hanselmann | |
465 | aecba21e | Michael Hanselmann | rapi_cert_backup = qa_utils.BackupFile(master.primary, |
466 | 304d9f02 | Michael Hanselmann | pathutils.RAPI_CERT_FILE) |
467 | 502f5236 | Michael Hanselmann | try:
|
468 | 502f5236 | Michael Hanselmann | # Custom RAPI certificate
|
469 | 502f5236 | Michael Hanselmann | fh = tempfile.NamedTemporaryFile() |
470 | 6d4a1656 | Michael Hanselmann | |
471 | 502f5236 | Michael Hanselmann | # Ensure certificate doesn't cause "gnt-cluster verify" to complain
|
472 | 502f5236 | Michael Hanselmann | validity = constants.SSL_CERT_EXPIRATION_WARN * 3
|
473 | 6d4a1656 | Michael Hanselmann | |
474 | 5e26633b | Michael Hanselmann | utils.GenerateSelfSignedSslCert(fh.name, validity=validity) |
475 | 6d4a1656 | Michael Hanselmann | |
476 | aecba21e | Michael Hanselmann | tmpcert = qa_utils.UploadFile(master.primary, fh.name) |
477 | 502f5236 | Michael Hanselmann | try:
|
478 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
479 | 2f4b4f78 | Iustin Pop | "--rapi-certificate=%s" % tmpcert])
|
480 | 502f5236 | Michael Hanselmann | finally:
|
481 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", tmpcert]) |
482 | 502f5236 | Michael Hanselmann | |
483 | 5e26633b | Michael Hanselmann | # Custom cluster domain secret
|
484 | 5e26633b | Michael Hanselmann | cds_fh = tempfile.NamedTemporaryFile() |
485 | 5e26633b | Michael Hanselmann | cds_fh.write(utils.GenerateSecret()) |
486 | 5e26633b | Michael Hanselmann | cds_fh.write("\n")
|
487 | 5e26633b | Michael Hanselmann | cds_fh.flush() |
488 | 5e26633b | Michael Hanselmann | |
489 | aecba21e | Michael Hanselmann | tmpcds = qa_utils.UploadFile(master.primary, cds_fh.name) |
490 | 5e26633b | Michael Hanselmann | try:
|
491 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
492 | 2f4b4f78 | Iustin Pop | "--cluster-domain-secret=%s" % tmpcds])
|
493 | 5e26633b | Michael Hanselmann | finally:
|
494 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", tmpcds]) |
495 | 5e26633b | Michael Hanselmann | |
496 | 502f5236 | Michael Hanselmann | # Normal case
|
497 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
498 | 2f4b4f78 | Iustin Pop | "--new-cluster-certificate", "--new-confd-hmac-key", |
499 | 2f4b4f78 | Iustin Pop | "--new-rapi-certificate", "--new-cluster-domain-secret"]) |
500 | 3db3eb2a | Michael Hanselmann | |
501 | 502f5236 | Michael Hanselmann | # Restore RAPI certificate
|
502 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
503 | 2f4b4f78 | Iustin Pop | "--rapi-certificate=%s" % rapi_cert_backup])
|
504 | 3db3eb2a | Michael Hanselmann | finally:
|
505 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", rapi_cert_backup]) |
506 | 3db3eb2a | Michael Hanselmann | |
507 | 6d4a1656 | Michael Hanselmann | |
508 | cec9845c | Michael Hanselmann | def TestClusterBurnin(): |
509 | cec9845c | Michael Hanselmann | """Burnin"""
|
510 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
511 | cec9845c | Michael Hanselmann | |
512 | d0c8c01d | Iustin Pop | options = qa_config.get("options", {})
|
513 | 68c8c3df | Michael Hanselmann | disk_template = options.get("burnin-disk-template", constants.DT_DRBD8)
|
514 | d0c8c01d | Iustin Pop | parallel = options.get("burnin-in-parallel", False) |
515 | d0c8c01d | Iustin Pop | check_inst = options.get("burnin-check-instances", False) |
516 | d0c8c01d | Iustin Pop | do_rename = options.get("burnin-rename", "") |
517 | d0c8c01d | Iustin Pop | do_reboot = options.get("burnin-reboot", True) |
518 | 1d103c02 | Iustin Pop | reboot_types = options.get("reboot-types", constants.REBOOT_TYPES)
|
519 | 23103544 | Michael Hanselmann | |
520 | cec9845c | Michael Hanselmann | # Get as many instances as we need
|
521 | cec9845c | Michael Hanselmann | instances = [] |
522 | cec9845c | Michael Hanselmann | try:
|
523 | 23103544 | Michael Hanselmann | try:
|
524 | d0c8c01d | Iustin Pop | num = qa_config.get("options", {}).get("burnin-instances", 1) |
525 | f1501b3f | Michael Hanselmann | for _ in range(0, num): |
526 | 23103544 | Michael Hanselmann | instances.append(qa_config.AcquireInstance()) |
527 | 23103544 | Michael Hanselmann | except qa_error.OutOfInstancesError:
|
528 | 23103544 | Michael Hanselmann | print "Not enough instances, continuing anyway." |
529 | cec9845c | Michael Hanselmann | |
530 | 23103544 | Michael Hanselmann | if len(instances) < 1: |
531 | 23103544 | Michael Hanselmann | raise qa_error.Error("Burnin needs at least one instance") |
532 | cec9845c | Michael Hanselmann | |
533 | aecba21e | Michael Hanselmann | script = qa_utils.UploadFile(master.primary, "../tools/burnin")
|
534 | cec9845c | Michael Hanselmann | try:
|
535 | 23103544 | Michael Hanselmann | # Run burnin
|
536 | cec9845c | Michael Hanselmann | cmd = [script, |
537 | d0c8c01d | Iustin Pop | "--os=%s" % qa_config.get("os"), |
538 | f356202a | Guido Trotter | "--minmem-size=%s" % qa_config.get(constants.BE_MINMEM),
|
539 | f356202a | Guido Trotter | "--maxmem-size=%s" % qa_config.get(constants.BE_MAXMEM),
|
540 | d0c8c01d | Iustin Pop | "--disk-size=%s" % ",".join(qa_config.get("disk")), |
541 | d0c8c01d | Iustin Pop | "--disk-growth=%s" % ",".join(qa_config.get("disk-growth")), |
542 | d0c8c01d | Iustin Pop | "--disk-template=%s" % disk_template]
|
543 | 0b0a150a | Iustin Pop | if parallel:
|
544 | d0c8c01d | Iustin Pop | cmd.append("--parallel")
|
545 | d0c8c01d | Iustin Pop | cmd.append("--early-release")
|
546 | 0b0a150a | Iustin Pop | if check_inst:
|
547 | d0c8c01d | Iustin Pop | cmd.append("--http-check")
|
548 | 4dc76b24 | Iustin Pop | if do_rename:
|
549 | d0c8c01d | Iustin Pop | cmd.append("--rename=%s" % do_rename)
|
550 | 58598264 | Iustin Pop | if not do_reboot: |
551 | d0c8c01d | Iustin Pop | cmd.append("--no-reboot")
|
552 | 1d103c02 | Iustin Pop | else:
|
553 | d0c8c01d | Iustin Pop | cmd.append("--reboot-types=%s" % ",".join(reboot_types)) |
554 | b5f33afa | Michael Hanselmann | cmd += [inst.name for inst in instances] |
555 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd) |
556 | cec9845c | Michael Hanselmann | finally:
|
557 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", script]) |
558 | 2f4b4f78 | Iustin Pop | |
559 | cec9845c | Michael Hanselmann | finally:
|
560 | cec9845c | Michael Hanselmann | for inst in instances: |
561 | 6f88e076 | Michael Hanselmann | inst.Release() |
562 | cec9845c | Michael Hanselmann | |
563 | cec9845c | Michael Hanselmann | |
564 | cec9845c | Michael Hanselmann | def TestClusterMasterFailover(): |
565 | c28502b1 | Iustin Pop | """gnt-cluster master-failover"""
|
566 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
567 | cec9845c | Michael Hanselmann | failovermaster = qa_config.AcquireNode(exclude=master) |
568 | cec9845c | Michael Hanselmann | |
569 | 2f4b4f78 | Iustin Pop | cmd = ["gnt-cluster", "master-failover"] |
570 | 2f4b4f78 | Iustin Pop | try:
|
571 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, node=failovermaster) |
572 | ff699aa9 | Michael Hanselmann | # Back to original master node
|
573 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, node=master) |
574 | cec9845c | Michael Hanselmann | finally:
|
575 | 565cb4bf | Michael Hanselmann | failovermaster.Release() |
576 | cec9845c | Michael Hanselmann | |
577 | cec9845c | Michael Hanselmann | |
578 | ff699aa9 | Michael Hanselmann | def TestClusterMasterFailoverWithDrainedQueue(): |
579 | ff699aa9 | Michael Hanselmann | """gnt-cluster master-failover with drained queue"""
|
580 | 304d9f02 | Michael Hanselmann | drain_check = ["test", "-f", pathutils.JOB_QUEUE_DRAIN_FILE] |
581 | ff699aa9 | Michael Hanselmann | |
582 | ff699aa9 | Michael Hanselmann | master = qa_config.GetMasterNode() |
583 | ff699aa9 | Michael Hanselmann | failovermaster = qa_config.AcquireNode(exclude=master) |
584 | ff699aa9 | Michael Hanselmann | |
585 | ff699aa9 | Michael Hanselmann | # Ensure queue is not drained
|
586 | ff699aa9 | Michael Hanselmann | for node in [master, failovermaster]: |
587 | ff699aa9 | Michael Hanselmann | AssertCommand(drain_check, node=node, fail=True)
|
588 | ff699aa9 | Michael Hanselmann | |
589 | ff699aa9 | Michael Hanselmann | # Drain queue on failover master
|
590 | 304d9f02 | Michael Hanselmann | AssertCommand(["touch", pathutils.JOB_QUEUE_DRAIN_FILE], node=failovermaster)
|
591 | ff699aa9 | Michael Hanselmann | |
592 | ff699aa9 | Michael Hanselmann | cmd = ["gnt-cluster", "master-failover"] |
593 | ff699aa9 | Michael Hanselmann | try:
|
594 | ff699aa9 | Michael Hanselmann | AssertCommand(drain_check, node=failovermaster) |
595 | ff699aa9 | Michael Hanselmann | AssertCommand(cmd, node=failovermaster) |
596 | ff699aa9 | Michael Hanselmann | AssertCommand(drain_check, fail=True)
|
597 | ff699aa9 | Michael Hanselmann | AssertCommand(drain_check, node=failovermaster, fail=True)
|
598 | ff699aa9 | Michael Hanselmann | |
599 | ff699aa9 | Michael Hanselmann | # Back to original master node
|
600 | ff699aa9 | Michael Hanselmann | AssertCommand(cmd, node=master) |
601 | ff699aa9 | Michael Hanselmann | finally:
|
602 | 565cb4bf | Michael Hanselmann | failovermaster.Release() |
603 | ff699aa9 | Michael Hanselmann | |
604 | ff699aa9 | Michael Hanselmann | AssertCommand(drain_check, fail=True)
|
605 | ff699aa9 | Michael Hanselmann | AssertCommand(drain_check, node=failovermaster, fail=True)
|
606 | ff699aa9 | Michael Hanselmann | |
607 | ff699aa9 | Michael Hanselmann | |
608 | cec9845c | Michael Hanselmann | def TestClusterCopyfile(): |
609 | cec9845c | Michael Hanselmann | """gnt-cluster copyfile"""
|
610 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
611 | cec9845c | Michael Hanselmann | |
612 | 24818e8f | Michael Hanselmann | uniqueid = utils.NewUUID() |
613 | 830da270 | Michael Hanselmann | |
614 | cec9845c | Michael Hanselmann | # Create temporary file
|
615 | cec9845c | Michael Hanselmann | f = tempfile.NamedTemporaryFile() |
616 | 830da270 | Michael Hanselmann | f.write(uniqueid) |
617 | cec9845c | Michael Hanselmann | f.flush() |
618 | cec9845c | Michael Hanselmann | f.seek(0)
|
619 | cec9845c | Michael Hanselmann | |
620 | cec9845c | Michael Hanselmann | # Upload file to master node
|
621 | aecba21e | Michael Hanselmann | testname = qa_utils.UploadFile(master.primary, f.name) |
622 | cec9845c | Michael Hanselmann | try:
|
623 | cec9845c | Michael Hanselmann | # Copy file to all nodes
|
624 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "copyfile", testname]) |
625 | 830da270 | Michael Hanselmann | _CheckFileOnAllNodes(testname, uniqueid) |
626 | cec9845c | Michael Hanselmann | finally:
|
627 | 830da270 | Michael Hanselmann | _RemoveFileFromAllNodes(testname) |
628 | 830da270 | Michael Hanselmann | |
629 | 830da270 | Michael Hanselmann | |
630 | 830da270 | Michael Hanselmann | def TestClusterCommand(): |
631 | 830da270 | Michael Hanselmann | """gnt-cluster command"""
|
632 | 24818e8f | Michael Hanselmann | uniqueid = utils.NewUUID() |
633 | 24818e8f | Michael Hanselmann | rfile = "/tmp/gnt%s" % utils.NewUUID()
|
634 | d0c8c01d | Iustin Pop | rcmd = utils.ShellQuoteArgs(["echo", "-n", uniqueid]) |
635 | d0c8c01d | Iustin Pop | cmd = utils.ShellQuoteArgs(["gnt-cluster", "command", |
636 | 830da270 | Michael Hanselmann | "%s >%s" % (rcmd, rfile)])
|
637 | 830da270 | Michael Hanselmann | |
638 | 830da270 | Michael Hanselmann | try:
|
639 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd) |
640 | 830da270 | Michael Hanselmann | _CheckFileOnAllNodes(rfile, uniqueid) |
641 | 830da270 | Michael Hanselmann | finally:
|
642 | 830da270 | Michael Hanselmann | _RemoveFileFromAllNodes(rfile) |
643 | cec9845c | Michael Hanselmann | |
644 | cec9845c | Michael Hanselmann | |
645 | cec9845c | Michael Hanselmann | def TestClusterDestroy(): |
646 | cec9845c | Michael Hanselmann | """gnt-cluster destroy"""
|
647 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "destroy", "--yes-do-it"]) |
648 | 65a884ef | Iustin Pop | |
649 | 65a884ef | Iustin Pop | |
650 | 65a884ef | Iustin Pop | def TestClusterRepairDiskSizes(): |
651 | 65a884ef | Iustin Pop | """gnt-cluster repair-disk-sizes"""
|
652 | 65a884ef | Iustin Pop | AssertCommand(["gnt-cluster", "repair-disk-sizes"]) |
653 | 50ef6a41 | Bernardo Dal Seno | |
654 | 50ef6a41 | Bernardo Dal Seno | |
655 | 50ef6a41 | Bernardo Dal Seno | def TestSetExclStorCluster(newvalue): |
656 | 50ef6a41 | Bernardo Dal Seno | """Set the exclusive_storage node parameter at the cluster level.
|
657 | 50ef6a41 | Bernardo Dal Seno |
|
658 | 50ef6a41 | Bernardo Dal Seno | @type newvalue: bool
|
659 | 50ef6a41 | Bernardo Dal Seno | @param newvalue: New value of exclusive_storage
|
660 | 50ef6a41 | Bernardo Dal Seno | @rtype: bool
|
661 | 50ef6a41 | Bernardo Dal Seno | @return: The old value of exclusive_storage
|
662 | 50ef6a41 | Bernardo Dal Seno |
|
663 | 50ef6a41 | Bernardo Dal Seno | """
|
664 | 50ef6a41 | Bernardo Dal Seno | oldvalue = _GetBoolClusterField("exclusive_storage")
|
665 | 50ef6a41 | Bernardo Dal Seno | AssertCommand(["gnt-cluster", "modify", "--node-parameters", |
666 | 50ef6a41 | Bernardo Dal Seno | "exclusive_storage=%s" % newvalue])
|
667 | 50ef6a41 | Bernardo Dal Seno | effvalue = _GetBoolClusterField("exclusive_storage")
|
668 | 50ef6a41 | Bernardo Dal Seno | if effvalue != newvalue:
|
669 | 50ef6a41 | Bernardo Dal Seno | raise qa_error.Error("exclusive_storage has the wrong value: %s instead" |
670 | 50ef6a41 | Bernardo Dal Seno | " of %s" % (effvalue, newvalue))
|
671 | 6a0f22e1 | Bernardo Dal Seno | qa_config.SetExclusiveStorage(newvalue) |
672 | 50ef6a41 | Bernardo Dal Seno | return oldvalue
|
673 | e8b919a1 | Bernardo Dal Seno | |
674 | e8b919a1 | Bernardo Dal Seno | |
675 | 21e2734f | Bernardo Dal Seno | def TestExclStorSharedPv(node): |
676 | 21e2734f | Bernardo Dal Seno | """cluster-verify reports LVs that share the same PV with exclusive_storage.
|
677 | 21e2734f | Bernardo Dal Seno |
|
678 | 21e2734f | Bernardo Dal Seno | """
|
679 | 21e2734f | Bernardo Dal Seno | vgname = qa_config.get("vg-name", constants.DEFAULT_VG)
|
680 | 21e2734f | Bernardo Dal Seno | lvname1 = _QA_LV_PREFIX + "vol1"
|
681 | 21e2734f | Bernardo Dal Seno | lvname2 = _QA_LV_PREFIX + "vol2"
|
682 | aecba21e | Michael Hanselmann | node_name = node.primary |
683 | 21e2734f | Bernardo Dal Seno | AssertCommand(["lvcreate", "-L1G", "-n", lvname1, vgname], node=node_name) |
684 | 21e2734f | Bernardo Dal Seno | AssertClusterVerify(fail=True, errors=[constants.CV_ENODEORPHANLV])
|
685 | 21e2734f | Bernardo Dal Seno | AssertCommand(["lvcreate", "-L1G", "-n", lvname2, vgname], node=node_name) |
686 | 21e2734f | Bernardo Dal Seno | AssertClusterVerify(fail=True, errors=[constants.CV_ENODELVM,
|
687 | 21e2734f | Bernardo Dal Seno | constants.CV_ENODEORPHANLV]) |
688 | 21e2734f | Bernardo Dal Seno | AssertCommand(["lvremove", "-f", "/".join([vgname, lvname1])], node=node_name) |
689 | 21e2734f | Bernardo Dal Seno | AssertCommand(["lvremove", "-f", "/".join([vgname, lvname2])], node=node_name) |
690 | 21e2734f | Bernardo Dal Seno | AssertClusterVerify() |