root / qa / qa_cluster.py @ 5abecc1c
History | View | Annotate | Download (12.4 kB)
1 | c68d1f43 | Michael Hanselmann | #
|
---|---|---|---|
2 | c68d1f43 | Michael Hanselmann | #
|
3 | c68d1f43 | Michael Hanselmann | |
4 | 69df9d2b | Iustin Pop | # Copyright (C) 2007, 2010, 2011 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 | cec9845c | Michael Hanselmann | from ganeti import utils |
31 | cec9845c | Michael Hanselmann | |
32 | cec9845c | Michael Hanselmann | import qa_config |
33 | cec9845c | Michael Hanselmann | import qa_utils |
34 | cec9845c | Michael Hanselmann | import qa_error |
35 | cec9845c | Michael Hanselmann | |
36 | 2f4b4f78 | Iustin Pop | from qa_utils import AssertEqual, AssertCommand |
37 | cec9845c | Michael Hanselmann | |
38 | cec9845c | Michael Hanselmann | |
39 | 830da270 | Michael Hanselmann | def _RemoveFileFromAllNodes(filename): |
40 | 830da270 | Michael Hanselmann | """Removes a file from all nodes.
|
41 | 830da270 | Michael Hanselmann |
|
42 | 830da270 | Michael Hanselmann | """
|
43 | 2f4b4f78 | Iustin Pop | for node in qa_config.get("nodes"): |
44 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", filename], node=node) |
45 | 830da270 | Michael Hanselmann | |
46 | 830da270 | Michael Hanselmann | |
47 | 830da270 | Michael Hanselmann | def _CheckFileOnAllNodes(filename, content): |
48 | 830da270 | Michael Hanselmann | """Verifies the content of the given file on all nodes.
|
49 | 830da270 | Michael Hanselmann |
|
50 | 830da270 | Michael Hanselmann | """
|
51 | 830da270 | Michael Hanselmann | cmd = utils.ShellQuoteArgs(["cat", filename])
|
52 | 2f4b4f78 | Iustin Pop | for node in qa_config.get("nodes"): |
53 | 2f4b4f78 | Iustin Pop | AssertEqual(qa_utils.GetCommandOutput(node["primary"], cmd), content)
|
54 | 830da270 | Michael Hanselmann | |
55 | 830da270 | Michael Hanselmann | |
56 | 725ec2f1 | René Nussbaumer | def TestClusterInit(rapi_user, rapi_secret): |
57 | cec9845c | Michael Hanselmann | """gnt-cluster init"""
|
58 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
59 | cec9845c | Michael Hanselmann | |
60 | 49ceab21 | Michael Hanselmann | rapi_dir = os.path.dirname(constants.RAPI_USERS_FILE) |
61 | 49ceab21 | Michael Hanselmann | |
62 | 725ec2f1 | René Nussbaumer | # First create the RAPI credentials
|
63 | a62d1901 | Michael Hanselmann | fh = tempfile.NamedTemporaryFile() |
64 | a62d1901 | Michael Hanselmann | try:
|
65 | a62d1901 | Michael Hanselmann | fh.write("%s %s write\n" % (rapi_user, rapi_secret))
|
66 | a62d1901 | Michael Hanselmann | fh.flush() |
67 | a62d1901 | Michael Hanselmann | |
68 | a62d1901 | Michael Hanselmann | tmpru = qa_utils.UploadFile(master["primary"], fh.name)
|
69 | a62d1901 | Michael Hanselmann | try:
|
70 | 49ceab21 | Michael Hanselmann | AssertCommand(["mkdir", "-p", rapi_dir]) |
71 | 2f4b4f78 | Iustin Pop | AssertCommand(["mv", tmpru, constants.RAPI_USERS_FILE])
|
72 | a62d1901 | Michael Hanselmann | finally:
|
73 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", tmpru]) |
74 | a62d1901 | Michael Hanselmann | finally:
|
75 | a62d1901 | Michael Hanselmann | fh.close() |
76 | a62d1901 | Michael Hanselmann | |
77 | a62d1901 | Michael Hanselmann | # Initialize cluster
|
78 | cec9845c | Michael Hanselmann | cmd = ['gnt-cluster', 'init'] |
79 | cec9845c | Michael Hanselmann | |
80 | 9486f6ae | Manuel Franceschini | cmd.append("--primary-ip-version=%d" %
|
81 | 9486f6ae | Manuel Franceschini | qa_config.get("primary_ip_version", 4)) |
82 | 9486f6ae | Manuel Franceschini | |
83 | cec9845c | Michael Hanselmann | if master.get('secondary', None): |
84 | cec9845c | Michael Hanselmann | cmd.append('--secondary-ip=%s' % master['secondary']) |
85 | cec9845c | Michael Hanselmann | |
86 | cec9845c | Michael Hanselmann | bridge = qa_config.get('bridge', None) |
87 | cec9845c | Michael Hanselmann | if bridge:
|
88 | cec9845c | Michael Hanselmann | cmd.append('--bridge=%s' % bridge)
|
89 | cec9845c | Michael Hanselmann | cmd.append('--master-netdev=%s' % bridge)
|
90 | cec9845c | Michael Hanselmann | |
91 | 2d6db53a | Guido Trotter | htype = qa_config.get('enabled-hypervisors', None) |
92 | b32f9859 | Iustin Pop | if htype:
|
93 | 2d6db53a | Guido Trotter | cmd.append('--enabled-hypervisors=%s' % htype)
|
94 | b32f9859 | Iustin Pop | |
95 | cec9845c | Michael Hanselmann | cmd.append(qa_config.get('name'))
|
96 | cec9845c | Michael Hanselmann | |
97 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd) |
98 | cec9845c | Michael Hanselmann | |
99 | 5abecc1c | Iustin Pop | cmd = ["gnt-cluster", "modify"] |
100 | 5abecc1c | Iustin Pop | # hypervisor parameter modifications
|
101 | 5abecc1c | Iustin Pop | hvp = qa_config.get("hypervisor-parameters", {})
|
102 | 5abecc1c | Iustin Pop | for k, v in hvp.items(): |
103 | 5abecc1c | Iustin Pop | cmd.extend(["-H", "%s:%s" % (k, v)]) |
104 | 5abecc1c | Iustin Pop | # backend parameter modifications
|
105 | 5abecc1c | Iustin Pop | bep = qa_config.get("backend-parameters", "") |
106 | 5abecc1c | Iustin Pop | if bep:
|
107 | 5abecc1c | Iustin Pop | cmd.extend(["-B", bep])
|
108 | 5abecc1c | Iustin Pop | |
109 | 5abecc1c | Iustin Pop | if len(cmd) > 2: |
110 | 5abecc1c | Iustin Pop | AssertCommand(cmd) |
111 | 5abecc1c | Iustin Pop | |
112 | 5abecc1c | Iustin Pop | # OS parameters
|
113 | 5abecc1c | Iustin Pop | osp = qa_config.get("os-parameters", {})
|
114 | 5abecc1c | Iustin Pop | for k, v in osp.items(): |
115 | 5abecc1c | Iustin Pop | AssertCommand(["gnt-os", "modify", "-O", v, k]) |
116 | 5abecc1c | Iustin Pop | |
117 | 5abecc1c | Iustin Pop | # OS hypervisor parameters
|
118 | 5abecc1c | Iustin Pop | os_hvp = qa_config.get("os-hvp", {})
|
119 | 5abecc1c | Iustin Pop | for os_name in os_hvp: |
120 | 5abecc1c | Iustin Pop | for hv, hvp in os_hvp[os_name].items(): |
121 | 5abecc1c | Iustin Pop | AssertCommand(["gnt-os", "modify", "-H", "%s:%s" % (hv, hvp), os_name]) |
122 | 5abecc1c | Iustin Pop | |
123 | cec9845c | Michael Hanselmann | |
124 | caea3b32 | Iustin Pop | def TestClusterRename(): |
125 | caea3b32 | Iustin Pop | """gnt-cluster rename"""
|
126 | caea3b32 | Iustin Pop | cmd = ['gnt-cluster', 'rename', '-f'] |
127 | caea3b32 | Iustin Pop | |
128 | caea3b32 | Iustin Pop | original_name = qa_config.get('name')
|
129 | caea3b32 | Iustin Pop | rename_target = qa_config.get('rename', None) |
130 | caea3b32 | Iustin Pop | if rename_target is None: |
131 | caea3b32 | Iustin Pop | print qa_utils.FormatError('"rename" entry is missing') |
132 | caea3b32 | Iustin Pop | return
|
133 | caea3b32 | Iustin Pop | |
134 | caea3b32 | Iustin Pop | cmd_verify = ['gnt-cluster', 'verify'] |
135 | caea3b32 | Iustin Pop | |
136 | 2f4b4f78 | Iustin Pop | for data in [ |
137 | 2f4b4f78 | Iustin Pop | cmd + [rename_target], |
138 | 2f4b4f78 | Iustin Pop | cmd_verify, |
139 | 2f4b4f78 | Iustin Pop | cmd + [original_name], |
140 | 2f4b4f78 | Iustin Pop | cmd_verify, |
141 | 2f4b4f78 | Iustin Pop | ]: |
142 | 2f4b4f78 | Iustin Pop | AssertCommand(data) |
143 | caea3b32 | Iustin Pop | |
144 | caea3b32 | Iustin Pop | |
145 | 69df9d2b | Iustin Pop | def TestClusterOob(): |
146 | 69df9d2b | Iustin Pop | """out-of-band framework"""
|
147 | f55312bd | René Nussbaumer | oob_path_exists = "/tmp/ganeti-qa-oob-does-exist-%s" % utils.NewUUID()
|
148 | f55312bd | René Nussbaumer | |
149 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "verify"]) |
150 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "modify", "--node-parameters", |
151 | f55312bd | René Nussbaumer | "oob_program=/tmp/ganeti-qa-oob-does-not-exist-%s" %
|
152 | f55312bd | René Nussbaumer | utils.NewUUID()]) |
153 | f55312bd | René Nussbaumer | |
154 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "verify"], fail=True) |
155 | f55312bd | René Nussbaumer | |
156 | 69df9d2b | Iustin Pop | AssertCommand(["touch", oob_path_exists])
|
157 | 69df9d2b | Iustin Pop | AssertCommand(["chmod", "0400", oob_path_exists]) |
158 | 69df9d2b | Iustin Pop | AssertCommand(["gnt-cluster", "copyfile", oob_path_exists]) |
159 | f55312bd | René Nussbaumer | |
160 | f55312bd | René Nussbaumer | try:
|
161 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "modify", "--node-parameters", |
162 | f55312bd | René Nussbaumer | "oob_program=%s" % oob_path_exists])
|
163 | f55312bd | René Nussbaumer | |
164 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "verify"], fail=True) |
165 | f55312bd | René Nussbaumer | |
166 | 69df9d2b | Iustin Pop | AssertCommand(["chmod", "0500", oob_path_exists]) |
167 | 69df9d2b | Iustin Pop | AssertCommand(["gnt-cluster", "copyfile", oob_path_exists]) |
168 | f55312bd | René Nussbaumer | |
169 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "verify"]) |
170 | f55312bd | René Nussbaumer | finally:
|
171 | 69df9d2b | Iustin Pop | AssertCommand(["gnt-cluster", "command", "rm", oob_path_exists]) |
172 | f55312bd | René Nussbaumer | |
173 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "modify", "--node-parameters", |
174 | f55312bd | René Nussbaumer | "oob_program="])
|
175 | 69df9d2b | Iustin Pop | |
176 | 69df9d2b | Iustin Pop | |
177 | 69df9d2b | Iustin Pop | def TestClusterVerify(): |
178 | 69df9d2b | Iustin Pop | """gnt-cluster verify"""
|
179 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "verify"]) |
180 | c6953b6e | Iustin Pop | AssertCommand(["gnt-cluster", "verify-disks"]) |
181 | cec9845c | Michael Hanselmann | |
182 | 1377433b | Michael Hanselmann | |
183 | 1377433b | Michael Hanselmann | def TestJobqueue(): |
184 | 1377433b | Michael Hanselmann | """gnt-debug test-jobqueue"""
|
185 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-debug", "test-jobqueue"]) |
186 | 1377433b | Michael Hanselmann | |
187 | 1377433b | Michael Hanselmann | |
188 | 452913ed | Iustin Pop | def TestClusterReservedLvs(): |
189 | 452913ed | Iustin Pop | """gnt-cluster reserved lvs"""
|
190 | 2f4b4f78 | Iustin Pop | CVERIFY = ["gnt-cluster", "verify"] |
191 | 2f4b4f78 | Iustin Pop | for fail, cmd in [ |
192 | 2f4b4f78 | Iustin Pop | (False, CVERIFY),
|
193 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "--reserved-lvs", ""]), |
194 | 2f4b4f78 | Iustin Pop | (False, ["lvcreate", "-L1G", "-nqa-test", "xenvg"]), |
195 | 2f4b4f78 | Iustin Pop | (True, CVERIFY),
|
196 | 84d7e26b | Dmitry Chernyak | (False, ["gnt-cluster", "modify", "--reserved-lvs", |
197 | 84d7e26b | Dmitry Chernyak | "xenvg/qa-test,.*/other-test"]),
|
198 | 2f4b4f78 | Iustin Pop | (False, CVERIFY),
|
199 | 84d7e26b | Dmitry Chernyak | (False, ["gnt-cluster", "modify", "--reserved-lvs", ".*/qa-.*"]), |
200 | 2f4b4f78 | Iustin Pop | (False, CVERIFY),
|
201 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "--reserved-lvs", ""]), |
202 | 2f4b4f78 | Iustin Pop | (True, CVERIFY),
|
203 | 2f4b4f78 | Iustin Pop | (False, ["lvremove", "-f", "xenvg/qa-test"]), |
204 | 2f4b4f78 | Iustin Pop | (False, CVERIFY),
|
205 | 452913ed | Iustin Pop | ]: |
206 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, fail=fail) |
207 | 452913ed | Iustin Pop | |
208 | cec9845c | Michael Hanselmann | |
209 | 9738ca94 | Iustin Pop | def TestClusterModifyBe(): |
210 | 9738ca94 | Iustin Pop | """gnt-cluster modify -B"""
|
211 | 2f4b4f78 | Iustin Pop | for fail, cmd in [ |
212 | 9738ca94 | Iustin Pop | # mem
|
213 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "memory=256"]), |
214 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *memory: 256$'"]), |
215 | 2f4b4f78 | Iustin Pop | (True, ["gnt-cluster", "modify", "-B", "memory=a"]), |
216 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "memory=128"]), |
217 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *memory: 128$'"]), |
218 | 9738ca94 | Iustin Pop | # vcpus
|
219 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "vcpus=4"]), |
220 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *vcpus: 4$'"]), |
221 | 2f4b4f78 | Iustin Pop | (True, ["gnt-cluster", "modify", "-B", "vcpus=a"]), |
222 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "vcpus=1"]), |
223 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *vcpus: 1$'"]), |
224 | 9738ca94 | Iustin Pop | # auto_balance
|
225 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "auto_balance=False"]), |
226 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *auto_balance: False$'"]), |
227 | 2f4b4f78 | Iustin Pop | (True, ["gnt-cluster", "modify", "-B", "auto_balance=1"]), |
228 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "auto_balance=True"]), |
229 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *auto_balance: True$'"]), |
230 | 9738ca94 | Iustin Pop | ]: |
231 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, fail=fail) |
232 | 9738ca94 | Iustin Pop | |
233 | 5abecc1c | Iustin Pop | # redo the original-requested BE parameters, if any
|
234 | 5abecc1c | Iustin Pop | bep = qa_config.get("backend-parameters", "") |
235 | 5abecc1c | Iustin Pop | if bep:
|
236 | 5abecc1c | Iustin Pop | AssertCommand(["gnt-cluster", "modify", "-B", bep]) |
237 | 9738ca94 | Iustin Pop | |
238 | cec9845c | Michael Hanselmann | def TestClusterInfo(): |
239 | cec9845c | Michael Hanselmann | """gnt-cluster info"""
|
240 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "info"]) |
241 | 283f9d4c | Michael Hanselmann | |
242 | 283f9d4c | Michael Hanselmann | |
243 | 283f9d4c | Michael Hanselmann | def TestClusterGetmaster(): |
244 | 283f9d4c | Michael Hanselmann | """gnt-cluster getmaster"""
|
245 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "getmaster"]) |
246 | 283f9d4c | Michael Hanselmann | |
247 | 283f9d4c | Michael Hanselmann | |
248 | 283f9d4c | Michael Hanselmann | def TestClusterVersion(): |
249 | 283f9d4c | Michael Hanselmann | """gnt-cluster version"""
|
250 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "version"]) |
251 | cec9845c | Michael Hanselmann | |
252 | cec9845c | Michael Hanselmann | |
253 | 6d4a1656 | Michael Hanselmann | def TestClusterRenewCrypto(): |
254 | 6d4a1656 | Michael Hanselmann | """gnt-cluster renew-crypto"""
|
255 | 6d4a1656 | Michael Hanselmann | master = qa_config.GetMasterNode() |
256 | 6d4a1656 | Michael Hanselmann | |
257 | 6d4a1656 | Michael Hanselmann | # Conflicting options
|
258 | 6d4a1656 | Michael Hanselmann | cmd = ["gnt-cluster", "renew-crypto", "--force", |
259 | 3db3eb2a | Michael Hanselmann | "--new-cluster-certificate", "--new-confd-hmac-key"] |
260 | 3db3eb2a | Michael Hanselmann | conflicting = [ |
261 | 3db3eb2a | Michael Hanselmann | ["--new-rapi-certificate", "--rapi-certificate=/dev/null"], |
262 | 3db3eb2a | Michael Hanselmann | ["--new-cluster-domain-secret", "--cluster-domain-secret=/dev/null"], |
263 | 3db3eb2a | Michael Hanselmann | ] |
264 | 3db3eb2a | Michael Hanselmann | for i in conflicting: |
265 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd+i, fail=True)
|
266 | 6d4a1656 | Michael Hanselmann | |
267 | 6d4a1656 | Michael Hanselmann | # Invalid RAPI certificate
|
268 | 6d4a1656 | Michael Hanselmann | cmd = ["gnt-cluster", "renew-crypto", "--force", |
269 | 6d4a1656 | Michael Hanselmann | "--rapi-certificate=/dev/null"]
|
270 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, fail=True)
|
271 | 6d4a1656 | Michael Hanselmann | |
272 | 502f5236 | Michael Hanselmann | rapi_cert_backup = qa_utils.BackupFile(master["primary"],
|
273 | 502f5236 | Michael Hanselmann | constants.RAPI_CERT_FILE) |
274 | 502f5236 | Michael Hanselmann | try:
|
275 | 502f5236 | Michael Hanselmann | # Custom RAPI certificate
|
276 | 502f5236 | Michael Hanselmann | fh = tempfile.NamedTemporaryFile() |
277 | 6d4a1656 | Michael Hanselmann | |
278 | 502f5236 | Michael Hanselmann | # Ensure certificate doesn't cause "gnt-cluster verify" to complain
|
279 | 502f5236 | Michael Hanselmann | validity = constants.SSL_CERT_EXPIRATION_WARN * 3
|
280 | 6d4a1656 | Michael Hanselmann | |
281 | 5e26633b | Michael Hanselmann | utils.GenerateSelfSignedSslCert(fh.name, validity=validity) |
282 | 6d4a1656 | Michael Hanselmann | |
283 | 502f5236 | Michael Hanselmann | tmpcert = qa_utils.UploadFile(master["primary"], fh.name)
|
284 | 502f5236 | Michael Hanselmann | try:
|
285 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
286 | 2f4b4f78 | Iustin Pop | "--rapi-certificate=%s" % tmpcert])
|
287 | 502f5236 | Michael Hanselmann | finally:
|
288 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", tmpcert]) |
289 | 502f5236 | Michael Hanselmann | |
290 | 5e26633b | Michael Hanselmann | # Custom cluster domain secret
|
291 | 5e26633b | Michael Hanselmann | cds_fh = tempfile.NamedTemporaryFile() |
292 | 5e26633b | Michael Hanselmann | cds_fh.write(utils.GenerateSecret()) |
293 | 5e26633b | Michael Hanselmann | cds_fh.write("\n")
|
294 | 5e26633b | Michael Hanselmann | cds_fh.flush() |
295 | 5e26633b | Michael Hanselmann | |
296 | 5e26633b | Michael Hanselmann | tmpcds = qa_utils.UploadFile(master["primary"], cds_fh.name)
|
297 | 5e26633b | Michael Hanselmann | try:
|
298 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
299 | 2f4b4f78 | Iustin Pop | "--cluster-domain-secret=%s" % tmpcds])
|
300 | 5e26633b | Michael Hanselmann | finally:
|
301 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", tmpcds]) |
302 | 5e26633b | Michael Hanselmann | |
303 | 502f5236 | Michael Hanselmann | # Normal case
|
304 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
305 | 2f4b4f78 | Iustin Pop | "--new-cluster-certificate", "--new-confd-hmac-key", |
306 | 2f4b4f78 | Iustin Pop | "--new-rapi-certificate", "--new-cluster-domain-secret"]) |
307 | 3db3eb2a | Michael Hanselmann | |
308 | 502f5236 | Michael Hanselmann | # Restore RAPI certificate
|
309 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
310 | 2f4b4f78 | Iustin Pop | "--rapi-certificate=%s" % rapi_cert_backup])
|
311 | 3db3eb2a | Michael Hanselmann | finally:
|
312 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", rapi_cert_backup]) |
313 | 3db3eb2a | Michael Hanselmann | |
314 | 6d4a1656 | Michael Hanselmann | |
315 | cec9845c | Michael Hanselmann | def TestClusterBurnin(): |
316 | cec9845c | Michael Hanselmann | """Burnin"""
|
317 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
318 | cec9845c | Michael Hanselmann | |
319 | 0b0a150a | Iustin Pop | options = qa_config.get('options', {})
|
320 | 0b0a150a | Iustin Pop | disk_template = options.get('burnin-disk-template', 'drbd') |
321 | 0b0a150a | Iustin Pop | parallel = options.get('burnin-in-parallel', False) |
322 | 0b0a150a | Iustin Pop | check_inst = options.get('burnin-check-instances', False) |
323 | 4dc76b24 | Iustin Pop | do_rename = options.get('burnin-rename', '') |
324 | 58598264 | Iustin Pop | do_reboot = options.get('burnin-reboot', True) |
325 | 1d103c02 | Iustin Pop | reboot_types = options.get("reboot-types", constants.REBOOT_TYPES)
|
326 | 23103544 | Michael Hanselmann | |
327 | cec9845c | Michael Hanselmann | # Get as many instances as we need
|
328 | cec9845c | Michael Hanselmann | instances = [] |
329 | cec9845c | Michael Hanselmann | try:
|
330 | 23103544 | Michael Hanselmann | try:
|
331 | 23103544 | Michael Hanselmann | num = qa_config.get('options', {}).get('burnin-instances', 1) |
332 | f1501b3f | Michael Hanselmann | for _ in range(0, num): |
333 | 23103544 | Michael Hanselmann | instances.append(qa_config.AcquireInstance()) |
334 | 23103544 | Michael Hanselmann | except qa_error.OutOfInstancesError:
|
335 | 23103544 | Michael Hanselmann | print "Not enough instances, continuing anyway." |
336 | cec9845c | Michael Hanselmann | |
337 | 23103544 | Michael Hanselmann | if len(instances) < 1: |
338 | 23103544 | Michael Hanselmann | raise qa_error.Error("Burnin needs at least one instance") |
339 | cec9845c | Michael Hanselmann | |
340 | cec9845c | Michael Hanselmann | script = qa_utils.UploadFile(master['primary'], '../tools/burnin') |
341 | cec9845c | Michael Hanselmann | try:
|
342 | 23103544 | Michael Hanselmann | # Run burnin
|
343 | cec9845c | Michael Hanselmann | cmd = [script, |
344 | cec9845c | Michael Hanselmann | '--os=%s' % qa_config.get('os'), |
345 | 1d693311 | Michael Hanselmann | '--disk-size=%s' % ",".join(qa_config.get('disk')), |
346 | 1d693311 | Michael Hanselmann | '--disk-growth=%s' % ",".join(qa_config.get('disk-growth')), |
347 | 23103544 | Michael Hanselmann | '--disk-template=%s' % disk_template]
|
348 | 0b0a150a | Iustin Pop | if parallel:
|
349 | 0b0a150a | Iustin Pop | cmd.append('--parallel')
|
350 | 745c878a | Iustin Pop | cmd.append('--early-release')
|
351 | 0b0a150a | Iustin Pop | if check_inst:
|
352 | 0b0a150a | Iustin Pop | cmd.append('--http-check')
|
353 | 4dc76b24 | Iustin Pop | if do_rename:
|
354 | 4dc76b24 | Iustin Pop | cmd.append('--rename=%s' % do_rename)
|
355 | 58598264 | Iustin Pop | if not do_reboot: |
356 | 58598264 | Iustin Pop | cmd.append('--no-reboot')
|
357 | 1d103c02 | Iustin Pop | else:
|
358 | 1d103c02 | Iustin Pop | cmd.append('--reboot-types=%s' % ",".join(reboot_types)) |
359 | cec9845c | Michael Hanselmann | cmd += [inst['name'] for inst in instances] |
360 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd) |
361 | cec9845c | Michael Hanselmann | finally:
|
362 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", script]) |
363 | 2f4b4f78 | Iustin Pop | |
364 | cec9845c | Michael Hanselmann | finally:
|
365 | cec9845c | Michael Hanselmann | for inst in instances: |
366 | cec9845c | Michael Hanselmann | qa_config.ReleaseInstance(inst) |
367 | cec9845c | Michael Hanselmann | |
368 | cec9845c | Michael Hanselmann | |
369 | cec9845c | Michael Hanselmann | def TestClusterMasterFailover(): |
370 | c28502b1 | Iustin Pop | """gnt-cluster master-failover"""
|
371 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
372 | cec9845c | Michael Hanselmann | failovermaster = qa_config.AcquireNode(exclude=master) |
373 | cec9845c | Michael Hanselmann | |
374 | 2f4b4f78 | Iustin Pop | cmd = ["gnt-cluster", "master-failover"] |
375 | 2f4b4f78 | Iustin Pop | try:
|
376 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, node=failovermaster) |
377 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, node=master) |
378 | cec9845c | Michael Hanselmann | finally:
|
379 | cec9845c | Michael Hanselmann | qa_config.ReleaseNode(failovermaster) |
380 | cec9845c | Michael Hanselmann | |
381 | cec9845c | Michael Hanselmann | |
382 | cec9845c | Michael Hanselmann | def TestClusterCopyfile(): |
383 | cec9845c | Michael Hanselmann | """gnt-cluster copyfile"""
|
384 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
385 | cec9845c | Michael Hanselmann | |
386 | 24818e8f | Michael Hanselmann | uniqueid = utils.NewUUID() |
387 | 830da270 | Michael Hanselmann | |
388 | cec9845c | Michael Hanselmann | # Create temporary file
|
389 | cec9845c | Michael Hanselmann | f = tempfile.NamedTemporaryFile() |
390 | 830da270 | Michael Hanselmann | f.write(uniqueid) |
391 | cec9845c | Michael Hanselmann | f.flush() |
392 | cec9845c | Michael Hanselmann | f.seek(0)
|
393 | cec9845c | Michael Hanselmann | |
394 | cec9845c | Michael Hanselmann | # Upload file to master node
|
395 | cec9845c | Michael Hanselmann | testname = qa_utils.UploadFile(master['primary'], f.name)
|
396 | cec9845c | Michael Hanselmann | try:
|
397 | cec9845c | Michael Hanselmann | # Copy file to all nodes
|
398 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "copyfile", testname]) |
399 | 830da270 | Michael Hanselmann | _CheckFileOnAllNodes(testname, uniqueid) |
400 | cec9845c | Michael Hanselmann | finally:
|
401 | 830da270 | Michael Hanselmann | _RemoveFileFromAllNodes(testname) |
402 | 830da270 | Michael Hanselmann | |
403 | 830da270 | Michael Hanselmann | |
404 | 830da270 | Michael Hanselmann | def TestClusterCommand(): |
405 | 830da270 | Michael Hanselmann | """gnt-cluster command"""
|
406 | 24818e8f | Michael Hanselmann | uniqueid = utils.NewUUID() |
407 | 24818e8f | Michael Hanselmann | rfile = "/tmp/gnt%s" % utils.NewUUID()
|
408 | 830da270 | Michael Hanselmann | rcmd = utils.ShellQuoteArgs(['echo', '-n', uniqueid]) |
409 | 830da270 | Michael Hanselmann | cmd = utils.ShellQuoteArgs(['gnt-cluster', 'command', |
410 | 830da270 | Michael Hanselmann | "%s >%s" % (rcmd, rfile)])
|
411 | 830da270 | Michael Hanselmann | |
412 | 830da270 | Michael Hanselmann | try:
|
413 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd) |
414 | 830da270 | Michael Hanselmann | _CheckFileOnAllNodes(rfile, uniqueid) |
415 | 830da270 | Michael Hanselmann | finally:
|
416 | 830da270 | Michael Hanselmann | _RemoveFileFromAllNodes(rfile) |
417 | cec9845c | Michael Hanselmann | |
418 | cec9845c | Michael Hanselmann | |
419 | cec9845c | Michael Hanselmann | def TestClusterDestroy(): |
420 | cec9845c | Michael Hanselmann | """gnt-cluster destroy"""
|
421 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "destroy", "--yes-do-it"]) |