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