root / qa / qa_env.py @ 9b603bff
History | View | Annotate | Download (2.1 kB)
1 | c68d1f43 | Michael Hanselmann | #
|
---|---|---|---|
2 | c68d1f43 | Michael Hanselmann | #
|
3 | c68d1f43 | Michael Hanselmann | |
4 | cec9845c | Michael Hanselmann | # Copyright (C) 2007 Google Inc.
|
5 | cec9845c | Michael Hanselmann | #
|
6 | cec9845c | Michael Hanselmann | # This program is free software; you can redistribute it and/or modify
|
7 | cec9845c | Michael Hanselmann | # it under the terms of the GNU General Public License as published by
|
8 | cec9845c | Michael Hanselmann | # the Free Software Foundation; either version 2 of the License, or
|
9 | cec9845c | Michael Hanselmann | # (at your option) any later version.
|
10 | cec9845c | Michael Hanselmann | #
|
11 | cec9845c | Michael Hanselmann | # This program is distributed in the hope that it will be useful, but
|
12 | cec9845c | Michael Hanselmann | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | cec9845c | Michael Hanselmann | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | cec9845c | Michael Hanselmann | # General Public License for more details.
|
15 | cec9845c | Michael Hanselmann | #
|
16 | cec9845c | Michael Hanselmann | # You should have received a copy of the GNU General Public License
|
17 | cec9845c | Michael Hanselmann | # along with this program; if not, write to the Free Software
|
18 | cec9845c | Michael Hanselmann | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 | cec9845c | Michael Hanselmann | # 02110-1301, USA.
|
20 | cec9845c | Michael Hanselmann | |
21 | cec9845c | Michael Hanselmann | |
22 | cec9845c | Michael Hanselmann | """Cluster environment related QA tests.
|
23 | cec9845c | Michael Hanselmann |
|
24 | cec9845c | Michael Hanselmann | """
|
25 | cec9845c | Michael Hanselmann | |
26 | cec9845c | Michael Hanselmann | from ganeti import utils |
27 | cec9845c | Michael Hanselmann | |
28 | cec9845c | Michael Hanselmann | import qa_config |
29 | 9b3939ea | Michael Hanselmann | import qa_utils |
30 | cec9845c | Michael Hanselmann | |
31 | cec9845c | Michael Hanselmann | from qa_utils import AssertEqual, StartSSH |
32 | cec9845c | Michael Hanselmann | |
33 | cec9845c | Michael Hanselmann | |
34 | 9b3939ea | Michael Hanselmann | @qa_utils.DefineHook('env-ssh-connection') |
35 | cec9845c | Michael Hanselmann | def TestSshConnection(): |
36 | cec9845c | Michael Hanselmann | """Test SSH connection.
|
37 | cec9845c | Michael Hanselmann |
|
38 | cec9845c | Michael Hanselmann | """
|
39 | cec9845c | Michael Hanselmann | for node in qa_config.get('nodes'): |
40 | cec9845c | Michael Hanselmann | AssertEqual(StartSSH(node['primary'], 'exit').wait(), 0) |
41 | cec9845c | Michael Hanselmann | |
42 | cec9845c | Michael Hanselmann | |
43 | 9b3939ea | Michael Hanselmann | @qa_utils.DefineHook('env-ganeti-commands') |
44 | cec9845c | Michael Hanselmann | def TestGanetiCommands(): |
45 | cec9845c | Michael Hanselmann | """Test availibility of Ganeti commands.
|
46 | cec9845c | Michael Hanselmann |
|
47 | cec9845c | Michael Hanselmann | """
|
48 | cec9845c | Michael Hanselmann | cmds = ( ['gnt-cluster', '--version'], |
49 | cec9845c | Michael Hanselmann | ['gnt-os', '--version'], |
50 | cec9845c | Michael Hanselmann | ['gnt-node', '--version'], |
51 | cec9845c | Michael Hanselmann | ['gnt-instance', '--version'], |
52 | cec9845c | Michael Hanselmann | ['gnt-backup', '--version'], |
53 | cec9845c | Michael Hanselmann | ['ganeti-noded', '--version'], |
54 | cec9845c | Michael Hanselmann | ['ganeti-watcher', '--version'] ) |
55 | cec9845c | Michael Hanselmann | |
56 | cec9845c | Michael Hanselmann | cmd = ' && '.join([utils.ShellQuoteArgs(i) for i in cmds]) |
57 | cec9845c | Michael Hanselmann | |
58 | cec9845c | Michael Hanselmann | for node in qa_config.get('nodes'): |
59 | cec9845c | Michael Hanselmann | AssertEqual(StartSSH(node['primary'], cmd).wait(), 0) |
60 | cec9845c | Michael Hanselmann | |
61 | cec9845c | Michael Hanselmann | |
62 | 9b3939ea | Michael Hanselmann | @qa_utils.DefineHook('env-icmp-ping') |
63 | cec9845c | Michael Hanselmann | def TestIcmpPing(): |
64 | cec9845c | Michael Hanselmann | """ICMP ping each node.
|
65 | cec9845c | Michael Hanselmann |
|
66 | cec9845c | Michael Hanselmann | """
|
67 | cec9845c | Michael Hanselmann | nodes = qa_config.get('nodes')
|
68 | cec9845c | Michael Hanselmann | |
69 | cec9845c | Michael Hanselmann | for node in nodes: |
70 | cec9845c | Michael Hanselmann | check = [] |
71 | cec9845c | Michael Hanselmann | for i in nodes: |
72 | cec9845c | Michael Hanselmann | check.append(i['primary'])
|
73 | cec9845c | Michael Hanselmann | if i.has_key('secondary'): |
74 | cec9845c | Michael Hanselmann | check.append(i['secondary'])
|
75 | cec9845c | Michael Hanselmann | |
76 | cec9845c | Michael Hanselmann | ping = lambda ip: utils.ShellQuoteArgs(['ping', '-w', '3', '-c', '1', ip]) |
77 | cec9845c | Michael Hanselmann | cmd = ' && '.join([ping(i) for i in check]) |
78 | cec9845c | Michael Hanselmann | |
79 | cec9845c | Michael Hanselmann | AssertEqual(StartSSH(node['primary'], cmd).wait(), 0) |