root / qa / ganeti-qa.py @ cec9845c
History | View | Annotate | Download (5.5 kB)
1 |
#!/usr/bin/python
|
---|---|
2 |
#
|
3 |
|
4 |
# Copyright (C) 2007 Google Inc.
|
5 |
#
|
6 |
# This program is free software; you can redistribute it and/or modify
|
7 |
# it under the terms of the GNU General Public License as published by
|
8 |
# the Free Software Foundation; either version 2 of the License, or
|
9 |
# (at your option) any later version.
|
10 |
#
|
11 |
# This program is distributed in the hope that it will be useful, but
|
12 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
# General Public License for more details.
|
15 |
#
|
16 |
# You should have received a copy of the GNU General Public License
|
17 |
# along with this program; if not, write to the Free Software
|
18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 |
# 02110-1301, USA.
|
20 |
|
21 |
|
22 |
"""Script for doing QA on Ganeti.
|
23 |
|
24 |
You can create the required known_hosts file using ssh-keyscan. It's mandatory
|
25 |
to use the full name of a node (FQDN). For security reasons, verify the keys
|
26 |
before using them.
|
27 |
Example: ssh-keyscan -t rsa node{1,2,3,4}.example.com > known_hosts
|
28 |
"""
|
29 |
|
30 |
import sys |
31 |
from datetime import datetime |
32 |
from optparse import OptionParser |
33 |
|
34 |
import qa_cluster |
35 |
import qa_config |
36 |
import qa_daemon |
37 |
import qa_env |
38 |
import qa_instance |
39 |
import qa_node |
40 |
import qa_other |
41 |
|
42 |
|
43 |
def RunTest(fn, *args): |
44 |
"""Runs a test after printing a header.
|
45 |
|
46 |
"""
|
47 |
if fn.__doc__:
|
48 |
desc = fn.__doc__.splitlines()[0].strip()
|
49 |
else:
|
50 |
desc = '%r' % fn
|
51 |
|
52 |
now = str(datetime.now())
|
53 |
|
54 |
print
|
55 |
print '---', now, ('-' * (55 - len(now))) |
56 |
print desc
|
57 |
print '-' * 60 |
58 |
|
59 |
return fn(*args)
|
60 |
|
61 |
|
62 |
def main(): |
63 |
"""Main program.
|
64 |
|
65 |
"""
|
66 |
parser = OptionParser(usage="%prog [options] <config-file> "
|
67 |
"<known-hosts-file>")
|
68 |
parser.add_option('--dry-run', dest='dry_run', |
69 |
action="store_true",
|
70 |
help="Show what would be done")
|
71 |
parser.add_option('--yes-do-it', dest='yes_do_it', |
72 |
action="store_true",
|
73 |
help="Really execute the tests")
|
74 |
(qa_config.options, args) = parser.parse_args() |
75 |
|
76 |
if len(args) == 2: |
77 |
(config_file, known_hosts_file) = args |
78 |
else:
|
79 |
parser.error("Not enough arguments.")
|
80 |
|
81 |
if not qa_config.options.yes_do_it: |
82 |
print ("Executing this script irreversibly destroys any Ganeti\n" |
83 |
"configuration on all nodes involved. If you really want\n"
|
84 |
"to start testing, supply the --yes-do-it option.")
|
85 |
sys.exit(1)
|
86 |
|
87 |
qa_config.Load(config_file) |
88 |
|
89 |
RunTest(qa_other.TestUploadKnownHostsFile, known_hosts_file) |
90 |
|
91 |
if qa_config.TestEnabled('env'): |
92 |
RunTest(qa_env.TestSshConnection) |
93 |
RunTest(qa_env.TestIcmpPing) |
94 |
RunTest(qa_env.TestGanetiCommands) |
95 |
|
96 |
RunTest(qa_cluster.TestClusterInit) |
97 |
|
98 |
RunTest(qa_node.TestNodeAddAll) |
99 |
|
100 |
if qa_config.TestEnabled('cluster-verify'): |
101 |
RunTest(qa_cluster.TestClusterVerify) |
102 |
|
103 |
if qa_config.TestEnabled('cluster-info'): |
104 |
RunTest(qa_cluster.TestClusterInfo) |
105 |
|
106 |
if qa_config.TestEnabled('cluster-copyfile'): |
107 |
RunTest(qa_cluster.TestClusterCopyfile) |
108 |
|
109 |
if qa_config.TestEnabled('node-info'): |
110 |
RunTest(qa_node.TestNodeInfo) |
111 |
|
112 |
if qa_config.TestEnabled('cluster-burnin'): |
113 |
RunTest(qa_cluster.TestClusterBurnin) |
114 |
|
115 |
if qa_config.TestEnabled('cluster-master-failover'): |
116 |
RunTest(qa_cluster.TestClusterMasterFailover) |
117 |
|
118 |
node = qa_config.AcquireNode() |
119 |
try:
|
120 |
if qa_config.TestEnabled('instance-add-plain-disk'): |
121 |
instance = RunTest(qa_instance.TestInstanceAddWithPlainDisk, node) |
122 |
RunTest(qa_instance.TestInstanceShutdown, instance) |
123 |
RunTest(qa_instance.TestInstanceStartup, instance) |
124 |
|
125 |
if qa_config.TestEnabled('instance-info'): |
126 |
RunTest(qa_instance.TestInstanceInfo, instance) |
127 |
|
128 |
if qa_config.TestEnabled('instance-automatic-restart'): |
129 |
RunTest(qa_daemon.TestInstanceAutomaticRestart, node, instance) |
130 |
|
131 |
if qa_config.TestEnabled('instance-consecutive-failures'): |
132 |
RunTest(qa_daemon.TestInstanceConsecutiveFailures, node, instance) |
133 |
|
134 |
if qa_config.TestEnabled('node-volumes'): |
135 |
RunTest(qa_node.TestNodeVolumes) |
136 |
|
137 |
RunTest(qa_instance.TestInstanceRemove, instance) |
138 |
del instance
|
139 |
|
140 |
if qa_config.TestEnabled('instance-add-local-mirror-disk'): |
141 |
instance = RunTest(qa_instance.TestInstanceAddWithLocalMirrorDisk, node) |
142 |
RunTest(qa_instance.TestInstanceShutdown, instance) |
143 |
RunTest(qa_instance.TestInstanceStartup, instance) |
144 |
|
145 |
if qa_config.TestEnabled('instance-info'): |
146 |
RunTest(qa_instance.TestInstanceInfo, instance) |
147 |
|
148 |
if qa_config.TestEnabled('node-volumes'): |
149 |
RunTest(qa_node.TestNodeVolumes) |
150 |
|
151 |
RunTest(qa_instance.TestInstanceRemove, instance) |
152 |
del instance
|
153 |
|
154 |
if qa_config.TestEnabled('instance-add-remote-raid-disk'): |
155 |
node2 = qa_config.AcquireNode(exclude=node) |
156 |
try:
|
157 |
instance = RunTest(qa_instance.TestInstanceAddWithRemoteRaidDisk, |
158 |
node, node2) |
159 |
RunTest(qa_instance.TestInstanceShutdown, instance) |
160 |
RunTest(qa_instance.TestInstanceStartup, instance) |
161 |
|
162 |
if qa_config.TestEnabled('instance-info'): |
163 |
RunTest(qa_instance.TestInstanceInfo, instance) |
164 |
|
165 |
if qa_config.TestEnabled('instance-failover'): |
166 |
RunTest(qa_instance.TestInstanceFailover, instance) |
167 |
|
168 |
if qa_config.TestEnabled('node-volumes'): |
169 |
RunTest(qa_node.TestNodeVolumes) |
170 |
|
171 |
RunTest(qa_instance.TestInstanceRemove, instance) |
172 |
del instance
|
173 |
finally:
|
174 |
qa_config.ReleaseNode(node2) |
175 |
|
176 |
finally:
|
177 |
qa_config.ReleaseNode(node) |
178 |
|
179 |
RunTest(qa_node.TestNodeRemoveAll) |
180 |
|
181 |
if qa_config.TestEnabled('cluster-destroy'): |
182 |
RunTest(qa_cluster.TestClusterDestroy) |
183 |
|
184 |
|
185 |
if __name__ == '__main__': |
186 |
main() |