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