root / qa / ganeti-qa.py @ 8947cf2b
History | View | Annotate | Download (7.4 kB)
1 | a8083063 | Iustin Pop | #!/usr/bin/python
|
---|---|---|---|
2 | a8083063 | Iustin Pop | #
|
3 | a8083063 | Iustin Pop | |
4 | cec9845c | Michael Hanselmann | # Copyright (C) 2007 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 | You can create the required known_hosts file using ssh-keyscan. It's mandatory
|
25 | 94508060 | Michael Hanselmann | to use the full name of a node (FQDN). For security reasons, verify the keys
|
26 | 94508060 | Michael Hanselmann | before using them.
|
27 | 94508060 | Michael Hanselmann | Example: ssh-keyscan -t rsa node{1,2,3,4}.example.com > known_hosts
|
28 | 94508060 | Michael Hanselmann | """
|
29 | a8083063 | Iustin Pop | |
30 | a8083063 | Iustin Pop | import sys |
31 | a8083063 | Iustin Pop | from datetime import datetime |
32 | a8083063 | Iustin Pop | from optparse import OptionParser |
33 | a8083063 | Iustin Pop | |
34 | cec9845c | Michael Hanselmann | import qa_cluster |
35 | cec9845c | Michael Hanselmann | import qa_config |
36 | cec9845c | Michael Hanselmann | import qa_daemon |
37 | cec9845c | Michael Hanselmann | import qa_env |
38 | cec9845c | Michael Hanselmann | import qa_instance |
39 | cec9845c | Michael Hanselmann | import qa_node |
40 | 8947cf2b | Michael Hanselmann | import qa_os |
41 | cec9845c | Michael Hanselmann | import qa_other |
42 | a8083063 | Iustin Pop | |
43 | a8083063 | Iustin Pop | |
44 | cec9845c | Michael Hanselmann | def RunTest(fn, *args): |
45 | a8083063 | Iustin Pop | """Runs a test after printing a header.
|
46 | a8083063 | Iustin Pop |
|
47 | a8083063 | Iustin Pop | """
|
48 | cec9845c | Michael Hanselmann | if fn.__doc__:
|
49 | cec9845c | Michael Hanselmann | desc = fn.__doc__.splitlines()[0].strip()
|
50 | a8083063 | Iustin Pop | else:
|
51 | cec9845c | Michael Hanselmann | desc = '%r' % fn
|
52 | a8083063 | Iustin Pop | |
53 | a8083063 | Iustin Pop | now = str(datetime.now())
|
54 | a8083063 | Iustin Pop | |
55 | a8083063 | Iustin Pop | print
|
56 | a8083063 | Iustin Pop | print '---', now, ('-' * (55 - len(now))) |
57 | a8083063 | Iustin Pop | print desc
|
58 | a8083063 | Iustin Pop | print '-' * 60 |
59 | a8083063 | Iustin Pop | |
60 | cec9845c | Michael Hanselmann | return fn(*args)
|
61 | a8083063 | Iustin Pop | |
62 | a8083063 | Iustin Pop | |
63 | cec9845c | Michael Hanselmann | def main(): |
64 | cec9845c | Michael Hanselmann | """Main program.
|
65 | a8083063 | Iustin Pop |
|
66 | a8083063 | Iustin Pop | """
|
67 | 94508060 | Michael Hanselmann | parser = OptionParser(usage="%prog [options] <config-file> "
|
68 | 94508060 | Michael Hanselmann | "<known-hosts-file>")
|
69 | a8083063 | Iustin Pop | parser.add_option('--dry-run', dest='dry_run', |
70 | a8083063 | Iustin Pop | action="store_true",
|
71 | a8083063 | Iustin Pop | help="Show what would be done")
|
72 | a8083063 | Iustin Pop | parser.add_option('--yes-do-it', dest='yes_do_it', |
73 | a8083063 | Iustin Pop | action="store_true",
|
74 | a8083063 | Iustin Pop | help="Really execute the tests")
|
75 | cec9845c | Michael Hanselmann | (qa_config.options, args) = parser.parse_args() |
76 | a8083063 | Iustin Pop | |
77 | 94508060 | Michael Hanselmann | if len(args) == 2: |
78 | 94508060 | Michael Hanselmann | (config_file, known_hosts_file) = args |
79 | a8083063 | Iustin Pop | else:
|
80 | 94508060 | Michael Hanselmann | parser.error("Not enough arguments.")
|
81 | a8083063 | Iustin Pop | |
82 | cec9845c | Michael Hanselmann | if not qa_config.options.yes_do_it: |
83 | a8083063 | Iustin Pop | print ("Executing this script irreversibly destroys any Ganeti\n" |
84 | a8083063 | Iustin Pop | "configuration on all nodes involved. If you really want\n"
|
85 | a8083063 | Iustin Pop | "to start testing, supply the --yes-do-it option.")
|
86 | a8083063 | Iustin Pop | sys.exit(1)
|
87 | a8083063 | Iustin Pop | |
88 | cec9845c | Michael Hanselmann | qa_config.Load(config_file) |
89 | a8083063 | Iustin Pop | |
90 | cec9845c | Michael Hanselmann | RunTest(qa_other.TestUploadKnownHostsFile, known_hosts_file) |
91 | 94508060 | Michael Hanselmann | |
92 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('env'): |
93 | cec9845c | Michael Hanselmann | RunTest(qa_env.TestSshConnection) |
94 | cec9845c | Michael Hanselmann | RunTest(qa_env.TestIcmpPing) |
95 | cec9845c | Michael Hanselmann | RunTest(qa_env.TestGanetiCommands) |
96 | a8083063 | Iustin Pop | |
97 | cec9845c | Michael Hanselmann | RunTest(qa_cluster.TestClusterInit) |
98 | a8083063 | Iustin Pop | |
99 | cec9845c | Michael Hanselmann | RunTest(qa_node.TestNodeAddAll) |
100 | 180bdd1f | Michael Hanselmann | |
101 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('cluster-verify'): |
102 | cec9845c | Michael Hanselmann | RunTest(qa_cluster.TestClusterVerify) |
103 | e9e35aaa | Michael Hanselmann | |
104 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('cluster-info'): |
105 | cec9845c | Michael Hanselmann | RunTest(qa_cluster.TestClusterInfo) |
106 | a8083063 | Iustin Pop | |
107 | 283f9d4c | Michael Hanselmann | if qa_config.TestEnabled('cluster-getmaster'): |
108 | 283f9d4c | Michael Hanselmann | RunTest(qa_cluster.TestClusterGetmaster) |
109 | 283f9d4c | Michael Hanselmann | |
110 | 283f9d4c | Michael Hanselmann | if qa_config.TestEnabled('cluster-version'): |
111 | 283f9d4c | Michael Hanselmann | RunTest(qa_cluster.TestClusterVersion) |
112 | 283f9d4c | Michael Hanselmann | |
113 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('cluster-copyfile'): |
114 | cec9845c | Michael Hanselmann | RunTest(qa_cluster.TestClusterCopyfile) |
115 | a8083063 | Iustin Pop | |
116 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('node-info'): |
117 | cec9845c | Michael Hanselmann | RunTest(qa_node.TestNodeInfo) |
118 | e9e35aaa | Michael Hanselmann | |
119 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('cluster-burnin'): |
120 | cec9845c | Michael Hanselmann | RunTest(qa_cluster.TestClusterBurnin) |
121 | a8083063 | Iustin Pop | |
122 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('cluster-master-failover'): |
123 | cec9845c | Michael Hanselmann | RunTest(qa_cluster.TestClusterMasterFailover) |
124 | a8083063 | Iustin Pop | |
125 | 8947cf2b | Michael Hanselmann | if qa_config.TestEnabled('os'): |
126 | 8947cf2b | Michael Hanselmann | RunTest(qa_os.TestOsList) |
127 | 8947cf2b | Michael Hanselmann | RunTest(qa_os.TestOsDiagnose) |
128 | 8947cf2b | Michael Hanselmann | RunTest(qa_os.TestOsValid) |
129 | 8947cf2b | Michael Hanselmann | RunTest(qa_os.TestOsInvalid) |
130 | 8947cf2b | Michael Hanselmann | RunTest(qa_os.TestOsPartiallyValid) |
131 | 8947cf2b | Michael Hanselmann | |
132 | cec9845c | Michael Hanselmann | node = qa_config.AcquireNode() |
133 | a8083063 | Iustin Pop | try:
|
134 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('instance-add-plain-disk'): |
135 | cec9845c | Michael Hanselmann | instance = RunTest(qa_instance.TestInstanceAddWithPlainDisk, node) |
136 | 5d640672 | Michael Hanselmann | |
137 | 5d640672 | Michael Hanselmann | if qa_config.TestEnabled('instance-shutdown'): |
138 | 5d640672 | Michael Hanselmann | RunTest(qa_instance.TestInstanceShutdown, instance) |
139 | 5d640672 | Michael Hanselmann | RunTest(qa_instance.TestInstanceStartup, instance) |
140 | a8083063 | Iustin Pop | |
141 | 283f9d4c | Michael Hanselmann | if qa_config.TestEnabled('instance-list'): |
142 | 283f9d4c | Michael Hanselmann | RunTest(qa_instance.TestInstanceList) |
143 | 283f9d4c | Michael Hanselmann | |
144 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('instance-info'): |
145 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceInfo, instance) |
146 | e9e35aaa | Michael Hanselmann | |
147 | 23269c5b | Michael Hanselmann | automatic_restart = \ |
148 | 23269c5b | Michael Hanselmann | qa_config.TestEnabled('instance-automatic-restart')
|
149 | 23269c5b | Michael Hanselmann | consecutive_failures = \ |
150 | 23269c5b | Michael Hanselmann | qa_config.TestEnabled('instance-consecutive-failures')
|
151 | a8083063 | Iustin Pop | |
152 | 23269c5b | Michael Hanselmann | if automatic_restart or consecutive_failures: |
153 | 23269c5b | Michael Hanselmann | qa_daemon.PrintCronWarning() |
154 | 23269c5b | Michael Hanselmann | |
155 | 23269c5b | Michael Hanselmann | if automatic_restart:
|
156 | 23269c5b | Michael Hanselmann | RunTest(qa_daemon.TestInstanceAutomaticRestart, node, instance) |
157 | 23269c5b | Michael Hanselmann | |
158 | 23269c5b | Michael Hanselmann | if consecutive_failures:
|
159 | 23269c5b | Michael Hanselmann | RunTest(qa_daemon.TestInstanceConsecutiveFailures, node, instance) |
160 | a8083063 | Iustin Pop | |
161 | 5d640672 | Michael Hanselmann | if qa_config.TestEnabled('instance-export'): |
162 | 5d640672 | Michael Hanselmann | expnode = qa_config.AcquireNode(exclude=node) |
163 | 5d640672 | Michael Hanselmann | try:
|
164 | 5d640672 | Michael Hanselmann | name = RunTest(qa_instance.TestInstanceExport, instance, expnode) |
165 | 5d640672 | Michael Hanselmann | |
166 | 283f9d4c | Michael Hanselmann | RunTest(qa_instance.TestBackupList, expnode) |
167 | 283f9d4c | Michael Hanselmann | |
168 | 5d640672 | Michael Hanselmann | if qa_config.TestEnabled('instance-import'): |
169 | 5d640672 | Michael Hanselmann | newinst = qa_config.AcquireInstance() |
170 | 5d640672 | Michael Hanselmann | try:
|
171 | 5d640672 | Michael Hanselmann | RunTest(qa_instance.TestInstanceImport, node, newinst, |
172 | 5d640672 | Michael Hanselmann | expnode, name) |
173 | 5d640672 | Michael Hanselmann | RunTest(qa_instance.TestInstanceRemove, newinst) |
174 | 5d640672 | Michael Hanselmann | finally:
|
175 | 5d640672 | Michael Hanselmann | qa_config.ReleaseInstance(newinst) |
176 | 5d640672 | Michael Hanselmann | finally:
|
177 | 5d640672 | Michael Hanselmann | qa_config.ReleaseNode(expnode) |
178 | 5d640672 | Michael Hanselmann | |
179 | 283f9d4c | Michael Hanselmann | if qa_config.TestEnabled('instance-reinstall'): |
180 | 283f9d4c | Michael Hanselmann | RunTest(qa_instance.TestInstanceShutdown, instance) |
181 | 283f9d4c | Michael Hanselmann | RunTest(qa_instance.TestInstanceReinstall, instance) |
182 | 283f9d4c | Michael Hanselmann | RunTest(qa_instance.TestInstanceStartup, instance) |
183 | 283f9d4c | Michael Hanselmann | |
184 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('node-volumes'): |
185 | cec9845c | Michael Hanselmann | RunTest(qa_node.TestNodeVolumes) |
186 | 9df6d173 | Michael Hanselmann | |
187 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceRemove, instance) |
188 | a8083063 | Iustin Pop | del instance
|
189 | a8083063 | Iustin Pop | |
190 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('instance-add-local-mirror-disk'): |
191 | cec9845c | Michael Hanselmann | instance = RunTest(qa_instance.TestInstanceAddWithLocalMirrorDisk, node) |
192 | 5d640672 | Michael Hanselmann | |
193 | 5d640672 | Michael Hanselmann | if qa_config.TestEnabled('instance-shutdown'): |
194 | 5d640672 | Michael Hanselmann | RunTest(qa_instance.TestInstanceShutdown, instance) |
195 | 5d640672 | Michael Hanselmann | RunTest(qa_instance.TestInstanceStartup, instance) |
196 | e9e35aaa | Michael Hanselmann | |
197 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('instance-info'): |
198 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceInfo, instance) |
199 | e9e35aaa | Michael Hanselmann | |
200 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('node-volumes'): |
201 | cec9845c | Michael Hanselmann | RunTest(qa_node.TestNodeVolumes) |
202 | 9df6d173 | Michael Hanselmann | |
203 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceRemove, instance) |
204 | a8083063 | Iustin Pop | del instance
|
205 | a8083063 | Iustin Pop | |
206 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('instance-add-remote-raid-disk'): |
207 | cec9845c | Michael Hanselmann | node2 = qa_config.AcquireNode(exclude=node) |
208 | a8083063 | Iustin Pop | try:
|
209 | cec9845c | Michael Hanselmann | instance = RunTest(qa_instance.TestInstanceAddWithRemoteRaidDisk, |
210 | cec9845c | Michael Hanselmann | node, node2) |
211 | 5d640672 | Michael Hanselmann | |
212 | 5d640672 | Michael Hanselmann | if qa_config.TestEnabled('instance-shutdown'): |
213 | 5d640672 | Michael Hanselmann | RunTest(qa_instance.TestInstanceShutdown, instance) |
214 | 5d640672 | Michael Hanselmann | RunTest(qa_instance.TestInstanceStartup, instance) |
215 | a8083063 | Iustin Pop | |
216 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('instance-info'): |
217 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceInfo, instance) |
218 | e9e35aaa | Michael Hanselmann | |
219 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('instance-failover'): |
220 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceFailover, instance) |
221 | a8083063 | Iustin Pop | |
222 | 4b62db14 | Michael Hanselmann | if qa_config.TestEnabled('node-evacuate'): |
223 | 4b62db14 | Michael Hanselmann | RunTest(qa_node.TestNodeEvacuate, node, node2) |
224 | 4b62db14 | Michael Hanselmann | |
225 | 4b62db14 | Michael Hanselmann | if qa_config.TestEnabled('node-failover'): |
226 | 4b62db14 | Michael Hanselmann | RunTest(qa_node.TestNodeFailover, node, node2) |
227 | 4b62db14 | Michael Hanselmann | |
228 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('node-volumes'): |
229 | cec9845c | Michael Hanselmann | RunTest(qa_node.TestNodeVolumes) |
230 | 9df6d173 | Michael Hanselmann | |
231 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceRemove, instance) |
232 | a8083063 | Iustin Pop | del instance
|
233 | a8083063 | Iustin Pop | finally:
|
234 | cec9845c | Michael Hanselmann | qa_config.ReleaseNode(node2) |
235 | a8083063 | Iustin Pop | |
236 | a8083063 | Iustin Pop | finally:
|
237 | cec9845c | Michael Hanselmann | qa_config.ReleaseNode(node) |
238 | a8083063 | Iustin Pop | |
239 | cec9845c | Michael Hanselmann | RunTest(qa_node.TestNodeRemoveAll) |
240 | a8083063 | Iustin Pop | |
241 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('cluster-destroy'): |
242 | cec9845c | Michael Hanselmann | RunTest(qa_cluster.TestClusterDestroy) |
243 | a8083063 | Iustin Pop | |
244 | cec9845c | Michael Hanselmann | |
245 | cec9845c | Michael Hanselmann | if __name__ == '__main__': |
246 | cec9845c | Michael Hanselmann | main() |