root / qa / ganeti-qa.py @ cec9845c
History | View | Annotate | Download (5.5 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 | cec9845c | Michael Hanselmann | import qa_other |
41 | a8083063 | Iustin Pop | |
42 | a8083063 | Iustin Pop | |
43 | cec9845c | Michael Hanselmann | def RunTest(fn, *args): |
44 | a8083063 | Iustin Pop | """Runs a test after printing a header.
|
45 | a8083063 | Iustin Pop |
|
46 | a8083063 | Iustin Pop | """
|
47 | cec9845c | Michael Hanselmann | if fn.__doc__:
|
48 | cec9845c | Michael Hanselmann | desc = fn.__doc__.splitlines()[0].strip()
|
49 | a8083063 | Iustin Pop | else:
|
50 | cec9845c | Michael Hanselmann | desc = '%r' % fn
|
51 | a8083063 | Iustin Pop | |
52 | a8083063 | Iustin Pop | now = str(datetime.now())
|
53 | a8083063 | Iustin Pop | |
54 | a8083063 | Iustin Pop | print
|
55 | a8083063 | Iustin Pop | print '---', now, ('-' * (55 - len(now))) |
56 | a8083063 | Iustin Pop | print desc
|
57 | a8083063 | Iustin Pop | print '-' * 60 |
58 | a8083063 | Iustin Pop | |
59 | cec9845c | Michael Hanselmann | return fn(*args)
|
60 | a8083063 | Iustin Pop | |
61 | a8083063 | Iustin Pop | |
62 | cec9845c | Michael Hanselmann | def main(): |
63 | cec9845c | Michael Hanselmann | """Main program.
|
64 | a8083063 | Iustin Pop |
|
65 | a8083063 | Iustin Pop | """
|
66 | 94508060 | Michael Hanselmann | parser = OptionParser(usage="%prog [options] <config-file> "
|
67 | 94508060 | Michael Hanselmann | "<known-hosts-file>")
|
68 | a8083063 | Iustin Pop | parser.add_option('--dry-run', dest='dry_run', |
69 | a8083063 | Iustin Pop | action="store_true",
|
70 | a8083063 | Iustin Pop | help="Show what would be done")
|
71 | a8083063 | Iustin Pop | parser.add_option('--yes-do-it', dest='yes_do_it', |
72 | a8083063 | Iustin Pop | action="store_true",
|
73 | a8083063 | Iustin Pop | help="Really execute the tests")
|
74 | cec9845c | Michael Hanselmann | (qa_config.options, args) = parser.parse_args() |
75 | a8083063 | Iustin Pop | |
76 | 94508060 | Michael Hanselmann | if len(args) == 2: |
77 | 94508060 | Michael Hanselmann | (config_file, known_hosts_file) = args |
78 | a8083063 | Iustin Pop | else:
|
79 | 94508060 | Michael Hanselmann | parser.error("Not enough arguments.")
|
80 | a8083063 | Iustin Pop | |
81 | cec9845c | Michael Hanselmann | if not qa_config.options.yes_do_it: |
82 | a8083063 | Iustin Pop | print ("Executing this script irreversibly destroys any Ganeti\n" |
83 | a8083063 | Iustin Pop | "configuration on all nodes involved. If you really want\n"
|
84 | a8083063 | Iustin Pop | "to start testing, supply the --yes-do-it option.")
|
85 | a8083063 | Iustin Pop | sys.exit(1)
|
86 | a8083063 | Iustin Pop | |
87 | cec9845c | Michael Hanselmann | qa_config.Load(config_file) |
88 | a8083063 | Iustin Pop | |
89 | cec9845c | Michael Hanselmann | RunTest(qa_other.TestUploadKnownHostsFile, known_hosts_file) |
90 | 94508060 | Michael Hanselmann | |
91 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('env'): |
92 | cec9845c | Michael Hanselmann | RunTest(qa_env.TestSshConnection) |
93 | cec9845c | Michael Hanselmann | RunTest(qa_env.TestIcmpPing) |
94 | cec9845c | Michael Hanselmann | RunTest(qa_env.TestGanetiCommands) |
95 | a8083063 | Iustin Pop | |
96 | cec9845c | Michael Hanselmann | RunTest(qa_cluster.TestClusterInit) |
97 | a8083063 | Iustin Pop | |
98 | cec9845c | Michael Hanselmann | RunTest(qa_node.TestNodeAddAll) |
99 | 180bdd1f | Michael Hanselmann | |
100 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('cluster-verify'): |
101 | cec9845c | Michael Hanselmann | RunTest(qa_cluster.TestClusterVerify) |
102 | e9e35aaa | Michael Hanselmann | |
103 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('cluster-info'): |
104 | cec9845c | Michael Hanselmann | RunTest(qa_cluster.TestClusterInfo) |
105 | a8083063 | Iustin Pop | |
106 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('cluster-copyfile'): |
107 | cec9845c | Michael Hanselmann | RunTest(qa_cluster.TestClusterCopyfile) |
108 | a8083063 | Iustin Pop | |
109 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('node-info'): |
110 | cec9845c | Michael Hanselmann | RunTest(qa_node.TestNodeInfo) |
111 | e9e35aaa | Michael Hanselmann | |
112 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('cluster-burnin'): |
113 | cec9845c | Michael Hanselmann | RunTest(qa_cluster.TestClusterBurnin) |
114 | a8083063 | Iustin Pop | |
115 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('cluster-master-failover'): |
116 | cec9845c | Michael Hanselmann | RunTest(qa_cluster.TestClusterMasterFailover) |
117 | a8083063 | Iustin Pop | |
118 | cec9845c | Michael Hanselmann | node = qa_config.AcquireNode() |
119 | a8083063 | Iustin Pop | try:
|
120 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('instance-add-plain-disk'): |
121 | cec9845c | Michael Hanselmann | instance = RunTest(qa_instance.TestInstanceAddWithPlainDisk, node) |
122 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceShutdown, instance) |
123 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceStartup, instance) |
124 | a8083063 | Iustin Pop | |
125 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('instance-info'): |
126 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceInfo, instance) |
127 | e9e35aaa | Michael Hanselmann | |
128 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('instance-automatic-restart'): |
129 | cec9845c | Michael Hanselmann | RunTest(qa_daemon.TestInstanceAutomaticRestart, node, instance) |
130 | a8083063 | Iustin Pop | |
131 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('instance-consecutive-failures'): |
132 | cec9845c | Michael Hanselmann | RunTest(qa_daemon.TestInstanceConsecutiveFailures, node, instance) |
133 | a8083063 | Iustin Pop | |
134 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('node-volumes'): |
135 | cec9845c | Michael Hanselmann | RunTest(qa_node.TestNodeVolumes) |
136 | 9df6d173 | Michael Hanselmann | |
137 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceRemove, instance) |
138 | a8083063 | Iustin Pop | del instance
|
139 | a8083063 | Iustin Pop | |
140 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('instance-add-local-mirror-disk'): |
141 | cec9845c | Michael Hanselmann | instance = RunTest(qa_instance.TestInstanceAddWithLocalMirrorDisk, node) |
142 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceShutdown, instance) |
143 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceStartup, instance) |
144 | e9e35aaa | Michael Hanselmann | |
145 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('instance-info'): |
146 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceInfo, instance) |
147 | e9e35aaa | Michael Hanselmann | |
148 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('node-volumes'): |
149 | cec9845c | Michael Hanselmann | RunTest(qa_node.TestNodeVolumes) |
150 | 9df6d173 | Michael Hanselmann | |
151 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceRemove, instance) |
152 | a8083063 | Iustin Pop | del instance
|
153 | a8083063 | Iustin Pop | |
154 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('instance-add-remote-raid-disk'): |
155 | cec9845c | Michael Hanselmann | node2 = qa_config.AcquireNode(exclude=node) |
156 | a8083063 | Iustin Pop | try:
|
157 | cec9845c | Michael Hanselmann | instance = RunTest(qa_instance.TestInstanceAddWithRemoteRaidDisk, |
158 | cec9845c | Michael Hanselmann | node, node2) |
159 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceShutdown, instance) |
160 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceStartup, instance) |
161 | a8083063 | Iustin Pop | |
162 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('instance-info'): |
163 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceInfo, instance) |
164 | e9e35aaa | Michael Hanselmann | |
165 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('instance-failover'): |
166 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceFailover, instance) |
167 | a8083063 | Iustin Pop | |
168 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('node-volumes'): |
169 | cec9845c | Michael Hanselmann | RunTest(qa_node.TestNodeVolumes) |
170 | 9df6d173 | Michael Hanselmann | |
171 | cec9845c | Michael Hanselmann | RunTest(qa_instance.TestInstanceRemove, instance) |
172 | a8083063 | Iustin Pop | del instance
|
173 | a8083063 | Iustin Pop | finally:
|
174 | cec9845c | Michael Hanselmann | qa_config.ReleaseNode(node2) |
175 | a8083063 | Iustin Pop | |
176 | a8083063 | Iustin Pop | finally:
|
177 | cec9845c | Michael Hanselmann | qa_config.ReleaseNode(node) |
178 | a8083063 | Iustin Pop | |
179 | cec9845c | Michael Hanselmann | RunTest(qa_node.TestNodeRemoveAll) |
180 | a8083063 | Iustin Pop | |
181 | cec9845c | Michael Hanselmann | if qa_config.TestEnabled('cluster-destroy'): |
182 | cec9845c | Michael Hanselmann | RunTest(qa_cluster.TestClusterDestroy) |
183 | a8083063 | Iustin Pop | |
184 | cec9845c | Michael Hanselmann | |
185 | cec9845c | Michael Hanselmann | if __name__ == '__main__': |
186 | cec9845c | Michael Hanselmann | main() |