root / qa / ganeti-qa.py @ f006f110
History | View | Annotate | Download (21 kB)
1 | f89d59b9 | Iustin Pop | #!/usr/bin/python -u
|
---|---|---|---|
2 | a8083063 | Iustin Pop | #
|
3 | a8083063 | Iustin Pop | |
4 | 50ef6a41 | Bernardo Dal Seno | # Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 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 | 83180411 | Bernardo Dal Seno | import qa_error |
38 | 30131294 | Adeodato Simo | import qa_group |
39 | cec9845c | Michael Hanselmann | import qa_instance |
40 | cec9845c | Michael Hanselmann | import qa_node |
41 | 8947cf2b | Michael Hanselmann | import qa_os |
42 | 09470dd8 | Michael Hanselmann | import qa_job |
43 | a47f574c | Oleksiy Mishchenko | import qa_rapi |
44 | d74c2ca1 | Michael Hanselmann | import qa_tags |
45 | 1672a0d1 | Michael Hanselmann | import qa_utils |
46 | a8083063 | Iustin Pop | |
47 | 725ec2f1 | René Nussbaumer | from ganeti import utils |
48 | 8ad0da1e | Iustin Pop | from ganeti import rapi # pylint: disable=W0611 |
49 | f3fd2c9d | Adeodato Simo | from ganeti import constants |
50 | 2a7c3583 | Michael Hanselmann | |
51 | b459a848 | Andrea Spadaccini | import ganeti.rapi.client # pylint: disable=W0611 |
52 | fc3f75dd | Iustin Pop | from ganeti.rapi.client import UsesRapiClient |
53 | 725ec2f1 | René Nussbaumer | |
54 | a8083063 | Iustin Pop | |
55 | 7d88f255 | Iustin Pop | def _FormatHeader(line, end=72): |
56 | f89d59b9 | Iustin Pop | """Fill a line up to the end column.
|
57 | f89d59b9 | Iustin Pop |
|
58 | f89d59b9 | Iustin Pop | """
|
59 | f89d59b9 | Iustin Pop | line = "---- " + line + " " |
60 | 21bf2e2e | Andrea Spadaccini | line += "-" * (end - len(line)) |
61 | f89d59b9 | Iustin Pop | line = line.rstrip() |
62 | f89d59b9 | Iustin Pop | return line
|
63 | f89d59b9 | Iustin Pop | |
64 | f89d59b9 | Iustin Pop | |
65 | 7d88f255 | Iustin Pop | def _DescriptionOf(fn): |
66 | 7d88f255 | Iustin Pop | """Computes the description of an item.
|
67 | a8083063 | Iustin Pop |
|
68 | a8083063 | Iustin Pop | """
|
69 | cec9845c | Michael Hanselmann | if fn.__doc__:
|
70 | cec9845c | Michael Hanselmann | desc = fn.__doc__.splitlines()[0].strip()
|
71 | a8083063 | Iustin Pop | else:
|
72 | f89d59b9 | Iustin Pop | desc = "%r" % fn
|
73 | a8083063 | Iustin Pop | |
74 | 7d88f255 | Iustin Pop | return desc.rstrip(".") |
75 | 7d88f255 | Iustin Pop | |
76 | 2932dc44 | Michael Hanselmann | |
77 | 741c6d91 | Michael Hanselmann | def RunTest(fn, *args, **kwargs): |
78 | 7d88f255 | Iustin Pop | """Runs a test after printing a header.
|
79 | 7d88f255 | Iustin Pop |
|
80 | 7d88f255 | Iustin Pop | """
|
81 | a8083063 | Iustin Pop | |
82 | f89d59b9 | Iustin Pop | tstart = datetime.datetime.now() |
83 | a8083063 | Iustin Pop | |
84 | 7d88f255 | Iustin Pop | desc = _DescriptionOf(fn) |
85 | 7d88f255 | Iustin Pop | |
86 | f89d59b9 | Iustin Pop | print
|
87 | f89d59b9 | Iustin Pop | print _FormatHeader("%s start %s" % (tstart, desc)) |
88 | f89d59b9 | Iustin Pop | |
89 | f89d59b9 | Iustin Pop | try:
|
90 | 741c6d91 | Michael Hanselmann | retval = fn(*args, **kwargs) |
91 | f89d59b9 | Iustin Pop | return retval
|
92 | f89d59b9 | Iustin Pop | finally:
|
93 | f89d59b9 | Iustin Pop | tstop = datetime.datetime.now() |
94 | f89d59b9 | Iustin Pop | tdelta = tstop - tstart |
95 | f89d59b9 | Iustin Pop | print _FormatHeader("%s time=%s %s" % (tstop, tdelta, desc)) |
96 | a8083063 | Iustin Pop | |
97 | a8083063 | Iustin Pop | |
98 | 741c6d91 | Michael Hanselmann | def RunTestIf(testnames, fn, *args, **kwargs): |
99 | 7d88f255 | Iustin Pop | """Runs a test conditionally.
|
100 | 7d88f255 | Iustin Pop |
|
101 | 7d88f255 | Iustin Pop | @param testnames: either a single test name in the configuration
|
102 | 7d88f255 | Iustin Pop | file, or a list of testnames (which will be AND-ed together)
|
103 | 7d88f255 | Iustin Pop |
|
104 | 7d88f255 | Iustin Pop | """
|
105 | 7d88f255 | Iustin Pop | if qa_config.TestEnabled(testnames):
|
106 | 741c6d91 | Michael Hanselmann | RunTest(fn, *args, **kwargs) |
107 | 7d88f255 | Iustin Pop | else:
|
108 | 7d88f255 | Iustin Pop | tstart = datetime.datetime.now() |
109 | 7d88f255 | Iustin Pop | desc = _DescriptionOf(fn) |
110 | 7d88f255 | Iustin Pop | print _FormatHeader("%s skipping %s, test(s) %s disabled" % |
111 | 7d88f255 | Iustin Pop | (tstart, desc, testnames)) |
112 | 7d88f255 | Iustin Pop | |
113 | 7d88f255 | Iustin Pop | |
114 | b1ffe1eb | Michael Hanselmann | def RunEnvTests(): |
115 | b1ffe1eb | Michael Hanselmann | """Run several environment tests.
|
116 | a8083063 | Iustin Pop |
|
117 | a8083063 | Iustin Pop | """
|
118 | 7d88f255 | Iustin Pop | RunTestIf("env", qa_env.TestSshConnection)
|
119 | 7d88f255 | Iustin Pop | RunTestIf("env", qa_env.TestIcmpPing)
|
120 | 7d88f255 | Iustin Pop | RunTestIf("env", qa_env.TestGanetiCommands)
|
121 | a8083063 | Iustin Pop | |
122 | 94508060 | Michael Hanselmann | |
123 | 725ec2f1 | René Nussbaumer | def SetupCluster(rapi_user, rapi_secret): |
124 | b1ffe1eb | Michael Hanselmann | """Initializes the cluster.
|
125 | a8083063 | Iustin Pop |
|
126 | 725ec2f1 | René Nussbaumer | @param rapi_user: Login user for RAPI
|
127 | 725ec2f1 | René Nussbaumer | @param rapi_secret: Login secret for RAPI
|
128 | 725ec2f1 | René Nussbaumer |
|
129 | b1ffe1eb | Michael Hanselmann | """
|
130 | 7d88f255 | Iustin Pop | RunTestIf("create-cluster", qa_cluster.TestClusterInit,
|
131 | 7d88f255 | Iustin Pop | rapi_user, rapi_secret) |
132 | 6a0f22e1 | Bernardo Dal Seno | if not qa_config.TestEnabled("create-cluster"): |
133 | 6a0f22e1 | Bernardo Dal Seno | # If the cluster is already in place, we assume that exclusive-storage is
|
134 | 6a0f22e1 | Bernardo Dal Seno | # already set according to the configuration
|
135 | 6a0f22e1 | Bernardo Dal Seno | qa_config.SetExclusiveStorage(qa_config.get("exclusive-storage", False)) |
136 | 288d6440 | Michael Hanselmann | |
137 | 288d6440 | Michael Hanselmann | # Test on empty cluster
|
138 | 288d6440 | Michael Hanselmann | RunTestIf("node-list", qa_node.TestNodeList)
|
139 | 288d6440 | Michael Hanselmann | RunTestIf("instance-list", qa_instance.TestInstanceList)
|
140 | 09470dd8 | Michael Hanselmann | RunTestIf("job-list", qa_job.TestJobList)
|
141 | 288d6440 | Michael Hanselmann | |
142 | 7d88f255 | Iustin Pop | RunTestIf("create-cluster", qa_node.TestNodeAddAll)
|
143 | 7d88f255 | Iustin Pop | if not qa_config.TestEnabled("create-cluster"): |
144 | 8e671b7c | Iustin Pop | # consider the nodes are already there
|
145 | 8e671b7c | Iustin Pop | qa_node.MarkNodeAddedAll() |
146 | 8201b996 | Iustin Pop | |
147 | 7d88f255 | Iustin Pop | RunTestIf("test-jobqueue", qa_cluster.TestJobqueue)
|
148 | cd04f8c2 | Michael Hanselmann | |
149 | 8201b996 | Iustin Pop | # enable the watcher (unconditionally)
|
150 | 8201b996 | Iustin Pop | RunTest(qa_daemon.TestResumeWatcher) |
151 | 8201b996 | Iustin Pop | |
152 | 288d6440 | Michael Hanselmann | RunTestIf("node-list", qa_node.TestNodeList)
|
153 | 288d6440 | Michael Hanselmann | |
154 | 2214cf14 | Michael Hanselmann | # Test listing fields
|
155 | 2214cf14 | Michael Hanselmann | RunTestIf("node-list", qa_node.TestNodeListFields)
|
156 | 2214cf14 | Michael Hanselmann | RunTestIf("instance-list", qa_instance.TestInstanceListFields)
|
157 | 09470dd8 | Michael Hanselmann | RunTestIf("job-list", qa_job.TestJobListFields)
|
158 | 0fdf247d | Michael Hanselmann | RunTestIf("instance-export", qa_instance.TestBackupListFields)
|
159 | 2214cf14 | Michael Hanselmann | |
160 | 7d88f255 | Iustin Pop | RunTestIf("node-info", qa_node.TestNodeInfo)
|
161 | b1ffe1eb | Michael Hanselmann | |
162 | b1ffe1eb | Michael Hanselmann | |
163 | b1ffe1eb | Michael Hanselmann | def RunClusterTests(): |
164 | b1ffe1eb | Michael Hanselmann | """Runs tests related to gnt-cluster.
|
165 | 180bdd1f | Michael Hanselmann |
|
166 | b1ffe1eb | Michael Hanselmann | """
|
167 | 7d88f255 | Iustin Pop | for test, fn in [ |
168 | 92cb4940 | Andrea Spadaccini | ("create-cluster", qa_cluster.TestClusterInitDisk),
|
169 | 7d88f255 | Iustin Pop | ("cluster-renew-crypto", qa_cluster.TestClusterRenewCrypto),
|
170 | 7d88f255 | Iustin Pop | ("cluster-verify", qa_cluster.TestClusterVerify),
|
171 | 7d88f255 | Iustin Pop | ("cluster-reserved-lvs", qa_cluster.TestClusterReservedLvs),
|
172 | 9738ca94 | Iustin Pop | # TODO: add more cluster modify tests
|
173 | 1e7acc3b | Iustin Pop | ("cluster-modify", qa_cluster.TestClusterModifyEmpty),
|
174 | 7d88f255 | Iustin Pop | ("cluster-modify", qa_cluster.TestClusterModifyBe),
|
175 | 92cb4940 | Andrea Spadaccini | ("cluster-modify", qa_cluster.TestClusterModifyDisk),
|
176 | 7d88f255 | Iustin Pop | ("cluster-rename", qa_cluster.TestClusterRename),
|
177 | 7d88f255 | Iustin Pop | ("cluster-info", qa_cluster.TestClusterVersion),
|
178 | 7d88f255 | Iustin Pop | ("cluster-info", qa_cluster.TestClusterInfo),
|
179 | 7d88f255 | Iustin Pop | ("cluster-info", qa_cluster.TestClusterGetmaster),
|
180 | 3e8b5a9c | Iustin Pop | ("cluster-redist-conf", qa_cluster.TestClusterRedistConf),
|
181 | 7d88f255 | Iustin Pop | ("cluster-copyfile", qa_cluster.TestClusterCopyfile),
|
182 | 7d88f255 | Iustin Pop | ("cluster-command", qa_cluster.TestClusterCommand),
|
183 | 7d88f255 | Iustin Pop | ("cluster-burnin", qa_cluster.TestClusterBurnin),
|
184 | 7d88f255 | Iustin Pop | ("cluster-master-failover", qa_cluster.TestClusterMasterFailover),
|
185 | ff699aa9 | Michael Hanselmann | ("cluster-master-failover",
|
186 | ff699aa9 | Michael Hanselmann | qa_cluster.TestClusterMasterFailoverWithDrainedQueue), |
187 | 69df9d2b | Iustin Pop | ("cluster-oob", qa_cluster.TestClusterOob),
|
188 | 7d88f255 | Iustin Pop | ("rapi", qa_rapi.TestVersion),
|
189 | 7d88f255 | Iustin Pop | ("rapi", qa_rapi.TestEmptyCluster),
|
190 | 4fab7cab | Michael Hanselmann | ("rapi", qa_rapi.TestRapiQuery),
|
191 | 7d88f255 | Iustin Pop | ]: |
192 | 7d88f255 | Iustin Pop | RunTestIf(test, fn) |
193 | 8947cf2b | Michael Hanselmann | |
194 | 6d4a1656 | Michael Hanselmann | |
195 | 65a884ef | Iustin Pop | def RunRepairDiskSizes(): |
196 | 65a884ef | Iustin Pop | """Run the repair disk-sizes test.
|
197 | 65a884ef | Iustin Pop |
|
198 | 65a884ef | Iustin Pop | """
|
199 | 65a884ef | Iustin Pop | RunTestIf("cluster-repair-disk-sizes", qa_cluster.TestClusterRepairDiskSizes)
|
200 | 65a884ef | Iustin Pop | |
201 | 65a884ef | Iustin Pop | |
202 | b1ffe1eb | Michael Hanselmann | def RunOsTests(): |
203 | b1ffe1eb | Michael Hanselmann | """Runs all tests related to gnt-os.
|
204 | 5d640672 | Michael Hanselmann |
|
205 | b1ffe1eb | Michael Hanselmann | """
|
206 | 2932dc44 | Michael Hanselmann | if qa_config.TestEnabled("rapi"): |
207 | 2932dc44 | Michael Hanselmann | rapi_getos = qa_rapi.GetOperatingSystems |
208 | 2932dc44 | Michael Hanselmann | else:
|
209 | 2932dc44 | Michael Hanselmann | rapi_getos = None
|
210 | 2932dc44 | Michael Hanselmann | |
211 | 7d88f255 | Iustin Pop | for fn in [ |
212 | 7d88f255 | Iustin Pop | qa_os.TestOsList, |
213 | 7d88f255 | Iustin Pop | qa_os.TestOsDiagnose, |
214 | 2932dc44 | Michael Hanselmann | ]: |
215 | 2932dc44 | Michael Hanselmann | RunTestIf("os", fn)
|
216 | 2932dc44 | Michael Hanselmann | |
217 | 2932dc44 | Michael Hanselmann | for fn in [ |
218 | 7d88f255 | Iustin Pop | qa_os.TestOsValid, |
219 | 7d88f255 | Iustin Pop | qa_os.TestOsInvalid, |
220 | 7d88f255 | Iustin Pop | qa_os.TestOsPartiallyValid, |
221 | 2932dc44 | Michael Hanselmann | ]: |
222 | 2932dc44 | Michael Hanselmann | RunTestIf("os", fn, rapi_getos)
|
223 | 2932dc44 | Michael Hanselmann | |
224 | 2932dc44 | Michael Hanselmann | for fn in [ |
225 | 7d88f255 | Iustin Pop | qa_os.TestOsModifyValid, |
226 | 7d88f255 | Iustin Pop | qa_os.TestOsModifyInvalid, |
227 | 074e139f | Michael Hanselmann | qa_os.TestOsStatesNonExisting, |
228 | 7d88f255 | Iustin Pop | ]: |
229 | 7d88f255 | Iustin Pop | RunTestIf("os", fn)
|
230 | b1ffe1eb | Michael Hanselmann | |
231 | b1ffe1eb | Michael Hanselmann | |
232 | b1ffe1eb | Michael Hanselmann | def RunCommonInstanceTests(instance): |
233 | b1ffe1eb | Michael Hanselmann | """Runs a few tests that are common to all disk types.
|
234 | b1ffe1eb | Michael Hanselmann |
|
235 | b1ffe1eb | Michael Hanselmann | """
|
236 | 7d88f255 | Iustin Pop | RunTestIf("instance-shutdown", qa_instance.TestInstanceShutdown, instance)
|
237 | b82d4c5e | Michael Hanselmann | RunTestIf(["instance-shutdown", "instance-console", "rapi"], |
238 | b82d4c5e | Michael Hanselmann | qa_rapi.TestRapiStoppedInstanceConsole, instance) |
239 | 3016bc1f | Michael Hanselmann | RunTestIf(["instance-shutdown", "instance-modify"], |
240 | 3016bc1f | Michael Hanselmann | qa_instance.TestInstanceStoppedModify, instance) |
241 | 7d88f255 | Iustin Pop | RunTestIf("instance-shutdown", qa_instance.TestInstanceStartup, instance)
|
242 | a8083063 | Iustin Pop | |
243 | a7418448 | Michael Hanselmann | # Test shutdown/start via RAPI
|
244 | a7418448 | Michael Hanselmann | RunTestIf(["instance-shutdown", "rapi"], |
245 | a7418448 | Michael Hanselmann | qa_rapi.TestRapiInstanceShutdown, instance) |
246 | a7418448 | Michael Hanselmann | RunTestIf(["instance-shutdown", "rapi"], |
247 | a7418448 | Michael Hanselmann | qa_rapi.TestRapiInstanceStartup, instance) |
248 | a7418448 | Michael Hanselmann | |
249 | 7d88f255 | Iustin Pop | RunTestIf("instance-list", qa_instance.TestInstanceList)
|
250 | 283f9d4c | Michael Hanselmann | |
251 | 7d88f255 | Iustin Pop | RunTestIf("instance-info", qa_instance.TestInstanceInfo, instance)
|
252 | e9e35aaa | Michael Hanselmann | |
253 | 7d88f255 | Iustin Pop | RunTestIf("instance-modify", qa_instance.TestInstanceModify, instance)
|
254 | 7d88f255 | Iustin Pop | RunTestIf(["instance-modify", "rapi"], |
255 | 7d88f255 | Iustin Pop | qa_rapi.TestRapiInstanceModify, instance) |
256 | c0f74c55 | Iustin Pop | |
257 | 7d88f255 | Iustin Pop | RunTestIf("instance-console", qa_instance.TestInstanceConsole, instance)
|
258 | b82d4c5e | Michael Hanselmann | RunTestIf(["instance-console", "rapi"], |
259 | b82d4c5e | Michael Hanselmann | qa_rapi.TestRapiInstanceConsole, instance) |
260 | 4379b1fa | Michael Hanselmann | |
261 | 1be35bef | Michael Hanselmann | DOWN_TESTS = qa_config.Either([ |
262 | 1be35bef | Michael Hanselmann | "instance-reinstall",
|
263 | 1be35bef | Michael Hanselmann | "instance-rename",
|
264 | 1be35bef | Michael Hanselmann | "instance-grow-disk",
|
265 | 1be35bef | Michael Hanselmann | ]) |
266 | 1be35bef | Michael Hanselmann | |
267 | 4c1a464b | Iustin Pop | # shutdown instance for any 'down' tests
|
268 | 4c1a464b | Iustin Pop | RunTestIf(DOWN_TESTS, qa_instance.TestInstanceShutdown, instance) |
269 | 4c1a464b | Iustin Pop | |
270 | 4c1a464b | Iustin Pop | # now run the 'down' state tests
|
271 | 7d88f255 | Iustin Pop | RunTestIf("instance-reinstall", qa_instance.TestInstanceReinstall, instance)
|
272 | 0220d2cf | Guido Trotter | RunTestIf(["instance-reinstall", "rapi"], |
273 | 0220d2cf | Guido Trotter | qa_rapi.TestRapiInstanceReinstall, instance) |
274 | 8a4e8898 | Michael Hanselmann | |
275 | d0c8c01d | Iustin Pop | if qa_config.TestEnabled("instance-rename"): |
276 | 69bc7a38 | Michael Hanselmann | tgt_instance = qa_config.AcquireInstance() |
277 | 69bc7a38 | Michael Hanselmann | try:
|
278 | 69bc7a38 | Michael Hanselmann | rename_source = instance["name"]
|
279 | 69bc7a38 | Michael Hanselmann | rename_target = tgt_instance["name"]
|
280 | 69bc7a38 | Michael Hanselmann | # perform instance rename to the same name
|
281 | 4c1a464b | Iustin Pop | RunTest(qa_instance.TestInstanceRenameAndBack, |
282 | 69bc7a38 | Michael Hanselmann | rename_source, rename_source) |
283 | 4c1a464b | Iustin Pop | RunTestIf("rapi", qa_rapi.TestRapiInstanceRenameAndBack,
|
284 | 69bc7a38 | Michael Hanselmann | rename_source, rename_source) |
285 | 69bc7a38 | Michael Hanselmann | if rename_target is not None: |
286 | 69bc7a38 | Michael Hanselmann | # perform instance rename to a different name, if we have one configured
|
287 | 69bc7a38 | Michael Hanselmann | RunTest(qa_instance.TestInstanceRenameAndBack, |
288 | 930e77d1 | Michael Hanselmann | rename_source, rename_target) |
289 | 69bc7a38 | Michael Hanselmann | RunTestIf("rapi", qa_rapi.TestRapiInstanceRenameAndBack,
|
290 | 69bc7a38 | Michael Hanselmann | rename_source, rename_target) |
291 | 69bc7a38 | Michael Hanselmann | finally:
|
292 | 69bc7a38 | Michael Hanselmann | qa_config.ReleaseInstance(tgt_instance) |
293 | 4c1a464b | Iustin Pop | |
294 | 26a5056d | Iustin Pop | RunTestIf(["instance-grow-disk"], qa_instance.TestInstanceGrowDisk, instance)
|
295 | 26a5056d | Iustin Pop | |
296 | 4c1a464b | Iustin Pop | # and now start the instance again
|
297 | 4c1a464b | Iustin Pop | RunTestIf(DOWN_TESTS, qa_instance.TestInstanceStartup, instance) |
298 | 4c1a464b | Iustin Pop | |
299 | 4c1a464b | Iustin Pop | RunTestIf("instance-reboot", qa_instance.TestInstanceReboot, instance)
|
300 | 18337ca9 | Iustin Pop | |
301 | 7d88f255 | Iustin Pop | RunTestIf("tags", qa_tags.TestInstanceTags, instance)
|
302 | d74c2ca1 | Michael Hanselmann | |
303 | 1ef6e776 | Michael Hanselmann | RunTestIf("cluster-verify", qa_cluster.TestClusterVerify)
|
304 | d74c2ca1 | Michael Hanselmann | |
305 | 7d88f255 | Iustin Pop | RunTestIf("rapi", qa_rapi.TestInstance, instance)
|
306 | 729c4377 | Iustin Pop | |
307 | 288d6440 | Michael Hanselmann | # Lists instances, too
|
308 | 288d6440 | Michael Hanselmann | RunTestIf("node-list", qa_node.TestNodeList)
|
309 | 288d6440 | Michael Hanselmann | |
310 | 09470dd8 | Michael Hanselmann | # Some jobs have been run, let's test listing them
|
311 | 09470dd8 | Michael Hanselmann | RunTestIf("job-list", qa_job.TestJobList)
|
312 | 09470dd8 | Michael Hanselmann | |
313 | 729c4377 | Iustin Pop | |
314 | 729c4377 | Iustin Pop | def RunCommonNodeTests(): |
315 | 729c4377 | Iustin Pop | """Run a few common node tests.
|
316 | 729c4377 | Iustin Pop |
|
317 | 729c4377 | Iustin Pop | """
|
318 | 7d88f255 | Iustin Pop | RunTestIf("node-volumes", qa_node.TestNodeVolumes)
|
319 | 7d88f255 | Iustin Pop | RunTestIf("node-storage", qa_node.TestNodeStorage)
|
320 | a1de4b18 | René Nussbaumer | RunTestIf("node-oob", qa_node.TestOutOfBand)
|
321 | 8e1db003 | Michael Hanselmann | |
322 | 8d8d650c | Michael Hanselmann | |
323 | 30131294 | Adeodato Simo | def RunGroupListTests(): |
324 | 30131294 | Adeodato Simo | """Run tests for listing node groups.
|
325 | 30131294 | Adeodato Simo |
|
326 | 30131294 | Adeodato Simo | """
|
327 | 7ab8b7d7 | Adeodato Simo | RunTestIf("group-list", qa_group.TestGroupList)
|
328 | 7ab8b7d7 | Adeodato Simo | RunTestIf("group-list", qa_group.TestGroupListFields)
|
329 | 30131294 | Adeodato Simo | |
330 | 30131294 | Adeodato Simo | |
331 | 66787da5 | Adeodato Simo | def RunGroupRwTests(): |
332 | 66787da5 | Adeodato Simo | """Run tests for adding/removing/renaming groups.
|
333 | 66787da5 | Adeodato Simo |
|
334 | 66787da5 | Adeodato Simo | """
|
335 | 66787da5 | Adeodato Simo | RunTestIf("group-rwops", qa_group.TestGroupAddRemoveRename)
|
336 | 4b10fb65 | Adeodato Simo | RunTestIf("group-rwops", qa_group.TestGroupAddWithOptions)
|
337 | 4b10fb65 | Adeodato Simo | RunTestIf("group-rwops", qa_group.TestGroupModify)
|
338 | b9e478fe | Michael Hanselmann | RunTestIf(["group-rwops", "rapi"], qa_rapi.TestRapiNodeGroups) |
339 | fe508a9d | Michael Hanselmann | RunTestIf(["group-rwops", "tags"], qa_tags.TestGroupTags, |
340 | fe508a9d | Michael Hanselmann | qa_group.GetDefaultGroup()) |
341 | 4b10fb65 | Adeodato Simo | |
342 | 66787da5 | Adeodato Simo | |
343 | c99200a3 | Bernardo Dal Seno | def RunExportImportTests(instance, inodes): |
344 | b1ffe1eb | Michael Hanselmann | """Tries to export and import the instance.
|
345 | a8083063 | Iustin Pop |
|
346 | c99200a3 | Bernardo Dal Seno | @type inodes: list of nodes
|
347 | c99200a3 | Bernardo Dal Seno | @param inodes: current nodes of the instance
|
348 | 638a7266 | Iustin Pop |
|
349 | b1ffe1eb | Michael Hanselmann | """
|
350 | d0c8c01d | Iustin Pop | if qa_config.TestEnabled("instance-export"): |
351 | bc696589 | Michael Hanselmann | RunTest(qa_instance.TestInstanceExportNoTarget, instance) |
352 | bc696589 | Michael Hanselmann | |
353 | c99200a3 | Bernardo Dal Seno | pnode = inodes[0]
|
354 | b1ffe1eb | Michael Hanselmann | expnode = qa_config.AcquireNode(exclude=pnode) |
355 | b1ffe1eb | Michael Hanselmann | try:
|
356 | b1ffe1eb | Michael Hanselmann | name = RunTest(qa_instance.TestInstanceExport, instance, expnode) |
357 | b1ffe1eb | Michael Hanselmann | |
358 | b1ffe1eb | Michael Hanselmann | RunTest(qa_instance.TestBackupList, expnode) |
359 | b1ffe1eb | Michael Hanselmann | |
360 | d0c8c01d | Iustin Pop | if qa_config.TestEnabled("instance-import"): |
361 | b1ffe1eb | Michael Hanselmann | newinst = qa_config.AcquireInstance() |
362 | 5d640672 | Michael Hanselmann | try:
|
363 | 5fa0375e | Michael Hanselmann | RunTest(qa_instance.TestInstanceImport, newinst, pnode, |
364 | b1ffe1eb | Michael Hanselmann | expnode, name) |
365 | 51131cad | Michael Hanselmann | # Check if starting the instance works
|
366 | 51131cad | Michael Hanselmann | RunTest(qa_instance.TestInstanceStartup, newinst) |
367 | b1ffe1eb | Michael Hanselmann | RunTest(qa_instance.TestInstanceRemove, newinst) |
368 | 5d640672 | Michael Hanselmann | finally:
|
369 | b1ffe1eb | Michael Hanselmann | qa_config.ReleaseInstance(newinst) |
370 | b1ffe1eb | Michael Hanselmann | finally:
|
371 | b1ffe1eb | Michael Hanselmann | qa_config.ReleaseNode(expnode) |
372 | 5d640672 | Michael Hanselmann | |
373 | 7d88f255 | Iustin Pop | if qa_config.TestEnabled(["rapi", "inter-cluster-instance-move"]): |
374 | 5d831182 | Michael Hanselmann | newinst = qa_config.AcquireInstance() |
375 | 5d831182 | Michael Hanselmann | try:
|
376 | c99200a3 | Bernardo Dal Seno | tnode = qa_config.AcquireNode(exclude=inodes) |
377 | 5d831182 | Michael Hanselmann | try:
|
378 | 5d831182 | Michael Hanselmann | RunTest(qa_rapi.TestInterClusterInstanceMove, instance, newinst, |
379 | c99200a3 | Bernardo Dal Seno | inodes, tnode) |
380 | 5d831182 | Michael Hanselmann | finally:
|
381 | 638a7266 | Iustin Pop | qa_config.ReleaseNode(tnode) |
382 | 5d831182 | Michael Hanselmann | finally:
|
383 | 5d831182 | Michael Hanselmann | qa_config.ReleaseInstance(newinst) |
384 | 5d831182 | Michael Hanselmann | |
385 | 283f9d4c | Michael Hanselmann | |
386 | b998270c | Iustin Pop | def RunDaemonTests(instance): |
387 | b1ffe1eb | Michael Hanselmann | """Test the ganeti-watcher script.
|
388 | 9df6d173 | Michael Hanselmann |
|
389 | b1ffe1eb | Michael Hanselmann | """
|
390 | 8201b996 | Iustin Pop | RunTest(qa_daemon.TestPauseWatcher) |
391 | e9e35aaa | Michael Hanselmann | |
392 | 7d88f255 | Iustin Pop | RunTestIf("instance-automatic-restart",
|
393 | b998270c | Iustin Pop | qa_daemon.TestInstanceAutomaticRestart, instance) |
394 | 7d88f255 | Iustin Pop | RunTestIf("instance-consecutive-failures",
|
395 | b998270c | Iustin Pop | qa_daemon.TestInstanceConsecutiveFailures, instance) |
396 | e9e35aaa | Michael Hanselmann | |
397 | 8201b996 | Iustin Pop | RunTest(qa_daemon.TestResumeWatcher) |
398 | 8201b996 | Iustin Pop | |
399 | 9df6d173 | Michael Hanselmann | |
400 | c99200a3 | Bernardo Dal Seno | def RunHardwareFailureTests(instance, inodes): |
401 | b1ffe1eb | Michael Hanselmann | """Test cluster internal hardware failure recovery.
|
402 | a8083063 | Iustin Pop |
|
403 | b1ffe1eb | Michael Hanselmann | """
|
404 | 7d88f255 | Iustin Pop | RunTestIf("instance-failover", qa_instance.TestInstanceFailover, instance)
|
405 | c0a146a1 | Michael Hanselmann | RunTestIf(["instance-failover", "rapi"], |
406 | c0a146a1 | Michael Hanselmann | qa_rapi.TestRapiInstanceFailover, instance) |
407 | b1ffe1eb | Michael Hanselmann | |
408 | 7d88f255 | Iustin Pop | RunTestIf("instance-migrate", qa_instance.TestInstanceMigrate, instance)
|
409 | 7d88f255 | Iustin Pop | RunTestIf(["instance-migrate", "rapi"], |
410 | 7d88f255 | Iustin Pop | qa_rapi.TestRapiInstanceMigrate, instance) |
411 | 938bde86 | Michael Hanselmann | |
412 | d0c8c01d | Iustin Pop | if qa_config.TestEnabled("instance-replace-disks"): |
413 | c99200a3 | Bernardo Dal Seno | # We just need alternative secondary nodes, hence "- 1"
|
414 | c99200a3 | Bernardo Dal Seno | othernodes = qa_config.AcquireManyNodes(len(inodes) - 1, exclude=inodes) |
415 | 7910e7a5 | Michael Hanselmann | try:
|
416 | 539d65ba | Michael Hanselmann | RunTestIf("rapi", qa_rapi.TestRapiInstanceReplaceDisks, instance)
|
417 | 7910e7a5 | Michael Hanselmann | RunTest(qa_instance.TestReplaceDisks, |
418 | c99200a3 | Bernardo Dal Seno | instance, inodes, othernodes) |
419 | 7910e7a5 | Michael Hanselmann | finally:
|
420 | c99200a3 | Bernardo Dal Seno | qa_config.ReleaseManyNodes(othernodes) |
421 | c99200a3 | Bernardo Dal Seno | del othernodes
|
422 | 7910e7a5 | Michael Hanselmann | |
423 | 83180411 | Bernardo Dal Seno | if qa_config.TestEnabled("instance-recreate-disks"): |
424 | 83180411 | Bernardo Dal Seno | try:
|
425 | c99200a3 | Bernardo Dal Seno | acquirednodes = qa_config.AcquireManyNodes(len(inodes), exclude=inodes)
|
426 | c99200a3 | Bernardo Dal Seno | othernodes = acquirednodes |
427 | 83180411 | Bernardo Dal Seno | except qa_error.OutOfNodesError:
|
428 | c99200a3 | Bernardo Dal Seno | if len(inodes) > 1: |
429 | c99200a3 | Bernardo Dal Seno | # If the cluster is not big enough, let's reuse some of the nodes, but
|
430 | c99200a3 | Bernardo Dal Seno | # with different roles. In this way, we can test a DRBD instance even on
|
431 | c99200a3 | Bernardo Dal Seno | # a 3-node cluster.
|
432 | c99200a3 | Bernardo Dal Seno | acquirednodes = [qa_config.AcquireNode(exclude=inodes)] |
433 | c99200a3 | Bernardo Dal Seno | othernodes = acquirednodes + inodes[:-1]
|
434 | c99200a3 | Bernardo Dal Seno | else:
|
435 | c99200a3 | Bernardo Dal Seno | raise
|
436 | 83180411 | Bernardo Dal Seno | try:
|
437 | 83180411 | Bernardo Dal Seno | RunTest(qa_instance.TestRecreateDisks, |
438 | c99200a3 | Bernardo Dal Seno | instance, inodes, othernodes) |
439 | 83180411 | Bernardo Dal Seno | finally:
|
440 | c99200a3 | Bernardo Dal Seno | qa_config.ReleaseManyNodes(acquirednodes) |
441 | b1ffe1eb | Michael Hanselmann | |
442 | c99200a3 | Bernardo Dal Seno | if len(inodes) >= 2: |
443 | c99200a3 | Bernardo Dal Seno | RunTestIf("node-evacuate", qa_node.TestNodeEvacuate, inodes[0], inodes[1]) |
444 | c99200a3 | Bernardo Dal Seno | RunTestIf("node-failover", qa_node.TestNodeFailover, inodes[0], inodes[1]) |
445 | b1ffe1eb | Michael Hanselmann | |
446 | b1ffe1eb | Michael Hanselmann | |
447 | 50ef6a41 | Bernardo Dal Seno | def RunExclusiveStorageTests(): |
448 | 50ef6a41 | Bernardo Dal Seno | """Test exclusive storage."""
|
449 | 50ef6a41 | Bernardo Dal Seno | if not qa_config.TestEnabled("cluster-exclusive-storage"): |
450 | 50ef6a41 | Bernardo Dal Seno | return
|
451 | 50ef6a41 | Bernardo Dal Seno | |
452 | 50ef6a41 | Bernardo Dal Seno | node = qa_config.AcquireNode() |
453 | 50ef6a41 | Bernardo Dal Seno | try:
|
454 | e8b919a1 | Bernardo Dal Seno | old_es = qa_cluster.TestSetExclStorCluster(False)
|
455 | e8b919a1 | Bernardo Dal Seno | qa_cluster.TestExclStorSingleNode(node) |
456 | e8b919a1 | Bernardo Dal Seno | |
457 | e8b919a1 | Bernardo Dal Seno | qa_cluster.TestSetExclStorCluster(True)
|
458 | 21e2734f | Bernardo Dal Seno | qa_cluster.TestExclStorSharedPv(node) |
459 | 21e2734f | Bernardo Dal Seno | |
460 | 50ef6a41 | Bernardo Dal Seno | if qa_config.TestEnabled("instance-add-plain-disk"): |
461 | 50ef6a41 | Bernardo Dal Seno | # Make sure that the cluster doesn't have any pre-existing problem
|
462 | 50ef6a41 | Bernardo Dal Seno | qa_cluster.AssertClusterVerify() |
463 | c99200a3 | Bernardo Dal Seno | instance1 = qa_instance.TestInstanceAddWithPlainDisk([node]) |
464 | c99200a3 | Bernardo Dal Seno | instance2 = qa_instance.TestInstanceAddWithPlainDisk([node]) |
465 | 50ef6a41 | Bernardo Dal Seno | # cluster-verify checks that disks are allocated correctly
|
466 | 50ef6a41 | Bernardo Dal Seno | qa_cluster.AssertClusterVerify() |
467 | 50ef6a41 | Bernardo Dal Seno | qa_instance.TestInstanceRemove(instance1) |
468 | 50ef6a41 | Bernardo Dal Seno | qa_instance.TestInstanceRemove(instance2) |
469 | efd58d99 | Bernardo Dal Seno | if qa_config.TestEnabled("instance-add-drbd-disk"): |
470 | efd58d99 | Bernardo Dal Seno | snode = qa_config.AcquireNode() |
471 | efd58d99 | Bernardo Dal Seno | try:
|
472 | efd58d99 | Bernardo Dal Seno | qa_cluster.TestSetExclStorCluster(False)
|
473 | c99200a3 | Bernardo Dal Seno | instance = qa_instance.TestInstanceAddWithDrbdDisk([node, snode]) |
474 | efd58d99 | Bernardo Dal Seno | qa_cluster.TestSetExclStorCluster(True)
|
475 | efd58d99 | Bernardo Dal Seno | exp_err = [constants.CV_EINSTANCEUNSUITABLENODE] |
476 | efd58d99 | Bernardo Dal Seno | qa_cluster.AssertClusterVerify(fail=True, errors=exp_err)
|
477 | efd58d99 | Bernardo Dal Seno | qa_instance.TestInstanceRemove(instance) |
478 | efd58d99 | Bernardo Dal Seno | finally:
|
479 | efd58d99 | Bernardo Dal Seno | qa_config.ReleaseNode(snode) |
480 | 50ef6a41 | Bernardo Dal Seno | qa_cluster.TestSetExclStorCluster(old_es) |
481 | 50ef6a41 | Bernardo Dal Seno | finally:
|
482 | 50ef6a41 | Bernardo Dal Seno | qa_config.ReleaseNode(node) |
483 | 50ef6a41 | Bernardo Dal Seno | |
484 | 50ef6a41 | Bernardo Dal Seno | |
485 | deadfa13 | Bernardo Dal Seno | def RunInstanceTests(): |
486 | deadfa13 | Bernardo Dal Seno | """Create and exercise instances."""
|
487 | deadfa13 | Bernardo Dal Seno | instance_tests = [ |
488 | deadfa13 | Bernardo Dal Seno | ("instance-add-plain-disk", constants.DT_PLAIN,
|
489 | deadfa13 | Bernardo Dal Seno | qa_instance.TestInstanceAddWithPlainDisk, 1),
|
490 | deadfa13 | Bernardo Dal Seno | ("instance-add-drbd-disk", constants.DT_DRBD8,
|
491 | deadfa13 | Bernardo Dal Seno | qa_instance.TestInstanceAddWithDrbdDisk, 2),
|
492 | deadfa13 | Bernardo Dal Seno | ] |
493 | deadfa13 | Bernardo Dal Seno | |
494 | deadfa13 | Bernardo Dal Seno | for (test_name, templ, create_fun, num_nodes) in instance_tests: |
495 | deadfa13 | Bernardo Dal Seno | if (qa_config.TestEnabled(test_name) and |
496 | deadfa13 | Bernardo Dal Seno | qa_config.IsTemplateSupported(templ)): |
497 | deadfa13 | Bernardo Dal Seno | inodes = qa_config.AcquireManyNodes(num_nodes) |
498 | deadfa13 | Bernardo Dal Seno | try:
|
499 | deadfa13 | Bernardo Dal Seno | instance = RunTest(create_fun, inodes) |
500 | deadfa13 | Bernardo Dal Seno | |
501 | deadfa13 | Bernardo Dal Seno | RunTestIf("cluster-epo", qa_cluster.TestClusterEpo)
|
502 | deadfa13 | Bernardo Dal Seno | RunDaemonTests(instance) |
503 | deadfa13 | Bernardo Dal Seno | for node in inodes: |
504 | deadfa13 | Bernardo Dal Seno | RunTestIf("haskell-confd", qa_node.TestNodeListDrbd, node)
|
505 | deadfa13 | Bernardo Dal Seno | if len(inodes) > 1: |
506 | deadfa13 | Bernardo Dal Seno | RunTestIf("group-rwops", qa_group.TestAssignNodesIncludingSplit,
|
507 | deadfa13 | Bernardo Dal Seno | constants.INITIAL_NODE_GROUP_NAME, |
508 | deadfa13 | Bernardo Dal Seno | inodes[0]["primary"], inodes[1]["primary"]) |
509 | deadfa13 | Bernardo Dal Seno | if qa_config.TestEnabled("instance-convert-disk"): |
510 | deadfa13 | Bernardo Dal Seno | RunTest(qa_instance.TestInstanceShutdown, instance) |
511 | deadfa13 | Bernardo Dal Seno | RunTest(qa_instance.TestInstanceConvertDiskToPlain, instance, inodes) |
512 | deadfa13 | Bernardo Dal Seno | RunTest(qa_instance.TestInstanceStartup, instance) |
513 | deadfa13 | Bernardo Dal Seno | RunCommonInstanceTests(instance) |
514 | deadfa13 | Bernardo Dal Seno | RunGroupListTests() |
515 | deadfa13 | Bernardo Dal Seno | RunExportImportTests(instance, inodes) |
516 | deadfa13 | Bernardo Dal Seno | RunHardwareFailureTests(instance, inodes) |
517 | deadfa13 | Bernardo Dal Seno | RunRepairDiskSizes() |
518 | deadfa13 | Bernardo Dal Seno | RunTest(qa_instance.TestInstanceRemove, instance) |
519 | deadfa13 | Bernardo Dal Seno | del instance
|
520 | deadfa13 | Bernardo Dal Seno | finally:
|
521 | deadfa13 | Bernardo Dal Seno | qa_config.ReleaseManyNodes(inodes) |
522 | deadfa13 | Bernardo Dal Seno | qa_cluster.AssertClusterVerify() |
523 | deadfa13 | Bernardo Dal Seno | |
524 | deadfa13 | Bernardo Dal Seno | |
525 | f7e6f3c8 | Iustin Pop | def RunQa(): |
526 | f7e6f3c8 | Iustin Pop | """Main QA body.
|
527 | b1ffe1eb | Michael Hanselmann |
|
528 | b1ffe1eb | Michael Hanselmann | """
|
529 | 725ec2f1 | René Nussbaumer | rapi_user = "ganeti-qa"
|
530 | 725ec2f1 | René Nussbaumer | rapi_secret = utils.GenerateSecret() |
531 | 725ec2f1 | René Nussbaumer | |
532 | b1ffe1eb | Michael Hanselmann | RunEnvTests() |
533 | 725ec2f1 | René Nussbaumer | SetupCluster(rapi_user, rapi_secret) |
534 | 2771835c | Michael Hanselmann | |
535 | 2771835c | Michael Hanselmann | # Load RAPI certificate
|
536 | 76917d97 | Iustin Pop | qa_rapi.Setup(rapi_user, rapi_secret) |
537 | 2771835c | Michael Hanselmann | |
538 | b1ffe1eb | Michael Hanselmann | RunClusterTests() |
539 | b1ffe1eb | Michael Hanselmann | RunOsTests() |
540 | 4b62db14 | Michael Hanselmann | |
541 | 7d88f255 | Iustin Pop | RunTestIf("tags", qa_tags.TestClusterTags)
|
542 | d74c2ca1 | Michael Hanselmann | |
543 | 729c4377 | Iustin Pop | RunCommonNodeTests() |
544 | 30131294 | Adeodato Simo | RunGroupListTests() |
545 | 66787da5 | Adeodato Simo | RunGroupRwTests() |
546 | 729c4377 | Iustin Pop | |
547 | 6f058bf2 | Bernardo Dal Seno | # The master shouldn't be readded or put offline; "delay" needs a non-master
|
548 | 6f058bf2 | Bernardo Dal Seno | # node to test
|
549 | d0cb68cb | Michael Hanselmann | pnode = qa_config.AcquireNode(exclude=qa_config.GetMasterNode()) |
550 | d0cb68cb | Michael Hanselmann | try:
|
551 | 7d88f255 | Iustin Pop | RunTestIf("node-readd", qa_node.TestNodeReadd, pnode)
|
552 | 7d88f255 | Iustin Pop | RunTestIf("node-modify", qa_node.TestNodeModify, pnode)
|
553 | 5a85b99e | Michael Hanselmann | RunTestIf("delay", qa_cluster.TestDelay, pnode)
|
554 | d0cb68cb | Michael Hanselmann | finally:
|
555 | d0cb68cb | Michael Hanselmann | qa_config.ReleaseNode(pnode) |
556 | 102b115b | Michael Hanselmann | |
557 | a36f690c | Bernardo Dal Seno | # Make sure the cluster is clean before running instance tests
|
558 | a36f690c | Bernardo Dal Seno | qa_cluster.AssertClusterVerify() |
559 | a36f690c | Bernardo Dal Seno | |
560 | b1ffe1eb | Michael Hanselmann | pnode = qa_config.AcquireNode() |
561 | b1ffe1eb | Michael Hanselmann | try:
|
562 | 7d88f255 | Iustin Pop | RunTestIf("tags", qa_tags.TestNodeTags, pnode)
|
563 | d74c2ca1 | Michael Hanselmann | |
564 | a47f574c | Oleksiy Mishchenko | if qa_rapi.Enabled():
|
565 | a47f574c | Oleksiy Mishchenko | RunTest(qa_rapi.TestNode, pnode) |
566 | a47f574c | Oleksiy Mishchenko | |
567 | 8cb70e56 | Michael Hanselmann | if qa_config.TestEnabled("instance-add-plain-disk"): |
568 | 924e95f9 | Michael Hanselmann | for use_client in [True, False]: |
569 | 924e95f9 | Michael Hanselmann | rapi_instance = RunTest(qa_rapi.TestRapiInstanceAdd, pnode, |
570 | 924e95f9 | Michael Hanselmann | use_client) |
571 | b498540e | Iustin Pop | if qa_config.TestEnabled("instance-plain-rapi-common-tests"): |
572 | b498540e | Iustin Pop | RunCommonInstanceTests(rapi_instance) |
573 | 924e95f9 | Michael Hanselmann | RunTest(qa_rapi.TestRapiInstanceRemove, rapi_instance, use_client) |
574 | 924e95f9 | Michael Hanselmann | del rapi_instance
|
575 | 8cb70e56 | Michael Hanselmann | |
576 | 6f058bf2 | Bernardo Dal Seno | finally:
|
577 | 6f058bf2 | Bernardo Dal Seno | qa_config.ReleaseNode(pnode) |
578 | 6f058bf2 | Bernardo Dal Seno | |
579 | deadfa13 | Bernardo Dal Seno | config_list = [ |
580 | deadfa13 | Bernardo Dal Seno | ("default-instance-tests", lambda: None, lambda _: None), |
581 | deadfa13 | Bernardo Dal Seno | ("exclusive-storage-instance-tests",
|
582 | deadfa13 | Bernardo Dal Seno | lambda: qa_cluster.TestSetExclStorCluster(True), |
583 | deadfa13 | Bernardo Dal Seno | qa_cluster.TestSetExclStorCluster), |
584 | 27eba428 | Bernardo Dal Seno | ] |
585 | deadfa13 | Bernardo Dal Seno | for (conf_name, setup_conf_f, restore_conf_f) in config_list: |
586 | deadfa13 | Bernardo Dal Seno | if qa_config.TestEnabled(conf_name):
|
587 | deadfa13 | Bernardo Dal Seno | oldconf = setup_conf_f() |
588 | deadfa13 | Bernardo Dal Seno | RunInstanceTests() |
589 | deadfa13 | Bernardo Dal Seno | restore_conf_f(oldconf) |
590 | c7e54e1d | Agata Murawska | |
591 | 6f058bf2 | Bernardo Dal Seno | pnode = qa_config.AcquireNode() |
592 | 6f058bf2 | Bernardo Dal Seno | try:
|
593 | 7d88f255 | Iustin Pop | if qa_config.TestEnabled(["instance-add-plain-disk", "instance-export"]): |
594 | 3b01286e | Michael Hanselmann | for shutdown in [False, True]: |
595 | c99200a3 | Bernardo Dal Seno | instance = RunTest(qa_instance.TestInstanceAddWithPlainDisk, [pnode]) |
596 | 3b01286e | Michael Hanselmann | expnode = qa_config.AcquireNode(exclude=pnode) |
597 | 3b01286e | Michael Hanselmann | try:
|
598 | 3b01286e | Michael Hanselmann | if shutdown:
|
599 | 3b01286e | Michael Hanselmann | # Stop instance before exporting and removing it
|
600 | 3b01286e | Michael Hanselmann | RunTest(qa_instance.TestInstanceShutdown, instance) |
601 | 3b01286e | Michael Hanselmann | RunTest(qa_instance.TestInstanceExportWithRemove, instance, expnode) |
602 | 3b01286e | Michael Hanselmann | RunTest(qa_instance.TestBackupList, expnode) |
603 | 3b01286e | Michael Hanselmann | finally:
|
604 | 3b01286e | Michael Hanselmann | qa_config.ReleaseNode(expnode) |
605 | 3b01286e | Michael Hanselmann | del expnode
|
606 | 3b01286e | Michael Hanselmann | del instance
|
607 | a36f690c | Bernardo Dal Seno | qa_cluster.AssertClusterVerify() |
608 | 8d8d650c | Michael Hanselmann | |
609 | a8083063 | Iustin Pop | finally:
|
610 | b1ffe1eb | Michael Hanselmann | qa_config.ReleaseNode(pnode) |
611 | a8083063 | Iustin Pop | |
612 | 50ef6a41 | Bernardo Dal Seno | RunExclusiveStorageTests() |
613 | 50ef6a41 | Bernardo Dal Seno | |
614 | a36f690c | Bernardo Dal Seno | # Test removing instance with offline drbd secondary
|
615 | a36f690c | Bernardo Dal Seno | if qa_config.TestEnabled("instance-remove-drbd-offline"): |
616 | a36f690c | Bernardo Dal Seno | # Make sure the master is not put offline
|
617 | a36f690c | Bernardo Dal Seno | snode = qa_config.AcquireNode(exclude=qa_config.GetMasterNode()) |
618 | a36f690c | Bernardo Dal Seno | try:
|
619 | a36f690c | Bernardo Dal Seno | pnode = qa_config.AcquireNode(exclude=snode) |
620 | a36f690c | Bernardo Dal Seno | try:
|
621 | a36f690c | Bernardo Dal Seno | instance = qa_instance.TestInstanceAddWithDrbdDisk([pnode, snode]) |
622 | f006f110 | Bernardo Dal Seno | set_offline = lambda node: qa_node.MakeNodeOffline(node, "yes") |
623 | f006f110 | Bernardo Dal Seno | set_online = lambda node: qa_node.MakeNodeOffline(node, "no") |
624 | f006f110 | Bernardo Dal Seno | RunTest(qa_instance.TestRemoveInstanceOfflineNode, instance, snode, |
625 | f006f110 | Bernardo Dal Seno | set_offline, set_online) |
626 | a36f690c | Bernardo Dal Seno | finally:
|
627 | a36f690c | Bernardo Dal Seno | qa_config.ReleaseNode(pnode) |
628 | a36f690c | Bernardo Dal Seno | finally:
|
629 | a36f690c | Bernardo Dal Seno | qa_config.ReleaseNode(snode) |
630 | f006f110 | Bernardo Dal Seno | qa_cluster.AssertClusterVerify() |
631 | a36f690c | Bernardo Dal Seno | |
632 | 7d88f255 | Iustin Pop | RunTestIf("create-cluster", qa_node.TestNodeRemoveAll)
|
633 | a8083063 | Iustin Pop | |
634 | 7d88f255 | Iustin Pop | RunTestIf("cluster-destroy", qa_cluster.TestClusterDestroy)
|
635 | a8083063 | Iustin Pop | |
636 | cec9845c | Michael Hanselmann | |
637 | fc3f75dd | Iustin Pop | @UsesRapiClient
|
638 | f7e6f3c8 | Iustin Pop | def main(): |
639 | f7e6f3c8 | Iustin Pop | """Main program.
|
640 | f7e6f3c8 | Iustin Pop |
|
641 | f7e6f3c8 | Iustin Pop | """
|
642 | f7e6f3c8 | Iustin Pop | parser = optparse.OptionParser(usage="%prog [options] <config-file>")
|
643 | d0c8c01d | Iustin Pop | parser.add_option("--yes-do-it", dest="yes_do_it", |
644 | 5ae4945a | Iustin Pop | action="store_true",
|
645 | 5ae4945a | Iustin Pop | help="Really execute the tests")
|
646 | f7e6f3c8 | Iustin Pop | (qa_config.options, args) = parser.parse_args() |
647 | f7e6f3c8 | Iustin Pop | |
648 | f7e6f3c8 | Iustin Pop | if len(args) == 1: |
649 | f7e6f3c8 | Iustin Pop | (config_file, ) = args |
650 | f7e6f3c8 | Iustin Pop | else:
|
651 | f7e6f3c8 | Iustin Pop | parser.error("Wrong number of arguments.")
|
652 | f7e6f3c8 | Iustin Pop | |
653 | f7e6f3c8 | Iustin Pop | if not qa_config.options.yes_do_it: |
654 | f7e6f3c8 | Iustin Pop | print ("Executing this script irreversibly destroys any Ganeti\n" |
655 | f7e6f3c8 | Iustin Pop | "configuration on all nodes involved. If you really want\n"
|
656 | f7e6f3c8 | Iustin Pop | "to start testing, supply the --yes-do-it option.")
|
657 | f7e6f3c8 | Iustin Pop | sys.exit(1)
|
658 | f7e6f3c8 | Iustin Pop | |
659 | f7e6f3c8 | Iustin Pop | qa_config.Load(config_file) |
660 | f7e6f3c8 | Iustin Pop | |
661 | 710bc88c | Iustin Pop | primary = qa_config.GetMasterNode()["primary"]
|
662 | 710bc88c | Iustin Pop | qa_utils.StartMultiplexer(primary) |
663 | 710bc88c | Iustin Pop | print ("SSH command for primary node: %s" % |
664 | 710bc88c | Iustin Pop | utils.ShellQuoteArgs(qa_utils.GetSSHCommand(primary, "")))
|
665 | 710bc88c | Iustin Pop | print ("SSH command for other nodes: %s" % |
666 | 710bc88c | Iustin Pop | utils.ShellQuoteArgs(qa_utils.GetSSHCommand("NODE", ""))) |
667 | f7e6f3c8 | Iustin Pop | try:
|
668 | f7e6f3c8 | Iustin Pop | RunQa() |
669 | f7e6f3c8 | Iustin Pop | finally:
|
670 | f7e6f3c8 | Iustin Pop | qa_utils.CloseMultiplexers() |
671 | f7e6f3c8 | Iustin Pop | |
672 | d0c8c01d | Iustin Pop | if __name__ == "__main__": |
673 | cec9845c | Michael Hanselmann | main() |