root / qa / qa_instance.py @ e9f745aa
History | View | Annotate | Download (3.3 kB)
1 |
# Copyright (C) 2007 Google Inc.
|
---|---|
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
6 |
# (at your option) any later version.
|
7 |
#
|
8 |
# This program is distributed in the hope that it will be useful, but
|
9 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11 |
# General Public License for more details.
|
12 |
#
|
13 |
# You should have received a copy of the GNU General Public License
|
14 |
# along with this program; if not, write to the Free Software
|
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
16 |
# 02110-1301, USA.
|
17 |
|
18 |
|
19 |
"""Instance related QA tests.
|
20 |
|
21 |
"""
|
22 |
|
23 |
from ganeti import utils |
24 |
|
25 |
import qa_config |
26 |
|
27 |
from qa_utils import AssertEqual, StartSSH |
28 |
|
29 |
|
30 |
def _DiskTest(node, args): |
31 |
master = qa_config.GetMasterNode() |
32 |
|
33 |
instance = qa_config.AcquireInstance() |
34 |
try:
|
35 |
cmd = ['gnt-instance', 'add', |
36 |
'--os-type=%s' % qa_config.get('os'), |
37 |
'--os-size=%s' % qa_config.get('os-size'), |
38 |
'--swap-size=%s' % qa_config.get('swap-size'), |
39 |
'--memory=%s' % qa_config.get('mem'), |
40 |
'--node=%s' % node['primary']] |
41 |
if args:
|
42 |
cmd += args |
43 |
cmd.append(instance['name'])
|
44 |
|
45 |
AssertEqual(StartSSH(master['primary'],
|
46 |
utils.ShellQuoteArgs(cmd)).wait(), 0)
|
47 |
return instance
|
48 |
except:
|
49 |
qa_config.ReleaseInstance(instance) |
50 |
raise
|
51 |
|
52 |
|
53 |
def TestInstanceAddWithPlainDisk(node): |
54 |
"""gnt-instance add -t plain"""
|
55 |
return _DiskTest(node, ['--disk-template=plain']) |
56 |
|
57 |
|
58 |
def TestInstanceAddWithLocalMirrorDisk(node): |
59 |
"""gnt-instance add -t local_raid1"""
|
60 |
return _DiskTest(node, ['--disk-template=local_raid1']) |
61 |
|
62 |
|
63 |
def TestInstanceAddWithRemoteRaidDisk(node, node2): |
64 |
"""gnt-instance add -t remote_raid1"""
|
65 |
return _DiskTest(node,
|
66 |
['--disk-template=remote_raid1',
|
67 |
'--secondary-node=%s' % node2['primary']]) |
68 |
|
69 |
|
70 |
def TestInstanceRemove(instance): |
71 |
"""gnt-instance remove"""
|
72 |
master = qa_config.GetMasterNode() |
73 |
|
74 |
cmd = ['gnt-instance', 'remove', '-f', instance['name']] |
75 |
AssertEqual(StartSSH(master['primary'],
|
76 |
utils.ShellQuoteArgs(cmd)).wait(), 0)
|
77 |
|
78 |
qa_config.ReleaseInstance(instance) |
79 |
|
80 |
|
81 |
def TestInstanceStartup(instance): |
82 |
"""gnt-instance startup"""
|
83 |
master = qa_config.GetMasterNode() |
84 |
|
85 |
cmd = ['gnt-instance', 'startup', instance['name']] |
86 |
AssertEqual(StartSSH(master['primary'],
|
87 |
utils.ShellQuoteArgs(cmd)).wait(), 0)
|
88 |
|
89 |
|
90 |
def TestInstanceShutdown(instance): |
91 |
"""gnt-instance shutdown"""
|
92 |
master = qa_config.GetMasterNode() |
93 |
|
94 |
cmd = ['gnt-instance', 'shutdown', instance['name']] |
95 |
AssertEqual(StartSSH(master['primary'],
|
96 |
utils.ShellQuoteArgs(cmd)).wait(), 0)
|
97 |
|
98 |
|
99 |
def TestInstanceFailover(instance): |
100 |
"""gnt-instance failover"""
|
101 |
master = qa_config.GetMasterNode() |
102 |
|
103 |
cmd = ['gnt-instance', 'failover', '--force', instance['name']] |
104 |
AssertEqual(StartSSH(master['primary'],
|
105 |
utils.ShellQuoteArgs(cmd)).wait(), 0)
|
106 |
|
107 |
|
108 |
def TestInstanceInfo(instance): |
109 |
"""gnt-instance info"""
|
110 |
master = qa_config.GetMasterNode() |
111 |
|
112 |
cmd = ['gnt-instance', 'info', instance['name']] |
113 |
AssertEqual(StartSSH(master['primary'],
|
114 |
utils.ShellQuoteArgs(cmd)).wait(), 0)
|