root / qa / ganeti-qa.py @ bebe7a73
History | View | Annotate | Download (16.4 kB)
1 | f89d59b9 | Iustin Pop | #!/usr/bin/python -u
|
---|---|---|---|
2 | a8083063 | Iustin Pop | #
|
3 | a8083063 | Iustin Pop | |
4 | 1e7acc3b | Iustin Pop | # Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Google Inc.
|
5 | a8083063 | Iustin Pop | #
|
6 | a8083063 | Iustin Pop | # This program is free software; you can redistribute it and/or modify
|
7 | a8083063 | Iustin Pop | # it under the terms of the GNU General Public License as published by
|
8 | a8083063 | Iustin Pop | # the Free Software Foundation; either version 2 of the License, or
|
9 | a8083063 | Iustin Pop | # (at your option) any later version.
|
10 | a8083063 | Iustin Pop | #
|
11 | a8083063 | Iustin Pop | # This program is distributed in the hope that it will be useful, but
|
12 | a8083063 | Iustin Pop | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | a8083063 | Iustin Pop | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | a8083063 | Iustin Pop | # General Public License for more details.
|
15 | a8083063 | Iustin Pop | #
|
16 | a8083063 | Iustin Pop | # You should have received a copy of the GNU General Public License
|
17 | a8083063 | Iustin Pop | # along with this program; if not, write to the Free Software
|
18 | a8083063 | Iustin Pop | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 | a8083063 | Iustin Pop | # 02110-1301, USA.
|
20 | a8083063 | Iustin Pop | |
21 | a8083063 | Iustin Pop | |
22 | cec9845c | Michael Hanselmann | """Script for doing QA on Ganeti.
|
23 | 94508060 | Michael Hanselmann |
|
24 | 94508060 | Michael Hanselmann | """
|
25 | a8083063 | Iustin Pop | |
26 | b459a848 | Andrea Spadaccini | # pylint: disable=C0103
|
27 | 3582eef6 | Iustin Pop | # due to invalid name
|
28 | 3582eef6 | Iustin Pop | |
29 | a8083063 | Iustin Pop | import sys |
30 | c68d1f43 | Michael Hanselmann | import datetime |
31 | c68d1f43 | Michael Hanselmann | import optparse |
32 | a8083063 | Iustin Pop | |
33 | cec9845c | Michael Hanselmann | import qa_cluster |
34 | cec9845c | Michael Hanselmann | import qa_config |
35 | cec9845c | Michael Hanselmann | import qa_daemon |
36 | cec9845c | Michael Hanselmann | import qa_env |
37 | 30131294 | Adeodato Simo | import qa_group |
38 | cec9845c | Michael Hanselmann | import qa_instance |
39 | cec9845c | Michael Hanselmann | import qa_node |
40 | 8947cf2b | Michael Hanselmann | import qa_os |
41 | a47f574c | Oleksiy Mishchenko | import qa_rapi |
42 | d74c2ca1 | Michael Hanselmann | import qa_tags |
43 | 1672a0d1 | Michael Hanselmann | import qa_utils |
44 | a8083063 | Iustin Pop | |
45 | 725ec2f1 | René Nussbaumer | from ganeti import utils |
46 | 2a7c3583 | Michael Hanselmann | from ganeti import rapi |
47 | f3fd2c9d | Adeodato Simo | from ganeti import constants |
48 | 2a7c3583 | Michael Hanselmann | |
49 | b459a848 | Andrea Spadaccini | import ganeti.rapi.client # pylint: disable=W0611 |
50 | 725ec2f1 | René Nussbaumer | |
51 | a8083063 | Iustin Pop | |
52 | 7d88f255 | Iustin Pop | def _FormatHeader(line, end=72): |
53 | f89d59b9 | Iustin Pop | """Fill a line up to the end column.
|
54 | f89d59b9 | Iustin Pop |
|
55 | f89d59b9 | Iustin Pop | """
|
56 | f89d59b9 | Iustin Pop | line = "---- " + line + " " |
57 | 21bf2e2e | Andrea Spadaccini | line += "-" * (end - len(line)) |
58 | f89d59b9 | Iustin Pop | line = line.rstrip() |
59 | f89d59b9 | Iustin Pop | return line
|
60 | f89d59b9 | Iustin Pop | |
61 | f89d59b9 | Iustin Pop | |
62 | 7d88f255 | Iustin Pop | def _DescriptionOf(fn): |
63 | 7d88f255 | Iustin Pop | """Computes the description of an item.
|
64 | a8083063 | Iustin Pop |
|
65 | a8083063 | Iustin Pop | """
|
66 | cec9845c | Michael Hanselmann | if fn.__doc__:
|
67 | cec9845c | Michael Hanselmann | desc = fn.__doc__.splitlines()[0].strip()
|
68 | a8083063 | Iustin Pop | else:
|
69 | f89d59b9 | Iustin Pop | desc = "%r" % fn
|
70 | a8083063 | Iustin Pop | |
71 | 7d88f255 | Iustin Pop | return desc.rstrip(".") |
72 | 7d88f255 | Iustin Pop | |
73 | 2932dc44 | Michael Hanselmann | |
74 | 7d88f255 | Iustin Pop | def RunTest(fn, *args): |
75 | 7d88f255 | Iustin Pop | """Runs a test after printing a header.
|
76 | 7d88f255 | Iustin Pop |
|
77 | 7d88f255 | Iustin Pop | """
|
78 | a8083063 | Iustin Pop | |
79 | f89d59b9 | Iustin Pop | tstart = datetime.datetime.now() |
80 | a8083063 | Iustin Pop | |
81 | 7d88f255 | Iustin Pop | desc = _DescriptionOf(fn) |
82 | 7d88f255 | Iustin Pop | |
83 | f89d59b9 | Iustin Pop | print
|
84 | f89d59b9 | Iustin Pop | print _FormatHeader("%s start %s" % (tstart, desc)) |
85 | f89d59b9 | Iustin Pop | |
86 | f89d59b9 | Iustin Pop | try:
|
87 | f89d59b9 | Iustin Pop | retval = fn(*args) |
88 | f89d59b9 | Iustin Pop | return retval
|
89 | f89d59b9 | Iustin Pop | finally:
|
90 | f89d59b9 | Iustin Pop | tstop = datetime.datetime.now() |
91 | f89d59b9 | Iustin Pop | tdelta = tstop - tstart |
92 | f89d59b9 | Iustin Pop | print _FormatHeader("%s time=%s %s" % (tstop, tdelta, desc)) |
93 | a8083063 | Iustin Pop | |
94 | a8083063 | Iustin Pop | |
95 | 7d88f255 | Iustin Pop | def RunTestIf(testnames, fn, *args): |
96 | 7d88f255 | Iustin Pop | """Runs a test conditionally.
|
97 | 7d88f255 | Iustin Pop |
|
98 | 7d88f255 | Iustin Pop | @param testnames: either a single test name in the configuration
|
99 | 7d88f255 | Iustin Pop | file, or a list of testnames (which will be AND-ed together)
|
100 | 7d88f255 | Iustin Pop |
|
101 | 7d88f255 | Iustin Pop | """
|
102 | 7d88f255 | Iustin Pop | if qa_config.TestEnabled(testnames):
|
103 | 7d88f255 | Iustin Pop | RunTest(fn, *args) |
104 | 7d88f255 | Iustin Pop | else:
|
105 | 7d88f255 | Iustin Pop | tstart = datetime.datetime.now() |
106 | 7d88f255 | Iustin Pop | desc = _DescriptionOf(fn) |
107 | 7d88f255 | Iustin Pop | print _FormatHeader("%s skipping %s, test(s) %s disabled" % |
108 | 7d88f255 | Iustin Pop | (tstart, desc, testnames)) |
109 | 7d88f255 | Iustin Pop | |
110 | 7d88f255 | Iustin Pop | |
111 | b1ffe1eb | Michael Hanselmann | def RunEnvTests(): |
112 | b1ffe1eb | Michael Hanselmann | """Run several environment tests.
|
113 | a8083063 | Iustin Pop |
|
114 | a8083063 | Iustin Pop | """
|
115 | 7d88f255 | Iustin Pop | RunTestIf("env", qa_env.TestSshConnection)
|
116 | 7d88f255 | Iustin Pop | RunTestIf("env", qa_env.TestIcmpPing)
|
117 | 7d88f255 | Iustin Pop | RunTestIf("env", qa_env.TestGanetiCommands)
|
118 | a8083063 | Iustin Pop | |
119 | 94508060 | Michael Hanselmann | |
120 | 725ec2f1 | René Nussbaumer | def SetupCluster(rapi_user, rapi_secret): |
121 | b1ffe1eb | Michael Hanselmann | """Initializes the cluster.
|
122 | a8083063 | Iustin Pop |
|
123 | 725ec2f1 | René Nussbaumer | @param rapi_user: Login user for RAPI
|
124 | 725ec2f1 | René Nussbaumer | @param rapi_secret: Login secret for RAPI
|
125 | 725ec2f1 | René Nussbaumer |
|
126 | b1ffe1eb | Michael Hanselmann | """
|
127 | 7d88f255 | Iustin Pop | RunTestIf("create-cluster", qa_cluster.TestClusterInit,
|
128 | 7d88f255 | Iustin Pop | rapi_user, rapi_secret) |
129 | 288d6440 | Michael Hanselmann | |
130 | 288d6440 | Michael Hanselmann | # Test on empty cluster
|
131 | 288d6440 | Michael Hanselmann | RunTestIf("node-list", qa_node.TestNodeList)
|
132 | 288d6440 | Michael Hanselmann | RunTestIf("instance-list", qa_instance.TestInstanceList)
|
133 | 288d6440 | Michael Hanselmann | |
134 | 7d88f255 | Iustin Pop | RunTestIf("create-cluster", qa_node.TestNodeAddAll)
|
135 | 7d88f255 | Iustin Pop | if not qa_config.TestEnabled("create-cluster"): |
136 | 8e671b7c | Iustin Pop | # consider the nodes are already there
|
137 | 8e671b7c | Iustin Pop | qa_node.MarkNodeAddedAll() |
138 | 8201b996 | Iustin Pop | |
139 | 7d88f255 | Iustin Pop | RunTestIf("test-jobqueue", qa_cluster.TestJobqueue)
|
140 | cd04f8c2 | Michael Hanselmann | |
141 | 8201b996 | Iustin Pop | # enable the watcher (unconditionally)
|
142 | 8201b996 | Iustin Pop | RunTest(qa_daemon.TestResumeWatcher) |
143 | 8201b996 | Iustin Pop | |
144 | 288d6440 | Michael Hanselmann | RunTestIf("node-list", qa_node.TestNodeList)
|
145 | 288d6440 | Michael Hanselmann | |
146 | 2214cf14 | Michael Hanselmann | # Test listing fields
|
147 | 2214cf14 | Michael Hanselmann | RunTestIf("node-list", qa_node.TestNodeListFields)
|
148 | 2214cf14 | Michael Hanselmann | RunTestIf("instance-list", qa_instance.TestInstanceListFields)
|
149 | 2214cf14 | Michael Hanselmann | |
150 | 7d88f255 | Iustin Pop | RunTestIf("node-info", qa_node.TestNodeInfo)
|
151 | b1ffe1eb | Michael Hanselmann | |
152 | b1ffe1eb | Michael Hanselmann | |
153 | b1ffe1eb | Michael Hanselmann | def RunClusterTests(): |
154 | b1ffe1eb | Michael Hanselmann | """Runs tests related to gnt-cluster.
|
155 | 180bdd1f | Michael Hanselmann |
|
156 | b1ffe1eb | Michael Hanselmann | """
|
157 | 7d88f255 | Iustin Pop | for test, fn in [ |
158 | 92cb4940 | Andrea Spadaccini | ("create-cluster", qa_cluster.TestClusterInitDisk),
|
159 | 7d88f255 | Iustin Pop | ("cluster-renew-crypto", qa_cluster.TestClusterRenewCrypto),
|
160 | 7d88f255 | Iustin Pop | ("cluster-verify", qa_cluster.TestClusterVerify),
|
161 | 7d88f255 | Iustin Pop | ("cluster-reserved-lvs", qa_cluster.TestClusterReservedLvs),
|
162 | 9738ca94 | Iustin Pop | # TODO: add more cluster modify tests
|
163 | 1e7acc3b | Iustin Pop | ("cluster-modify", qa_cluster.TestClusterModifyEmpty),
|
164 | 7d88f255 | Iustin Pop | ("cluster-modify", qa_cluster.TestClusterModifyBe),
|
165 | 92cb4940 | Andrea Spadaccini | ("cluster-modify", qa_cluster.TestClusterModifyDisk),
|
166 | 7d88f255 | Iustin Pop | ("cluster-rename", qa_cluster.TestClusterRename),
|
167 | 7d88f255 | Iustin Pop | ("cluster-info", qa_cluster.TestClusterVersion),
|
168 | 7d88f255 | Iustin Pop | ("cluster-info", qa_cluster.TestClusterInfo),
|
169 | 7d88f255 | Iustin Pop | ("cluster-info", qa_cluster.TestClusterGetmaster),
|
170 | 3e8b5a9c | Iustin Pop | ("cluster-redist-conf", qa_cluster.TestClusterRedistConf),
|
171 | 7d88f255 | Iustin Pop | ("cluster-copyfile", qa_cluster.TestClusterCopyfile),
|
172 | 7d88f255 | Iustin Pop | ("cluster-command", qa_cluster.TestClusterCommand),
|
173 | 7d88f255 | Iustin Pop | ("cluster-burnin", qa_cluster.TestClusterBurnin),
|
174 | 7d88f255 | Iustin Pop | ("cluster-master-failover", qa_cluster.TestClusterMasterFailover),
|
175 | ff699aa9 | Michael Hanselmann | ("cluster-master-failover",
|
176 | ff699aa9 | Michael Hanselmann | qa_cluster.TestClusterMasterFailoverWithDrainedQueue), |
177 | 69df9d2b | Iustin Pop | ("cluster-oob", qa_cluster.TestClusterOob),
|
178 | 7d88f255 | Iustin Pop | ("rapi", qa_rapi.TestVersion),
|
179 | 7d88f255 | Iustin Pop | ("rapi", qa_rapi.TestEmptyCluster),
|
180 | 4fab7cab | Michael Hanselmann | ("rapi", qa_rapi.TestRapiQuery),
|
181 | 7d88f255 | Iustin Pop | ]: |
182 | 7d88f255 | Iustin Pop | RunTestIf(test, fn) |
183 | 8947cf2b | Michael Hanselmann | |
184 | 6d4a1656 | Michael Hanselmann | |
185 | 65a884ef | Iustin Pop | def RunRepairDiskSizes(): |
186 | 65a884ef | Iustin Pop | """Run the repair disk-sizes test.
|
187 | 65a884ef | Iustin Pop |
|
188 | 65a884ef | Iustin Pop | """
|
189 | 65a884ef | Iustin Pop | RunTestIf("cluster-repair-disk-sizes", qa_cluster.TestClusterRepairDiskSizes)
|
190 | 65a884ef | Iustin Pop | |
191 | 65a884ef | Iustin Pop | |
192 | b1ffe1eb | Michael Hanselmann | def RunOsTests(): |
193 | b1ffe1eb | Michael Hanselmann | """Runs all tests related to gnt-os.
|
194 | 5d640672 | Michael Hanselmann |
|
195 | b1ffe1eb | Michael Hanselmann | """
|
196 | 2932dc44 | Michael Hanselmann | if qa_config.TestEnabled("rapi"): |
197 | 2932dc44 | Michael Hanselmann | rapi_getos = qa_rapi.GetOperatingSystems |
198 | 2932dc44 | Michael Hanselmann | else:
|
199 | 2932dc44 | Michael Hanselmann | rapi_getos = None
|
200 | 2932dc44 | Michael Hanselmann | |
201 | 7d88f255 | Iustin Pop | for fn in [ |
202 | 7d88f255 | Iustin Pop | qa_os.TestOsList, |
203 | 7d88f255 | Iustin Pop | qa_os.TestOsDiagnose, |
204 | 2932dc44 | Michael Hanselmann | ]: |
205 | 2932dc44 | Michael Hanselmann | RunTestIf("os", fn)
|
206 | 2932dc44 | Michael Hanselmann | |
207 | 2932dc44 | Michael Hanselmann | for fn in [ |
208 | 7d88f255 | Iustin Pop | qa_os.TestOsValid, |
209 | 7d88f255 | Iustin Pop | qa_os.TestOsInvalid, |
210 | 7d88f255 | Iustin Pop | qa_os.TestOsPartiallyValid, |
211 | 2932dc44 | Michael Hanselmann | ]: |
212 | 2932dc44 | Michael Hanselmann | RunTestIf("os", fn, rapi_getos)
|
213 | 2932dc44 | Michael Hanselmann | |
214 | 2932dc44 | Michael Hanselmann | for fn in [ |
215 | 7d88f255 | Iustin Pop | qa_os.TestOsModifyValid, |
216 | 7d88f255 | Iustin Pop | qa_os.TestOsModifyInvalid, |
217 | 074e139f | Michael Hanselmann | qa_os.TestOsStatesNonExisting, |
218 | 7d88f255 | Iustin Pop | ]: |
219 | 7d88f255 | Iustin Pop | RunTestIf("os", fn)
|
220 | b1ffe1eb | Michael Hanselmann | |
221 | b1ffe1eb | Michael Hanselmann | |
222 | b1ffe1eb | Michael Hanselmann | def RunCommonInstanceTests(instance): |
223 | b1ffe1eb | Michael Hanselmann | """Runs a few tests that are common to all disk types.
|
224 | b1ffe1eb | Michael Hanselmann |
|
225 | b1ffe1eb | Michael Hanselmann | """
|
226 | 7d88f255 | Iustin Pop | RunTestIf("instance-shutdown", qa_instance.TestInstanceShutdown, instance)
|
227 | b82d4c5e | Michael Hanselmann | RunTestIf(["instance-shutdown", "instance-console", "rapi"], |
228 | b82d4c5e | Michael Hanselmann | qa_rapi.TestRapiStoppedInstanceConsole, instance) |
229 | 3016bc1f | Michael Hanselmann | RunTestIf(["instance-shutdown", "instance-modify"], |
230 | 3016bc1f | Michael Hanselmann | qa_instance.TestInstanceStoppedModify, instance) |
231 | 7d88f255 | Iustin Pop | RunTestIf("instance-shutdown", qa_instance.TestInstanceStartup, instance)
|
232 | a8083063 | Iustin Pop | |
233 | a7418448 | Michael Hanselmann | # Test shutdown/start via RAPI
|
234 | a7418448 | Michael Hanselmann | RunTestIf(["instance-shutdown", "rapi"], |
235 | a7418448 | Michael Hanselmann | qa_rapi.TestRapiInstanceShutdown, instance) |
236 | a7418448 | Michael Hanselmann | RunTestIf(["instance-shutdown", "rapi"], |
237 | a7418448 | Michael Hanselmann | qa_rapi.TestRapiInstanceStartup, instance) |
238 | a7418448 | Michael Hanselmann | |
239 | 7d88f255 | Iustin Pop | RunTestIf("instance-list", qa_instance.TestInstanceList)
|
240 | 283f9d4c | Michael Hanselmann | |
241 | 7d88f255 | Iustin Pop | RunTestIf("instance-info", qa_instance.TestInstanceInfo, instance)
|
242 | e9e35aaa | Michael Hanselmann | |
243 | 7d88f255 | Iustin Pop | RunTestIf("instance-modify", qa_instance.TestInstanceModify, instance)
|
244 | 7d88f255 | Iustin Pop | RunTestIf(["instance-modify", "rapi"], |
245 | 7d88f255 | Iustin Pop | qa_rapi.TestRapiInstanceModify, instance) |
246 | c0f74c55 | Iustin Pop | |
247 | 7d88f255 | Iustin Pop | RunTestIf("instance-console", qa_instance.TestInstanceConsole, instance)
|
248 | b82d4c5e | Michael Hanselmann | RunTestIf(["instance-console", "rapi"], |
249 | b82d4c5e | Michael Hanselmann | qa_rapi.TestRapiInstanceConsole, instance) |
250 | 4379b1fa | Michael Hanselmann | |
251 | 4c1a464b | Iustin Pop | DOWN_TESTS = ["instance-reinstall", "instance-rename"] |
252 | 4c1a464b | Iustin Pop | # shutdown instance for any 'down' tests
|
253 | 4c1a464b | Iustin Pop | RunTestIf(DOWN_TESTS, qa_instance.TestInstanceShutdown, instance) |
254 | 4c1a464b | Iustin Pop | |
255 | 4c1a464b | Iustin Pop | # now run the 'down' state tests
|
256 | 7d88f255 | Iustin Pop | RunTestIf("instance-reinstall", qa_instance.TestInstanceReinstall, instance)
|
257 | 0220d2cf | Guido Trotter | RunTestIf(["instance-reinstall", "rapi"], |
258 | 0220d2cf | Guido Trotter | qa_rapi.TestRapiInstanceReinstall, instance) |
259 | 4c1a464b | Iustin Pop | # RAPI reinstall will leave the instance up by default, so we have
|
260 | 4c1a464b | Iustin Pop | # to stop it again
|
261 | 4c1a464b | Iustin Pop | RunTestIf(["instance-reinstall", "rapi"], |
262 | 4c1a464b | Iustin Pop | qa_rapi.TestRapiInstanceShutdown, instance) |
263 | 8a4e8898 | Michael Hanselmann | |
264 | d0c8c01d | Iustin Pop | if qa_config.TestEnabled("instance-rename"): |
265 | e5c2accd | Guido Trotter | rename_source = instance["name"]
|
266 | 7fb50870 | Michael Hanselmann | rename_target = qa_config.get("rename", None) |
267 | 46747143 | Guido Trotter | # perform instance rename to the same name
|
268 | 4c1a464b | Iustin Pop | RunTest(qa_instance.TestInstanceRenameAndBack, |
269 | 4c1a464b | Iustin Pop | rename_source, rename_source) |
270 | 4c1a464b | Iustin Pop | RunTestIf("rapi", qa_rapi.TestRapiInstanceRenameAndBack,
|
271 | 930e77d1 | Michael Hanselmann | rename_source, rename_source) |
272 | 46747143 | Guido Trotter | if rename_target is not None: |
273 | 46747143 | Guido Trotter | # perform instance rename to a different name, if we have one configured
|
274 | 4c1a464b | Iustin Pop | RunTest(qa_instance.TestInstanceRenameAndBack, |
275 | 4c1a464b | Iustin Pop | rename_source, rename_target) |
276 | 4c1a464b | Iustin Pop | RunTestIf("rapi", qa_rapi.TestRapiInstanceRenameAndBack,
|
277 | 930e77d1 | Michael Hanselmann | rename_source, rename_target) |
278 | 4c1a464b | Iustin Pop | |
279 | 4c1a464b | Iustin Pop | # and now start the instance again
|
280 | 4c1a464b | Iustin Pop | RunTestIf(DOWN_TESTS, qa_instance.TestInstanceStartup, instance) |
281 | 4c1a464b | Iustin Pop | |
282 | 4c1a464b | Iustin Pop | RunTestIf("instance-reboot", qa_instance.TestInstanceReboot, instance)
|
283 | 18337ca9 | Iustin Pop | |
284 | 7d88f255 | Iustin Pop | RunTestIf("tags", qa_tags.TestInstanceTags, instance)
|
285 | d74c2ca1 | Michael Hanselmann | |
286 | 1ef6e776 | Michael Hanselmann | RunTestIf("cluster-verify", qa_cluster.TestClusterVerify)
|
287 | d74c2ca1 | Michael Hanselmann | |
288 | 7d88f255 | Iustin Pop | RunTestIf("rapi", qa_rapi.TestInstance, instance)
|
289 | 729c4377 | Iustin Pop | |
290 | 288d6440 | Michael Hanselmann | # Lists instances, too
|
291 | 288d6440 | Michael Hanselmann | RunTestIf("node-list", qa_node.TestNodeList)
|
292 | 288d6440 | Michael Hanselmann | |
293 | 729c4377 | Iustin Pop | |
294 | 729c4377 | Iustin Pop | def RunCommonNodeTests(): |
295 | 729c4377 | Iustin Pop | """Run a few common node tests.
|
296 | 729c4377 | Iustin Pop |
|
297 | 729c4377 | Iustin Pop | """
|
298 | 7d88f255 | Iustin Pop | RunTestIf("node-volumes", qa_node.TestNodeVolumes)
|
299 | 7d88f255 | Iustin Pop | RunTestIf("node-storage", qa_node.TestNodeStorage)
|
300 | a1de4b18 | René Nussbaumer | RunTestIf("node-oob", qa_node.TestOutOfBand)
|
301 | 8e1db003 | Michael Hanselmann | |
302 | 8d8d650c | Michael Hanselmann | |
303 | 30131294 | Adeodato Simo | def RunGroupListTests(): |
304 | 30131294 | Adeodato Simo | """Run tests for listing node groups.
|
305 | 30131294 | Adeodato Simo |
|
306 | 30131294 | Adeodato Simo | """
|
307 | 7ab8b7d7 | Adeodato Simo | RunTestIf("group-list", qa_group.TestGroupList)
|
308 | 7ab8b7d7 | Adeodato Simo | RunTestIf("group-list", qa_group.TestGroupListFields)
|
309 | 30131294 | Adeodato Simo | |
310 | 30131294 | Adeodato Simo | |
311 | 66787da5 | Adeodato Simo | def RunGroupRwTests(): |
312 | 66787da5 | Adeodato Simo | """Run tests for adding/removing/renaming groups.
|
313 | 66787da5 | Adeodato Simo |
|
314 | 66787da5 | Adeodato Simo | """
|
315 | 66787da5 | Adeodato Simo | RunTestIf("group-rwops", qa_group.TestGroupAddRemoveRename)
|
316 | 4b10fb65 | Adeodato Simo | RunTestIf("group-rwops", qa_group.TestGroupAddWithOptions)
|
317 | 4b10fb65 | Adeodato Simo | RunTestIf("group-rwops", qa_group.TestGroupModify)
|
318 | b9e478fe | Michael Hanselmann | RunTestIf(["group-rwops", "rapi"], qa_rapi.TestRapiNodeGroups) |
319 | fe508a9d | Michael Hanselmann | RunTestIf(["group-rwops", "tags"], qa_tags.TestGroupTags, |
320 | fe508a9d | Michael Hanselmann | qa_group.GetDefaultGroup()) |
321 | 4b10fb65 | Adeodato Simo | |
322 | 66787da5 | Adeodato Simo | |
323 | 638a7266 | Iustin Pop | def RunExportImportTests(instance, pnode, snode): |
324 | b1ffe1eb | Michael Hanselmann | """Tries to export and import the instance.
|
325 | a8083063 | Iustin Pop |
|
326 | 638a7266 | Iustin Pop | @param pnode: current primary node of the instance
|
327 | 638a7266 | Iustin Pop | @param snode: current secondary node of the instance, if any,
|
328 | 638a7266 | Iustin Pop | otherwise None
|
329 | 638a7266 | Iustin Pop |
|
330 | b1ffe1eb | Michael Hanselmann | """
|
331 | d0c8c01d | Iustin Pop | if qa_config.TestEnabled("instance-export"): |
332 | bc696589 | Michael Hanselmann | RunTest(qa_instance.TestInstanceExportNoTarget, instance) |
333 | bc696589 | Michael Hanselmann | |
334 | b1ffe1eb | Michael Hanselmann | expnode = qa_config.AcquireNode(exclude=pnode) |
335 | b1ffe1eb | Michael Hanselmann | try:
|
336 | b1ffe1eb | Michael Hanselmann | name = RunTest(qa_instance.TestInstanceExport, instance, expnode) |
337 | b1ffe1eb | Michael Hanselmann | |
338 | b1ffe1eb | Michael Hanselmann | RunTest(qa_instance.TestBackupList, expnode) |
339 | b1ffe1eb | Michael Hanselmann | |
340 | d0c8c01d | Iustin Pop | if qa_config.TestEnabled("instance-import"): |
341 | b1ffe1eb | Michael Hanselmann | newinst = qa_config.AcquireInstance() |
342 | 5d640672 | Michael Hanselmann | try:
|
343 | b1ffe1eb | Michael Hanselmann | RunTest(qa_instance.TestInstanceImport, pnode, newinst, |
344 | b1ffe1eb | Michael Hanselmann | expnode, name) |
345 | b1ffe1eb | Michael Hanselmann | RunTest(qa_instance.TestInstanceRemove, newinst) |
346 | 5d640672 | Michael Hanselmann | finally:
|
347 | b1ffe1eb | Michael Hanselmann | qa_config.ReleaseInstance(newinst) |
348 | b1ffe1eb | Michael Hanselmann | finally:
|
349 | b1ffe1eb | Michael Hanselmann | qa_config.ReleaseNode(expnode) |
350 | 5d640672 | Michael Hanselmann | |
351 | 7d88f255 | Iustin Pop | if qa_config.TestEnabled(["rapi", "inter-cluster-instance-move"]): |
352 | 5d831182 | Michael Hanselmann | newinst = qa_config.AcquireInstance() |
353 | 5d831182 | Michael Hanselmann | try:
|
354 | 638a7266 | Iustin Pop | if snode is None: |
355 | 638a7266 | Iustin Pop | excl = [pnode] |
356 | 638a7266 | Iustin Pop | else:
|
357 | 638a7266 | Iustin Pop | excl = [pnode, snode] |
358 | 638a7266 | Iustin Pop | tnode = qa_config.AcquireNode(exclude=excl) |
359 | 5d831182 | Michael Hanselmann | try:
|
360 | 5d831182 | Michael Hanselmann | RunTest(qa_rapi.TestInterClusterInstanceMove, instance, newinst, |
361 | 638a7266 | Iustin Pop | pnode, snode, tnode) |
362 | 5d831182 | Michael Hanselmann | finally:
|
363 | 638a7266 | Iustin Pop | qa_config.ReleaseNode(tnode) |
364 | 5d831182 | Michael Hanselmann | finally:
|
365 | 5d831182 | Michael Hanselmann | qa_config.ReleaseInstance(newinst) |
366 | 5d831182 | Michael Hanselmann | |
367 | 283f9d4c | Michael Hanselmann | |
368 | b998270c | Iustin Pop | def RunDaemonTests(instance): |
369 | b1ffe1eb | Michael Hanselmann | """Test the ganeti-watcher script.
|
370 | 9df6d173 | Michael Hanselmann |
|
371 | b1ffe1eb | Michael Hanselmann | """
|
372 | 8201b996 | Iustin Pop | RunTest(qa_daemon.TestPauseWatcher) |
373 | e9e35aaa | Michael Hanselmann | |
374 | 7d88f255 | Iustin Pop | RunTestIf("instance-automatic-restart",
|
375 | b998270c | Iustin Pop | qa_daemon.TestInstanceAutomaticRestart, instance) |
376 | 7d88f255 | Iustin Pop | RunTestIf("instance-consecutive-failures",
|
377 | b998270c | Iustin Pop | qa_daemon.TestInstanceConsecutiveFailures, instance) |
378 | e9e35aaa | Michael Hanselmann | |
379 | 8201b996 | Iustin Pop | RunTest(qa_daemon.TestResumeWatcher) |
380 | 8201b996 | Iustin Pop | |
381 | 9df6d173 | Michael Hanselmann | |
382 | b1ffe1eb | Michael Hanselmann | def RunHardwareFailureTests(instance, pnode, snode): |
383 | b1ffe1eb | Michael Hanselmann | """Test cluster internal hardware failure recovery.
|
384 | a8083063 | Iustin Pop |
|
385 | b1ffe1eb | Michael Hanselmann | """
|
386 | 7d88f255 | Iustin Pop | RunTestIf("instance-failover", qa_instance.TestInstanceFailover, instance)
|
387 | c0a146a1 | Michael Hanselmann | RunTestIf(["instance-failover", "rapi"], |
388 | c0a146a1 | Michael Hanselmann | qa_rapi.TestRapiInstanceFailover, instance) |
389 | b1ffe1eb | Michael Hanselmann | |
390 | 7d88f255 | Iustin Pop | RunTestIf("instance-migrate", qa_instance.TestInstanceMigrate, instance)
|
391 | 7d88f255 | Iustin Pop | RunTestIf(["instance-migrate", "rapi"], |
392 | 7d88f255 | Iustin Pop | qa_rapi.TestRapiInstanceMigrate, instance) |
393 | 938bde86 | Michael Hanselmann | |
394 | d0c8c01d | Iustin Pop | if qa_config.TestEnabled("instance-replace-disks"): |
395 | 76f59a32 | Michael Hanselmann | othernode = qa_config.AcquireNode(exclude=[pnode, snode]) |
396 | 7910e7a5 | Michael Hanselmann | try:
|
397 | 539d65ba | Michael Hanselmann | RunTestIf("rapi", qa_rapi.TestRapiInstanceReplaceDisks, instance)
|
398 | 7910e7a5 | Michael Hanselmann | RunTest(qa_instance.TestReplaceDisks, |
399 | 7910e7a5 | Michael Hanselmann | instance, pnode, snode, othernode) |
400 | 7910e7a5 | Michael Hanselmann | finally:
|
401 | 7910e7a5 | Michael Hanselmann | qa_config.ReleaseNode(othernode) |
402 | 7910e7a5 | Michael Hanselmann | |
403 | 7d88f255 | Iustin Pop | RunTestIf("node-evacuate", qa_node.TestNodeEvacuate, pnode, snode)
|
404 | b1ffe1eb | Michael Hanselmann | |
405 | 7d88f255 | Iustin Pop | RunTestIf("node-failover", qa_node.TestNodeFailover, pnode, snode)
|
406 | b1ffe1eb | Michael Hanselmann | |
407 | 7d88f255 | Iustin Pop | RunTestIf("instance-disk-failure", qa_instance.TestInstanceMasterDiskFailure,
|
408 | b1ffe1eb | Michael Hanselmann | instance, pnode, snode) |
409 | 7d88f255 | Iustin Pop | RunTestIf("instance-disk-failure",
|
410 | 7d88f255 | Iustin Pop | qa_instance.TestInstanceSecondaryDiskFailure, instance, |
411 | 7d88f255 | Iustin Pop | pnode, snode) |
412 | b1ffe1eb | Michael Hanselmann | |
413 | b1ffe1eb | Michael Hanselmann | |
414 | f7e6f3c8 | Iustin Pop | def RunQa(): |
415 | f7e6f3c8 | Iustin Pop | """Main QA body.
|
416 | b1ffe1eb | Michael Hanselmann |
|
417 | b1ffe1eb | Michael Hanselmann | """
|
418 | 725ec2f1 | René Nussbaumer | rapi_user = "ganeti-qa"
|
419 | 725ec2f1 | René Nussbaumer | rapi_secret = utils.GenerateSecret() |
420 | 725ec2f1 | René Nussbaumer | |
421 | b1ffe1eb | Michael Hanselmann | RunEnvTests() |
422 | 725ec2f1 | René Nussbaumer | SetupCluster(rapi_user, rapi_secret) |
423 | 2771835c | Michael Hanselmann | |
424 | 2771835c | Michael Hanselmann | # Load RAPI certificate
|
425 | 76917d97 | Iustin Pop | qa_rapi.Setup(rapi_user, rapi_secret) |
426 | 2771835c | Michael Hanselmann | |
427 | b1ffe1eb | Michael Hanselmann | RunClusterTests() |
428 | b1ffe1eb | Michael Hanselmann | RunOsTests() |
429 | 4b62db14 | Michael Hanselmann | |
430 | 7d88f255 | Iustin Pop | RunTestIf("tags", qa_tags.TestClusterTags)
|
431 | d74c2ca1 | Michael Hanselmann | |
432 | 729c4377 | Iustin Pop | RunCommonNodeTests() |
433 | 30131294 | Adeodato Simo | RunGroupListTests() |
434 | 66787da5 | Adeodato Simo | RunGroupRwTests() |
435 | 729c4377 | Iustin Pop | |
436 | d0cb68cb | Michael Hanselmann | pnode = qa_config.AcquireNode(exclude=qa_config.GetMasterNode()) |
437 | d0cb68cb | Michael Hanselmann | try:
|
438 | 7d88f255 | Iustin Pop | RunTestIf("node-readd", qa_node.TestNodeReadd, pnode)
|
439 | 7d88f255 | Iustin Pop | RunTestIf("node-modify", qa_node.TestNodeModify, pnode)
|
440 | 5a85b99e | Michael Hanselmann | RunTestIf("delay", qa_cluster.TestDelay, pnode)
|
441 | d0cb68cb | Michael Hanselmann | finally:
|
442 | d0cb68cb | Michael Hanselmann | qa_config.ReleaseNode(pnode) |
443 | 102b115b | Michael Hanselmann | |
444 | b1ffe1eb | Michael Hanselmann | pnode = qa_config.AcquireNode() |
445 | b1ffe1eb | Michael Hanselmann | try:
|
446 | 7d88f255 | Iustin Pop | RunTestIf("tags", qa_tags.TestNodeTags, pnode)
|
447 | d74c2ca1 | Michael Hanselmann | |
448 | a47f574c | Oleksiy Mishchenko | if qa_rapi.Enabled():
|
449 | a47f574c | Oleksiy Mishchenko | RunTest(qa_rapi.TestNode, pnode) |
450 | a47f574c | Oleksiy Mishchenko | |
451 | 8cb70e56 | Michael Hanselmann | if qa_config.TestEnabled("instance-add-plain-disk"): |
452 | 924e95f9 | Michael Hanselmann | for use_client in [True, False]: |
453 | 924e95f9 | Michael Hanselmann | rapi_instance = RunTest(qa_rapi.TestRapiInstanceAdd, pnode, |
454 | 924e95f9 | Michael Hanselmann | use_client) |
455 | 924e95f9 | Michael Hanselmann | RunCommonInstanceTests(rapi_instance) |
456 | 924e95f9 | Michael Hanselmann | RunTest(qa_rapi.TestRapiInstanceRemove, rapi_instance, use_client) |
457 | 924e95f9 | Michael Hanselmann | del rapi_instance
|
458 | 8cb70e56 | Michael Hanselmann | |
459 | 65a884ef | Iustin Pop | if qa_config.TestEnabled("instance-add-plain-disk"): |
460 | b1ffe1eb | Michael Hanselmann | instance = RunTest(qa_instance.TestInstanceAddWithPlainDisk, pnode) |
461 | b1ffe1eb | Michael Hanselmann | RunCommonInstanceTests(instance) |
462 | 30131294 | Adeodato Simo | RunGroupListTests() |
463 | 24fed61e | René Nussbaumer | RunTestIf("cluster-epo", qa_cluster.TestClusterEpo)
|
464 | 638a7266 | Iustin Pop | RunExportImportTests(instance, pnode, None)
|
465 | b998270c | Iustin Pop | RunDaemonTests(instance) |
466 | 65a884ef | Iustin Pop | RunRepairDiskSizes() |
467 | b1ffe1eb | Michael Hanselmann | RunTest(qa_instance.TestInstanceRemove, instance) |
468 | b1ffe1eb | Michael Hanselmann | del instance
|
469 | 9df6d173 | Michael Hanselmann | |
470 | 7d7609a3 | Michael Hanselmann | multinode_tests = [ |
471 | d0c8c01d | Iustin Pop | ("instance-add-drbd-disk",
|
472 | 7d7609a3 | Michael Hanselmann | qa_instance.TestInstanceAddWithDrbdDisk), |
473 | 7d7609a3 | Michael Hanselmann | ] |
474 | 7d7609a3 | Michael Hanselmann | |
475 | 7d7609a3 | Michael Hanselmann | for name, func in multinode_tests: |
476 | 7d7609a3 | Michael Hanselmann | if qa_config.TestEnabled(name):
|
477 | 7d7609a3 | Michael Hanselmann | snode = qa_config.AcquireNode(exclude=pnode) |
478 | 7d7609a3 | Michael Hanselmann | try:
|
479 | 7d7609a3 | Michael Hanselmann | instance = RunTest(func, pnode, snode) |
480 | 7d7609a3 | Michael Hanselmann | RunCommonInstanceTests(instance) |
481 | 30131294 | Adeodato Simo | RunGroupListTests() |
482 | f3fd2c9d | Adeodato Simo | RunTest(qa_group.TestAssignNodesIncludingSplit, |
483 | f3fd2c9d | Adeodato Simo | constants.INITIAL_NODE_GROUP_NAME, |
484 | f3fd2c9d | Adeodato Simo | pnode["primary"], snode["primary"]) |
485 | d0c8c01d | Iustin Pop | if qa_config.TestEnabled("instance-convert-disk"): |
486 | f9f0ce7f | Guido Trotter | RunTest(qa_instance.TestInstanceShutdown, instance) |
487 | 7f69aabb | Iustin Pop | RunTest(qa_instance.TestInstanceConvertDisk, instance, snode) |
488 | f9f0ce7f | Guido Trotter | RunTest(qa_instance.TestInstanceStartup, instance) |
489 | 638a7266 | Iustin Pop | RunExportImportTests(instance, pnode, snode) |
490 | 7d7609a3 | Michael Hanselmann | RunHardwareFailureTests(instance, pnode, snode) |
491 | 65a884ef | Iustin Pop | RunRepairDiskSizes() |
492 | 7d7609a3 | Michael Hanselmann | RunTest(qa_instance.TestInstanceRemove, instance) |
493 | 7d7609a3 | Michael Hanselmann | del instance
|
494 | 7d7609a3 | Michael Hanselmann | finally:
|
495 | 7d7609a3 | Michael Hanselmann | qa_config.ReleaseNode(snode) |
496 | a8083063 | Iustin Pop | |
497 | 7d88f255 | Iustin Pop | if qa_config.TestEnabled(["instance-add-plain-disk", "instance-export"]): |
498 | 3b01286e | Michael Hanselmann | for shutdown in [False, True]: |
499 | 3b01286e | Michael Hanselmann | instance = RunTest(qa_instance.TestInstanceAddWithPlainDisk, pnode) |
500 | 3b01286e | Michael Hanselmann | expnode = qa_config.AcquireNode(exclude=pnode) |
501 | 3b01286e | Michael Hanselmann | try:
|
502 | 3b01286e | Michael Hanselmann | if shutdown:
|
503 | 3b01286e | Michael Hanselmann | # Stop instance before exporting and removing it
|
504 | 3b01286e | Michael Hanselmann | RunTest(qa_instance.TestInstanceShutdown, instance) |
505 | 3b01286e | Michael Hanselmann | RunTest(qa_instance.TestInstanceExportWithRemove, instance, expnode) |
506 | 3b01286e | Michael Hanselmann | RunTest(qa_instance.TestBackupList, expnode) |
507 | 3b01286e | Michael Hanselmann | finally:
|
508 | 3b01286e | Michael Hanselmann | qa_config.ReleaseNode(expnode) |
509 | 3b01286e | Michael Hanselmann | del expnode
|
510 | 3b01286e | Michael Hanselmann | del instance
|
511 | 8d8d650c | Michael Hanselmann | |
512 | a8083063 | Iustin Pop | finally:
|
513 | b1ffe1eb | Michael Hanselmann | qa_config.ReleaseNode(pnode) |
514 | a8083063 | Iustin Pop | |
515 | 7d88f255 | Iustin Pop | RunTestIf("create-cluster", qa_node.TestNodeRemoveAll)
|
516 | a8083063 | Iustin Pop | |
517 | 7d88f255 | Iustin Pop | RunTestIf("cluster-destroy", qa_cluster.TestClusterDestroy)
|
518 | a8083063 | Iustin Pop | |
519 | cec9845c | Michael Hanselmann | |
520 | f7e6f3c8 | Iustin Pop | @rapi.client.UsesRapiClient
|
521 | f7e6f3c8 | Iustin Pop | def main(): |
522 | f7e6f3c8 | Iustin Pop | """Main program.
|
523 | f7e6f3c8 | Iustin Pop |
|
524 | f7e6f3c8 | Iustin Pop | """
|
525 | f7e6f3c8 | Iustin Pop | parser = optparse.OptionParser(usage="%prog [options] <config-file>")
|
526 | d0c8c01d | Iustin Pop | parser.add_option("--yes-do-it", dest="yes_do_it", |
527 | f7e6f3c8 | Iustin Pop | action="store_true",
|
528 | f7e6f3c8 | Iustin Pop | help="Really execute the tests")
|
529 | f7e6f3c8 | Iustin Pop | (qa_config.options, args) = parser.parse_args() |
530 | f7e6f3c8 | Iustin Pop | |
531 | f7e6f3c8 | Iustin Pop | if len(args) == 1: |
532 | f7e6f3c8 | Iustin Pop | (config_file, ) = args |
533 | f7e6f3c8 | Iustin Pop | else:
|
534 | f7e6f3c8 | Iustin Pop | parser.error("Wrong number of arguments.")
|
535 | f7e6f3c8 | Iustin Pop | |
536 | f7e6f3c8 | Iustin Pop | if not qa_config.options.yes_do_it: |
537 | f7e6f3c8 | Iustin Pop | print ("Executing this script irreversibly destroys any Ganeti\n" |
538 | f7e6f3c8 | Iustin Pop | "configuration on all nodes involved. If you really want\n"
|
539 | f7e6f3c8 | Iustin Pop | "to start testing, supply the --yes-do-it option.")
|
540 | f7e6f3c8 | Iustin Pop | sys.exit(1)
|
541 | f7e6f3c8 | Iustin Pop | |
542 | f7e6f3c8 | Iustin Pop | qa_config.Load(config_file) |
543 | f7e6f3c8 | Iustin Pop | |
544 | f7e6f3c8 | Iustin Pop | qa_utils.StartMultiplexer(qa_config.GetMasterNode()["primary"])
|
545 | f7e6f3c8 | Iustin Pop | try:
|
546 | f7e6f3c8 | Iustin Pop | RunQa() |
547 | f7e6f3c8 | Iustin Pop | finally:
|
548 | f7e6f3c8 | Iustin Pop | qa_utils.CloseMultiplexers() |
549 | f7e6f3c8 | Iustin Pop | |
550 | d0c8c01d | Iustin Pop | if __name__ == "__main__": |
551 | cec9845c | Michael Hanselmann | main() |