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