root / qa / qa_cluster.py @ 69df9d2b
History | View | Annotate | Download (11.5 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 | cec9845c | Michael Hanselmann | |
100 | caea3b32 | Iustin Pop | def TestClusterRename(): |
101 | caea3b32 | Iustin Pop | """gnt-cluster rename"""
|
102 | caea3b32 | Iustin Pop | cmd = ['gnt-cluster', 'rename', '-f'] |
103 | caea3b32 | Iustin Pop | |
104 | caea3b32 | Iustin Pop | original_name = qa_config.get('name')
|
105 | caea3b32 | Iustin Pop | rename_target = qa_config.get('rename', None) |
106 | caea3b32 | Iustin Pop | if rename_target is None: |
107 | caea3b32 | Iustin Pop | print qa_utils.FormatError('"rename" entry is missing') |
108 | caea3b32 | Iustin Pop | return
|
109 | caea3b32 | Iustin Pop | |
110 | caea3b32 | Iustin Pop | cmd_verify = ['gnt-cluster', 'verify'] |
111 | caea3b32 | Iustin Pop | |
112 | 2f4b4f78 | Iustin Pop | for data in [ |
113 | 2f4b4f78 | Iustin Pop | cmd + [rename_target], |
114 | 2f4b4f78 | Iustin Pop | cmd_verify, |
115 | 2f4b4f78 | Iustin Pop | cmd + [original_name], |
116 | 2f4b4f78 | Iustin Pop | cmd_verify, |
117 | 2f4b4f78 | Iustin Pop | ]: |
118 | 2f4b4f78 | Iustin Pop | AssertCommand(data) |
119 | caea3b32 | Iustin Pop | |
120 | caea3b32 | Iustin Pop | |
121 | 69df9d2b | Iustin Pop | def TestClusterOob(): |
122 | 69df9d2b | Iustin Pop | """out-of-band framework"""
|
123 | f55312bd | René Nussbaumer | oob_path_exists = "/tmp/ganeti-qa-oob-does-exist-%s" % utils.NewUUID()
|
124 | f55312bd | René Nussbaumer | |
125 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "verify"]) |
126 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "modify", "--node-parameters", |
127 | f55312bd | René Nussbaumer | "oob_program=/tmp/ganeti-qa-oob-does-not-exist-%s" %
|
128 | f55312bd | René Nussbaumer | utils.NewUUID()]) |
129 | f55312bd | René Nussbaumer | |
130 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "verify"], fail=True) |
131 | f55312bd | René Nussbaumer | |
132 | 69df9d2b | Iustin Pop | AssertCommand(["touch", oob_path_exists])
|
133 | 69df9d2b | Iustin Pop | AssertCommand(["chmod", "0400", oob_path_exists]) |
134 | 69df9d2b | Iustin Pop | AssertCommand(["gnt-cluster", "copyfile", oob_path_exists]) |
135 | f55312bd | René Nussbaumer | |
136 | f55312bd | René Nussbaumer | try:
|
137 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "modify", "--node-parameters", |
138 | f55312bd | René Nussbaumer | "oob_program=%s" % oob_path_exists])
|
139 | f55312bd | René Nussbaumer | |
140 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "verify"], fail=True) |
141 | f55312bd | René Nussbaumer | |
142 | 69df9d2b | Iustin Pop | AssertCommand(["chmod", "0500", oob_path_exists]) |
143 | 69df9d2b | Iustin Pop | AssertCommand(["gnt-cluster", "copyfile", oob_path_exists]) |
144 | f55312bd | René Nussbaumer | |
145 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "verify"]) |
146 | f55312bd | René Nussbaumer | finally:
|
147 | 69df9d2b | Iustin Pop | AssertCommand(["gnt-cluster", "command", "rm", oob_path_exists]) |
148 | f55312bd | René Nussbaumer | |
149 | f55312bd | René Nussbaumer | AssertCommand(["gnt-cluster", "modify", "--node-parameters", |
150 | f55312bd | René Nussbaumer | "oob_program="])
|
151 | 69df9d2b | Iustin Pop | |
152 | 69df9d2b | Iustin Pop | |
153 | 69df9d2b | Iustin Pop | def TestClusterVerify(): |
154 | 69df9d2b | Iustin Pop | """gnt-cluster verify"""
|
155 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "verify"]) |
156 | cec9845c | Michael Hanselmann | |
157 | 1377433b | Michael Hanselmann | |
158 | 1377433b | Michael Hanselmann | def TestJobqueue(): |
159 | 1377433b | Michael Hanselmann | """gnt-debug test-jobqueue"""
|
160 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-debug", "test-jobqueue"]) |
161 | 1377433b | Michael Hanselmann | |
162 | 1377433b | Michael Hanselmann | |
163 | 452913ed | Iustin Pop | def TestClusterReservedLvs(): |
164 | 452913ed | Iustin Pop | """gnt-cluster reserved lvs"""
|
165 | 2f4b4f78 | Iustin Pop | CVERIFY = ["gnt-cluster", "verify"] |
166 | 2f4b4f78 | Iustin Pop | for fail, cmd in [ |
167 | 2f4b4f78 | Iustin Pop | (False, CVERIFY),
|
168 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "--reserved-lvs", ""]), |
169 | 2f4b4f78 | Iustin Pop | (False, ["lvcreate", "-L1G", "-nqa-test", "xenvg"]), |
170 | 2f4b4f78 | Iustin Pop | (True, CVERIFY),
|
171 | 84d7e26b | Dmitry Chernyak | (False, ["gnt-cluster", "modify", "--reserved-lvs", |
172 | 84d7e26b | Dmitry Chernyak | "xenvg/qa-test,.*/other-test"]),
|
173 | 2f4b4f78 | Iustin Pop | (False, CVERIFY),
|
174 | 84d7e26b | Dmitry Chernyak | (False, ["gnt-cluster", "modify", "--reserved-lvs", ".*/qa-.*"]), |
175 | 2f4b4f78 | Iustin Pop | (False, CVERIFY),
|
176 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "--reserved-lvs", ""]), |
177 | 2f4b4f78 | Iustin Pop | (True, CVERIFY),
|
178 | 2f4b4f78 | Iustin Pop | (False, ["lvremove", "-f", "xenvg/qa-test"]), |
179 | 2f4b4f78 | Iustin Pop | (False, CVERIFY),
|
180 | 452913ed | Iustin Pop | ]: |
181 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, fail=fail) |
182 | 452913ed | Iustin Pop | |
183 | cec9845c | Michael Hanselmann | |
184 | 9738ca94 | Iustin Pop | def TestClusterModifyBe(): |
185 | 9738ca94 | Iustin Pop | """gnt-cluster modify -B"""
|
186 | 2f4b4f78 | Iustin Pop | for fail, cmd in [ |
187 | 9738ca94 | Iustin Pop | # mem
|
188 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "memory=256"]), |
189 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *memory: 256$'"]), |
190 | 2f4b4f78 | Iustin Pop | (True, ["gnt-cluster", "modify", "-B", "memory=a"]), |
191 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "memory=128"]), |
192 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *memory: 128$'"]), |
193 | 9738ca94 | Iustin Pop | # vcpus
|
194 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "vcpus=4"]), |
195 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *vcpus: 4$'"]), |
196 | 2f4b4f78 | Iustin Pop | (True, ["gnt-cluster", "modify", "-B", "vcpus=a"]), |
197 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "vcpus=1"]), |
198 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *vcpus: 1$'"]), |
199 | 9738ca94 | Iustin Pop | # auto_balance
|
200 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "auto_balance=False"]), |
201 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *auto_balance: False$'"]), |
202 | 2f4b4f78 | Iustin Pop | (True, ["gnt-cluster", "modify", "-B", "auto_balance=1"]), |
203 | 2f4b4f78 | Iustin Pop | (False, ["gnt-cluster", "modify", "-B", "auto_balance=True"]), |
204 | 2f4b4f78 | Iustin Pop | (False, ["sh", "-c", "gnt-cluster info|grep '^ *auto_balance: True$'"]), |
205 | 9738ca94 | Iustin Pop | ]: |
206 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, fail=fail) |
207 | 9738ca94 | Iustin Pop | |
208 | 9738ca94 | Iustin Pop | |
209 | cec9845c | Michael Hanselmann | def TestClusterInfo(): |
210 | cec9845c | Michael Hanselmann | """gnt-cluster info"""
|
211 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "info"]) |
212 | 283f9d4c | Michael Hanselmann | |
213 | 283f9d4c | Michael Hanselmann | |
214 | 283f9d4c | Michael Hanselmann | def TestClusterGetmaster(): |
215 | 283f9d4c | Michael Hanselmann | """gnt-cluster getmaster"""
|
216 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "getmaster"]) |
217 | 283f9d4c | Michael Hanselmann | |
218 | 283f9d4c | Michael Hanselmann | |
219 | 283f9d4c | Michael Hanselmann | def TestClusterVersion(): |
220 | 283f9d4c | Michael Hanselmann | """gnt-cluster version"""
|
221 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "version"]) |
222 | cec9845c | Michael Hanselmann | |
223 | cec9845c | Michael Hanselmann | |
224 | 6d4a1656 | Michael Hanselmann | def TestClusterRenewCrypto(): |
225 | 6d4a1656 | Michael Hanselmann | """gnt-cluster renew-crypto"""
|
226 | 6d4a1656 | Michael Hanselmann | master = qa_config.GetMasterNode() |
227 | 6d4a1656 | Michael Hanselmann | |
228 | 6d4a1656 | Michael Hanselmann | # Conflicting options
|
229 | 6d4a1656 | Michael Hanselmann | cmd = ["gnt-cluster", "renew-crypto", "--force", |
230 | 3db3eb2a | Michael Hanselmann | "--new-cluster-certificate", "--new-confd-hmac-key"] |
231 | 3db3eb2a | Michael Hanselmann | conflicting = [ |
232 | 3db3eb2a | Michael Hanselmann | ["--new-rapi-certificate", "--rapi-certificate=/dev/null"], |
233 | 3db3eb2a | Michael Hanselmann | ["--new-cluster-domain-secret", "--cluster-domain-secret=/dev/null"], |
234 | 3db3eb2a | Michael Hanselmann | ] |
235 | 3db3eb2a | Michael Hanselmann | for i in conflicting: |
236 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd+i, fail=True)
|
237 | 6d4a1656 | Michael Hanselmann | |
238 | 6d4a1656 | Michael Hanselmann | # Invalid RAPI certificate
|
239 | 6d4a1656 | Michael Hanselmann | cmd = ["gnt-cluster", "renew-crypto", "--force", |
240 | 6d4a1656 | Michael Hanselmann | "--rapi-certificate=/dev/null"]
|
241 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, fail=True)
|
242 | 6d4a1656 | Michael Hanselmann | |
243 | 502f5236 | Michael Hanselmann | rapi_cert_backup = qa_utils.BackupFile(master["primary"],
|
244 | 502f5236 | Michael Hanselmann | constants.RAPI_CERT_FILE) |
245 | 502f5236 | Michael Hanselmann | try:
|
246 | 502f5236 | Michael Hanselmann | # Custom RAPI certificate
|
247 | 502f5236 | Michael Hanselmann | fh = tempfile.NamedTemporaryFile() |
248 | 6d4a1656 | Michael Hanselmann | |
249 | 502f5236 | Michael Hanselmann | # Ensure certificate doesn't cause "gnt-cluster verify" to complain
|
250 | 502f5236 | Michael Hanselmann | validity = constants.SSL_CERT_EXPIRATION_WARN * 3
|
251 | 6d4a1656 | Michael Hanselmann | |
252 | 5e26633b | Michael Hanselmann | utils.GenerateSelfSignedSslCert(fh.name, validity=validity) |
253 | 6d4a1656 | Michael Hanselmann | |
254 | 502f5236 | Michael Hanselmann | tmpcert = qa_utils.UploadFile(master["primary"], fh.name)
|
255 | 502f5236 | Michael Hanselmann | try:
|
256 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
257 | 2f4b4f78 | Iustin Pop | "--rapi-certificate=%s" % tmpcert])
|
258 | 502f5236 | Michael Hanselmann | finally:
|
259 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", tmpcert]) |
260 | 502f5236 | Michael Hanselmann | |
261 | 5e26633b | Michael Hanselmann | # Custom cluster domain secret
|
262 | 5e26633b | Michael Hanselmann | cds_fh = tempfile.NamedTemporaryFile() |
263 | 5e26633b | Michael Hanselmann | cds_fh.write(utils.GenerateSecret()) |
264 | 5e26633b | Michael Hanselmann | cds_fh.write("\n")
|
265 | 5e26633b | Michael Hanselmann | cds_fh.flush() |
266 | 5e26633b | Michael Hanselmann | |
267 | 5e26633b | Michael Hanselmann | tmpcds = qa_utils.UploadFile(master["primary"], cds_fh.name)
|
268 | 5e26633b | Michael Hanselmann | try:
|
269 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
270 | 2f4b4f78 | Iustin Pop | "--cluster-domain-secret=%s" % tmpcds])
|
271 | 5e26633b | Michael Hanselmann | finally:
|
272 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", tmpcds]) |
273 | 5e26633b | Michael Hanselmann | |
274 | 502f5236 | Michael Hanselmann | # Normal case
|
275 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
276 | 2f4b4f78 | Iustin Pop | "--new-cluster-certificate", "--new-confd-hmac-key", |
277 | 2f4b4f78 | Iustin Pop | "--new-rapi-certificate", "--new-cluster-domain-secret"]) |
278 | 3db3eb2a | Michael Hanselmann | |
279 | 502f5236 | Michael Hanselmann | # Restore RAPI certificate
|
280 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
281 | 2f4b4f78 | Iustin Pop | "--rapi-certificate=%s" % rapi_cert_backup])
|
282 | 3db3eb2a | Michael Hanselmann | finally:
|
283 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", rapi_cert_backup]) |
284 | 3db3eb2a | Michael Hanselmann | |
285 | 6d4a1656 | Michael Hanselmann | |
286 | cec9845c | Michael Hanselmann | def TestClusterBurnin(): |
287 | cec9845c | Michael Hanselmann | """Burnin"""
|
288 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
289 | cec9845c | Michael Hanselmann | |
290 | 0b0a150a | Iustin Pop | options = qa_config.get('options', {})
|
291 | 0b0a150a | Iustin Pop | disk_template = options.get('burnin-disk-template', 'drbd') |
292 | 0b0a150a | Iustin Pop | parallel = options.get('burnin-in-parallel', False) |
293 | 0b0a150a | Iustin Pop | check_inst = options.get('burnin-check-instances', False) |
294 | 4dc76b24 | Iustin Pop | do_rename = options.get('burnin-rename', '') |
295 | 58598264 | Iustin Pop | do_reboot = options.get('burnin-reboot', True) |
296 | 1d103c02 | Iustin Pop | reboot_types = options.get("reboot-types", constants.REBOOT_TYPES)
|
297 | 23103544 | Michael Hanselmann | |
298 | cec9845c | Michael Hanselmann | # Get as many instances as we need
|
299 | cec9845c | Michael Hanselmann | instances = [] |
300 | cec9845c | Michael Hanselmann | try:
|
301 | 23103544 | Michael Hanselmann | try:
|
302 | 23103544 | Michael Hanselmann | num = qa_config.get('options', {}).get('burnin-instances', 1) |
303 | f1501b3f | Michael Hanselmann | for _ in range(0, num): |
304 | 23103544 | Michael Hanselmann | instances.append(qa_config.AcquireInstance()) |
305 | 23103544 | Michael Hanselmann | except qa_error.OutOfInstancesError:
|
306 | 23103544 | Michael Hanselmann | print "Not enough instances, continuing anyway." |
307 | cec9845c | Michael Hanselmann | |
308 | 23103544 | Michael Hanselmann | if len(instances) < 1: |
309 | 23103544 | Michael Hanselmann | raise qa_error.Error("Burnin needs at least one instance") |
310 | cec9845c | Michael Hanselmann | |
311 | cec9845c | Michael Hanselmann | script = qa_utils.UploadFile(master['primary'], '../tools/burnin') |
312 | cec9845c | Michael Hanselmann | try:
|
313 | 23103544 | Michael Hanselmann | # Run burnin
|
314 | cec9845c | Michael Hanselmann | cmd = [script, |
315 | cec9845c | Michael Hanselmann | '--os=%s' % qa_config.get('os'), |
316 | 1d693311 | Michael Hanselmann | '--disk-size=%s' % ",".join(qa_config.get('disk')), |
317 | 1d693311 | Michael Hanselmann | '--disk-growth=%s' % ",".join(qa_config.get('disk-growth')), |
318 | 23103544 | Michael Hanselmann | '--disk-template=%s' % disk_template]
|
319 | 0b0a150a | Iustin Pop | if parallel:
|
320 | 0b0a150a | Iustin Pop | cmd.append('--parallel')
|
321 | 745c878a | Iustin Pop | cmd.append('--early-release')
|
322 | 0b0a150a | Iustin Pop | if check_inst:
|
323 | 0b0a150a | Iustin Pop | cmd.append('--http-check')
|
324 | 4dc76b24 | Iustin Pop | if do_rename:
|
325 | 4dc76b24 | Iustin Pop | cmd.append('--rename=%s' % do_rename)
|
326 | 58598264 | Iustin Pop | if not do_reboot: |
327 | 58598264 | Iustin Pop | cmd.append('--no-reboot')
|
328 | 1d103c02 | Iustin Pop | else:
|
329 | 1d103c02 | Iustin Pop | cmd.append('--reboot-types=%s' % ",".join(reboot_types)) |
330 | cec9845c | Michael Hanselmann | cmd += [inst['name'] for inst in instances] |
331 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd) |
332 | cec9845c | Michael Hanselmann | finally:
|
333 | 2f4b4f78 | Iustin Pop | AssertCommand(["rm", "-f", script]) |
334 | 2f4b4f78 | Iustin Pop | |
335 | cec9845c | Michael Hanselmann | finally:
|
336 | cec9845c | Michael Hanselmann | for inst in instances: |
337 | cec9845c | Michael Hanselmann | qa_config.ReleaseInstance(inst) |
338 | cec9845c | Michael Hanselmann | |
339 | cec9845c | Michael Hanselmann | |
340 | cec9845c | Michael Hanselmann | def TestClusterMasterFailover(): |
341 | c28502b1 | Iustin Pop | """gnt-cluster master-failover"""
|
342 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
343 | cec9845c | Michael Hanselmann | failovermaster = qa_config.AcquireNode(exclude=master) |
344 | cec9845c | Michael Hanselmann | |
345 | 2f4b4f78 | Iustin Pop | cmd = ["gnt-cluster", "master-failover"] |
346 | 2f4b4f78 | Iustin Pop | try:
|
347 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, node=failovermaster) |
348 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd, node=master) |
349 | cec9845c | Michael Hanselmann | finally:
|
350 | cec9845c | Michael Hanselmann | qa_config.ReleaseNode(failovermaster) |
351 | cec9845c | Michael Hanselmann | |
352 | cec9845c | Michael Hanselmann | |
353 | cec9845c | Michael Hanselmann | def TestClusterCopyfile(): |
354 | cec9845c | Michael Hanselmann | """gnt-cluster copyfile"""
|
355 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
356 | cec9845c | Michael Hanselmann | |
357 | 24818e8f | Michael Hanselmann | uniqueid = utils.NewUUID() |
358 | 830da270 | Michael Hanselmann | |
359 | cec9845c | Michael Hanselmann | # Create temporary file
|
360 | cec9845c | Michael Hanselmann | f = tempfile.NamedTemporaryFile() |
361 | 830da270 | Michael Hanselmann | f.write(uniqueid) |
362 | cec9845c | Michael Hanselmann | f.flush() |
363 | cec9845c | Michael Hanselmann | f.seek(0)
|
364 | cec9845c | Michael Hanselmann | |
365 | cec9845c | Michael Hanselmann | # Upload file to master node
|
366 | cec9845c | Michael Hanselmann | testname = qa_utils.UploadFile(master['primary'], f.name)
|
367 | cec9845c | Michael Hanselmann | try:
|
368 | cec9845c | Michael Hanselmann | # Copy file to all nodes
|
369 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "copyfile", testname]) |
370 | 830da270 | Michael Hanselmann | _CheckFileOnAllNodes(testname, uniqueid) |
371 | cec9845c | Michael Hanselmann | finally:
|
372 | 830da270 | Michael Hanselmann | _RemoveFileFromAllNodes(testname) |
373 | 830da270 | Michael Hanselmann | |
374 | 830da270 | Michael Hanselmann | |
375 | 830da270 | Michael Hanselmann | def TestClusterCommand(): |
376 | 830da270 | Michael Hanselmann | """gnt-cluster command"""
|
377 | 24818e8f | Michael Hanselmann | uniqueid = utils.NewUUID() |
378 | 24818e8f | Michael Hanselmann | rfile = "/tmp/gnt%s" % utils.NewUUID()
|
379 | 830da270 | Michael Hanselmann | rcmd = utils.ShellQuoteArgs(['echo', '-n', uniqueid]) |
380 | 830da270 | Michael Hanselmann | cmd = utils.ShellQuoteArgs(['gnt-cluster', 'command', |
381 | 830da270 | Michael Hanselmann | "%s >%s" % (rcmd, rfile)])
|
382 | 830da270 | Michael Hanselmann | |
383 | 830da270 | Michael Hanselmann | try:
|
384 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd) |
385 | 830da270 | Michael Hanselmann | _CheckFileOnAllNodes(rfile, uniqueid) |
386 | 830da270 | Michael Hanselmann | finally:
|
387 | 830da270 | Michael Hanselmann | _RemoveFileFromAllNodes(rfile) |
388 | cec9845c | Michael Hanselmann | |
389 | cec9845c | Michael Hanselmann | |
390 | cec9845c | Michael Hanselmann | def TestClusterDestroy(): |
391 | cec9845c | Michael Hanselmann | """gnt-cluster destroy"""
|
392 | 2f4b4f78 | Iustin Pop | AssertCommand(["gnt-cluster", "destroy", "--yes-do-it"]) |