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