4 # Copyright (C) 2007 Google Inc.
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.
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.
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
22 """Script for doing QA on Ganeti.
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
27 Example: ssh-keyscan -t rsa node{1,2,3,4}.example.com > known_hosts
31 from datetime import datetime
32 from optparse import OptionParser
43 def RunTest(fn, *args):
44 """Runs a test after printing a header.
48 desc = fn.__doc__.splitlines()[0].strip()
52 now = str(datetime.now())
55 print '---', now, ('-' * (55 - len(now)))
66 parser = OptionParser(usage="%prog [options] <config-file> "
68 parser.add_option('--dry-run', dest='dry_run',
70 help="Show what would be done")
71 parser.add_option('--yes-do-it', dest='yes_do_it',
73 help="Really execute the tests")
74 (qa_config.options, args) = parser.parse_args()
77 (config_file, known_hosts_file) = args
79 parser.error("Not enough arguments.")
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.")
87 qa_config.Load(config_file)
89 RunTest(qa_other.TestUploadKnownHostsFile, known_hosts_file)
91 if qa_config.TestEnabled('env'):
92 RunTest(qa_env.TestSshConnection)
93 RunTest(qa_env.TestIcmpPing)
94 RunTest(qa_env.TestGanetiCommands)
96 RunTest(qa_cluster.TestClusterInit)
98 RunTest(qa_node.TestNodeAddAll)
100 if qa_config.TestEnabled('cluster-verify'):
101 RunTest(qa_cluster.TestClusterVerify)
103 if qa_config.TestEnabled('cluster-info'):
104 RunTest(qa_cluster.TestClusterInfo)
106 if qa_config.TestEnabled('cluster-copyfile'):
107 RunTest(qa_cluster.TestClusterCopyfile)
109 if qa_config.TestEnabled('node-info'):
110 RunTest(qa_node.TestNodeInfo)
112 if qa_config.TestEnabled('cluster-burnin'):
113 RunTest(qa_cluster.TestClusterBurnin)
115 if qa_config.TestEnabled('cluster-master-failover'):
116 RunTest(qa_cluster.TestClusterMasterFailover)
118 node = qa_config.AcquireNode()
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)
125 if qa_config.TestEnabled('instance-info'):
126 RunTest(qa_instance.TestInstanceInfo, instance)
128 if qa_config.TestEnabled('instance-automatic-restart'):
129 RunTest(qa_daemon.TestInstanceAutomaticRestart, node, instance)
131 if qa_config.TestEnabled('instance-consecutive-failures'):
132 RunTest(qa_daemon.TestInstanceConsecutiveFailures, node, instance)
134 if qa_config.TestEnabled('node-volumes'):
135 RunTest(qa_node.TestNodeVolumes)
137 RunTest(qa_instance.TestInstanceRemove, instance)
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)
145 if qa_config.TestEnabled('instance-info'):
146 RunTest(qa_instance.TestInstanceInfo, instance)
148 if qa_config.TestEnabled('node-volumes'):
149 RunTest(qa_node.TestNodeVolumes)
151 RunTest(qa_instance.TestInstanceRemove, instance)
154 if qa_config.TestEnabled('instance-add-remote-raid-disk'):
155 node2 = qa_config.AcquireNode(exclude=node)
157 instance = RunTest(qa_instance.TestInstanceAddWithRemoteRaidDisk,
159 RunTest(qa_instance.TestInstanceShutdown, instance)
160 RunTest(qa_instance.TestInstanceStartup, instance)
162 if qa_config.TestEnabled('instance-info'):
163 RunTest(qa_instance.TestInstanceInfo, instance)
165 if qa_config.TestEnabled('instance-failover'):
166 RunTest(qa_instance.TestInstanceFailover, instance)
168 if qa_config.TestEnabled('node-volumes'):
169 RunTest(qa_node.TestNodeVolumes)
171 RunTest(qa_instance.TestInstanceRemove, instance)
174 qa_config.ReleaseNode(node2)
177 qa_config.ReleaseNode(node)
179 RunTest(qa_node.TestNodeRemoveAll)
181 if qa_config.TestEnabled('cluster-destroy'):
182 RunTest(qa_cluster.TestClusterDestroy)
185 if __name__ == '__main__':