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