root / qa / qa_instance.py @ 6852c52f
History | View | Annotate | Download (10.3 kB)
1 | cec9845c | Michael Hanselmann | # Copyright (C) 2007 Google Inc.
|
---|---|---|---|
2 | cec9845c | Michael Hanselmann | #
|
3 | cec9845c | Michael Hanselmann | # This program is free software; you can redistribute it and/or modify
|
4 | cec9845c | Michael Hanselmann | # it under the terms of the GNU General Public License as published by
|
5 | cec9845c | Michael Hanselmann | # the Free Software Foundation; either version 2 of the License, or
|
6 | cec9845c | Michael Hanselmann | # (at your option) any later version.
|
7 | cec9845c | Michael Hanselmann | #
|
8 | cec9845c | Michael Hanselmann | # This program is distributed in the hope that it will be useful, but
|
9 | cec9845c | Michael Hanselmann | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
10 | cec9845c | Michael Hanselmann | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11 | cec9845c | Michael Hanselmann | # General Public License for more details.
|
12 | cec9845c | Michael Hanselmann | #
|
13 | cec9845c | Michael Hanselmann | # You should have received a copy of the GNU General Public License
|
14 | cec9845c | Michael Hanselmann | # along with this program; if not, write to the Free Software
|
15 | cec9845c | Michael Hanselmann | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
16 | cec9845c | Michael Hanselmann | # 02110-1301, USA.
|
17 | cec9845c | Michael Hanselmann | |
18 | cec9845c | Michael Hanselmann | |
19 | cec9845c | Michael Hanselmann | """Instance related QA tests.
|
20 | cec9845c | Michael Hanselmann |
|
21 | cec9845c | Michael Hanselmann | """
|
22 | cec9845c | Michael Hanselmann | |
23 | e8ae0c20 | Michael Hanselmann | import re |
24 | e8ae0c20 | Michael Hanselmann | import time |
25 | e8ae0c20 | Michael Hanselmann | |
26 | cec9845c | Michael Hanselmann | from ganeti import utils |
27 | 5d640672 | Michael Hanselmann | from ganeti import constants |
28 | cec9845c | Michael Hanselmann | |
29 | cec9845c | Michael Hanselmann | import qa_config |
30 | 5d640672 | Michael Hanselmann | import qa_utils |
31 | e8ae0c20 | Michael Hanselmann | import qa_error |
32 | e8ae0c20 | Michael Hanselmann | |
33 | e8ae0c20 | Michael Hanselmann | from qa_utils import AssertEqual, AssertNotEqual, StartSSH |
34 | cec9845c | Michael Hanselmann | |
35 | e8ae0c20 | Michael Hanselmann | |
36 | e8ae0c20 | Michael Hanselmann | def _GetDiskStatePath(disk): |
37 | e8ae0c20 | Michael Hanselmann | return "/sys/block/%s/device/state" % disk |
38 | cec9845c | Michael Hanselmann | |
39 | cec9845c | Michael Hanselmann | |
40 | 5d640672 | Michael Hanselmann | def _GetGenericAddParameters(): |
41 | 5d640672 | Michael Hanselmann | return ['--os-size=%s' % qa_config.get('os-size'), |
42 | 5d640672 | Michael Hanselmann | '--swap-size=%s' % qa_config.get('swap-size'), |
43 | 5d640672 | Michael Hanselmann | '--memory=%s' % qa_config.get('mem')] |
44 | 5d640672 | Michael Hanselmann | |
45 | 5d640672 | Michael Hanselmann | |
46 | 113b8d89 | Michael Hanselmann | def _DiskTest(node, disk_template): |
47 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
48 | cec9845c | Michael Hanselmann | |
49 | cec9845c | Michael Hanselmann | instance = qa_config.AcquireInstance() |
50 | cec9845c | Michael Hanselmann | try:
|
51 | 5d640672 | Michael Hanselmann | cmd = (['gnt-instance', 'add', |
52 | 5d640672 | Michael Hanselmann | '--os-type=%s' % qa_config.get('os'), |
53 | 113b8d89 | Michael Hanselmann | '--disk-template=%s' % disk_template,
|
54 | 113b8d89 | Michael Hanselmann | '--node=%s' % node] +
|
55 | 5d640672 | Michael Hanselmann | _GetGenericAddParameters()) |
56 | cec9845c | Michael Hanselmann | cmd.append(instance['name'])
|
57 | cec9845c | Michael Hanselmann | |
58 | cec9845c | Michael Hanselmann | AssertEqual(StartSSH(master['primary'],
|
59 | cec9845c | Michael Hanselmann | utils.ShellQuoteArgs(cmd)).wait(), 0)
|
60 | cec9845c | Michael Hanselmann | return instance
|
61 | cec9845c | Michael Hanselmann | except:
|
62 | cec9845c | Michael Hanselmann | qa_config.ReleaseInstance(instance) |
63 | cec9845c | Michael Hanselmann | raise
|
64 | cec9845c | Michael Hanselmann | |
65 | cec9845c | Michael Hanselmann | |
66 | e42b5307 | Michael Hanselmann | @qa_utils.DefineHook('instance-add-plain-disk') |
67 | cec9845c | Michael Hanselmann | def TestInstanceAddWithPlainDisk(node): |
68 | cec9845c | Michael Hanselmann | """gnt-instance add -t plain"""
|
69 | 113b8d89 | Michael Hanselmann | return _DiskTest(node['primary'], 'plain') |
70 | cec9845c | Michael Hanselmann | |
71 | cec9845c | Michael Hanselmann | |
72 | e42b5307 | Michael Hanselmann | @qa_utils.DefineHook('instance-add-local-mirror-disk') |
73 | cec9845c | Michael Hanselmann | def TestInstanceAddWithLocalMirrorDisk(node): |
74 | cec9845c | Michael Hanselmann | """gnt-instance add -t local_raid1"""
|
75 | 113b8d89 | Michael Hanselmann | return _DiskTest(node['primary'], 'local_raid1') |
76 | cec9845c | Michael Hanselmann | |
77 | cec9845c | Michael Hanselmann | |
78 | e42b5307 | Michael Hanselmann | @qa_utils.DefineHook('instance-add-remote-raid-disk') |
79 | cec9845c | Michael Hanselmann | def TestInstanceAddWithRemoteRaidDisk(node, node2): |
80 | cec9845c | Michael Hanselmann | """gnt-instance add -t remote_raid1"""
|
81 | 113b8d89 | Michael Hanselmann | return _DiskTest("%s:%s" % (node['primary'], node2['primary']), |
82 | 113b8d89 | Michael Hanselmann | 'remote_raid1')
|
83 | cec9845c | Michael Hanselmann | |
84 | cec9845c | Michael Hanselmann | |
85 | e42b5307 | Michael Hanselmann | @qa_utils.DefineHook('instance-remove') |
86 | cec9845c | Michael Hanselmann | def TestInstanceRemove(instance): |
87 | cec9845c | Michael Hanselmann | """gnt-instance remove"""
|
88 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
89 | cec9845c | Michael Hanselmann | |
90 | cec9845c | Michael Hanselmann | cmd = ['gnt-instance', 'remove', '-f', instance['name']] |
91 | cec9845c | Michael Hanselmann | AssertEqual(StartSSH(master['primary'],
|
92 | cec9845c | Michael Hanselmann | utils.ShellQuoteArgs(cmd)).wait(), 0)
|
93 | cec9845c | Michael Hanselmann | |
94 | cec9845c | Michael Hanselmann | qa_config.ReleaseInstance(instance) |
95 | cec9845c | Michael Hanselmann | |
96 | cec9845c | Michael Hanselmann | |
97 | e42b5307 | Michael Hanselmann | @qa_utils.DefineHook('instance-startup') |
98 | cec9845c | Michael Hanselmann | def TestInstanceStartup(instance): |
99 | cec9845c | Michael Hanselmann | """gnt-instance startup"""
|
100 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
101 | cec9845c | Michael Hanselmann | |
102 | cec9845c | Michael Hanselmann | cmd = ['gnt-instance', 'startup', instance['name']] |
103 | cec9845c | Michael Hanselmann | AssertEqual(StartSSH(master['primary'],
|
104 | cec9845c | Michael Hanselmann | utils.ShellQuoteArgs(cmd)).wait(), 0)
|
105 | cec9845c | Michael Hanselmann | |
106 | cec9845c | Michael Hanselmann | |
107 | e42b5307 | Michael Hanselmann | @qa_utils.DefineHook('instance-shutdown') |
108 | cec9845c | Michael Hanselmann | def TestInstanceShutdown(instance): |
109 | cec9845c | Michael Hanselmann | """gnt-instance shutdown"""
|
110 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
111 | cec9845c | Michael Hanselmann | |
112 | cec9845c | Michael Hanselmann | cmd = ['gnt-instance', 'shutdown', instance['name']] |
113 | cec9845c | Michael Hanselmann | AssertEqual(StartSSH(master['primary'],
|
114 | cec9845c | Michael Hanselmann | utils.ShellQuoteArgs(cmd)).wait(), 0)
|
115 | cec9845c | Michael Hanselmann | |
116 | cec9845c | Michael Hanselmann | |
117 | e42b5307 | Michael Hanselmann | @qa_utils.DefineHook('instance-reinstall') |
118 | 283f9d4c | Michael Hanselmann | def TestInstanceReinstall(instance): |
119 | 283f9d4c | Michael Hanselmann | """gnt-instance reinstall"""
|
120 | 283f9d4c | Michael Hanselmann | master = qa_config.GetMasterNode() |
121 | 283f9d4c | Michael Hanselmann | |
122 | 283f9d4c | Michael Hanselmann | cmd = ['gnt-instance', 'reinstall', '-f', instance['name']] |
123 | 283f9d4c | Michael Hanselmann | AssertEqual(StartSSH(master['primary'],
|
124 | 283f9d4c | Michael Hanselmann | utils.ShellQuoteArgs(cmd)).wait(), 0)
|
125 | 283f9d4c | Michael Hanselmann | |
126 | 283f9d4c | Michael Hanselmann | |
127 | e42b5307 | Michael Hanselmann | @qa_utils.DefineHook('instance-failover') |
128 | cec9845c | Michael Hanselmann | def TestInstanceFailover(instance): |
129 | cec9845c | Michael Hanselmann | """gnt-instance failover"""
|
130 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
131 | cec9845c | Michael Hanselmann | |
132 | cec9845c | Michael Hanselmann | cmd = ['gnt-instance', 'failover', '--force', instance['name']] |
133 | cec9845c | Michael Hanselmann | AssertEqual(StartSSH(master['primary'],
|
134 | cec9845c | Michael Hanselmann | utils.ShellQuoteArgs(cmd)).wait(), 0)
|
135 | cec9845c | Michael Hanselmann | |
136 | cec9845c | Michael Hanselmann | |
137 | e42b5307 | Michael Hanselmann | @qa_utils.DefineHook('instance-info') |
138 | cec9845c | Michael Hanselmann | def TestInstanceInfo(instance): |
139 | cec9845c | Michael Hanselmann | """gnt-instance info"""
|
140 | cec9845c | Michael Hanselmann | master = qa_config.GetMasterNode() |
141 | cec9845c | Michael Hanselmann | |
142 | cec9845c | Michael Hanselmann | cmd = ['gnt-instance', 'info', instance['name']] |
143 | cec9845c | Michael Hanselmann | AssertEqual(StartSSH(master['primary'],
|
144 | cec9845c | Michael Hanselmann | utils.ShellQuoteArgs(cmd)).wait(), 0)
|
145 | 5d640672 | Michael Hanselmann | |
146 | 5d640672 | Michael Hanselmann | |
147 | e42b5307 | Michael Hanselmann | @qa_utils.DefineHook('instance-list') |
148 | 283f9d4c | Michael Hanselmann | def TestInstanceList(): |
149 | 283f9d4c | Michael Hanselmann | """gnt-instance list"""
|
150 | 283f9d4c | Michael Hanselmann | master = qa_config.GetMasterNode() |
151 | 283f9d4c | Michael Hanselmann | |
152 | 283f9d4c | Michael Hanselmann | cmd = ['gnt-instance', 'list'] |
153 | 283f9d4c | Michael Hanselmann | AssertEqual(StartSSH(master['primary'],
|
154 | 283f9d4c | Michael Hanselmann | utils.ShellQuoteArgs(cmd)).wait(), 0)
|
155 | 283f9d4c | Michael Hanselmann | |
156 | 283f9d4c | Michael Hanselmann | |
157 | e42b5307 | Michael Hanselmann | @qa_utils.DefineHook('backup-export') |
158 | 5d640672 | Michael Hanselmann | def TestInstanceExport(instance, node): |
159 | 5d640672 | Michael Hanselmann | """gnt-backup export"""
|
160 | 5d640672 | Michael Hanselmann | master = qa_config.GetMasterNode() |
161 | 5d640672 | Michael Hanselmann | |
162 | 5d640672 | Michael Hanselmann | cmd = ['gnt-backup', 'export', '-n', node['primary'], instance['name']] |
163 | 5d640672 | Michael Hanselmann | AssertEqual(StartSSH(master['primary'],
|
164 | 5d640672 | Michael Hanselmann | utils.ShellQuoteArgs(cmd)).wait(), 0)
|
165 | 5d640672 | Michael Hanselmann | |
166 | 5d640672 | Michael Hanselmann | return qa_utils.ResolveInstanceName(instance)
|
167 | 5d640672 | Michael Hanselmann | |
168 | 5d640672 | Michael Hanselmann | |
169 | e42b5307 | Michael Hanselmann | @qa_utils.DefineHook('backup-import') |
170 | 5d640672 | Michael Hanselmann | def TestInstanceImport(node, newinst, expnode, name): |
171 | 5d640672 | Michael Hanselmann | """gnt-backup import"""
|
172 | 5d640672 | Michael Hanselmann | master = qa_config.GetMasterNode() |
173 | 5d640672 | Michael Hanselmann | |
174 | 5d640672 | Michael Hanselmann | cmd = (['gnt-backup', 'import', |
175 | 5d640672 | Michael Hanselmann | '--disk-template=plain',
|
176 | 5d640672 | Michael Hanselmann | '--no-ip-check',
|
177 | 5d640672 | Michael Hanselmann | '--src-node=%s' % expnode['primary'], |
178 | 5d640672 | Michael Hanselmann | '--src-dir=%s/%s' % (constants.EXPORT_DIR, name),
|
179 | 5d640672 | Michael Hanselmann | '--node=%s' % node['primary']] + |
180 | 5d640672 | Michael Hanselmann | _GetGenericAddParameters()) |
181 | 5d640672 | Michael Hanselmann | cmd.append(newinst['name'])
|
182 | 5d640672 | Michael Hanselmann | AssertEqual(StartSSH(master['primary'],
|
183 | 5d640672 | Michael Hanselmann | utils.ShellQuoteArgs(cmd)).wait(), 0)
|
184 | 283f9d4c | Michael Hanselmann | |
185 | 283f9d4c | Michael Hanselmann | |
186 | e42b5307 | Michael Hanselmann | @qa_utils.DefineHook('backup-list') |
187 | 283f9d4c | Michael Hanselmann | def TestBackupList(expnode): |
188 | 283f9d4c | Michael Hanselmann | """gnt-backup list"""
|
189 | 283f9d4c | Michael Hanselmann | master = qa_config.GetMasterNode() |
190 | 283f9d4c | Michael Hanselmann | |
191 | 1e020d1b | Michael Hanselmann | cmd = ['gnt-backup', 'list', '--node=%s' % expnode['primary']] |
192 | 283f9d4c | Michael Hanselmann | AssertEqual(StartSSH(master['primary'],
|
193 | 283f9d4c | Michael Hanselmann | utils.ShellQuoteArgs(cmd)).wait(), 0)
|
194 | e8ae0c20 | Michael Hanselmann | |
195 | e8ae0c20 | Michael Hanselmann | |
196 | e8ae0c20 | Michael Hanselmann | def _TestInstanceDiskFailure(instance, node, node2, onmaster): |
197 | e8ae0c20 | Michael Hanselmann | """Testing disk failure."""
|
198 | e8ae0c20 | Michael Hanselmann | master = qa_config.GetMasterNode() |
199 | e8ae0c20 | Michael Hanselmann | sq = utils.ShellQuoteArgs |
200 | e8ae0c20 | Michael Hanselmann | |
201 | e8ae0c20 | Michael Hanselmann | instance_full = qa_utils.ResolveInstanceName(instance) |
202 | e8ae0c20 | Michael Hanselmann | node_full = qa_utils.ResolveNodeName(node) |
203 | e8ae0c20 | Michael Hanselmann | node2_full = qa_utils.ResolveNodeName(node2) |
204 | e8ae0c20 | Michael Hanselmann | |
205 | e8ae0c20 | Michael Hanselmann | cmd = ['gnt-node', 'volumes', '--separator=|', '--no-headers', |
206 | e8ae0c20 | Michael Hanselmann | '--output=node,phys,instance',
|
207 | e8ae0c20 | Michael Hanselmann | node['primary'], node2['primary']] |
208 | e8ae0c20 | Michael Hanselmann | output = qa_utils.GetCommandOutput(master['primary'], sq(cmd))
|
209 | e8ae0c20 | Michael Hanselmann | |
210 | e8ae0c20 | Michael Hanselmann | # Get physical disk names
|
211 | e8ae0c20 | Michael Hanselmann | re_disk = re.compile(r'^/dev/([a-z]+)\d+$')
|
212 | e8ae0c20 | Michael Hanselmann | node2disk = {} |
213 | e8ae0c20 | Michael Hanselmann | for line in output.splitlines(): |
214 | e8ae0c20 | Michael Hanselmann | (node_name, phys, inst) = line.split('|')
|
215 | e8ae0c20 | Michael Hanselmann | if inst == instance_full:
|
216 | e8ae0c20 | Michael Hanselmann | if node_name not in node2disk: |
217 | e8ae0c20 | Michael Hanselmann | node2disk[node_name] = [] |
218 | e8ae0c20 | Michael Hanselmann | |
219 | e8ae0c20 | Michael Hanselmann | m = re_disk.match(phys) |
220 | e8ae0c20 | Michael Hanselmann | if not m: |
221 | e8ae0c20 | Michael Hanselmann | raise qa_error.Error("Unknown disk name format: %s" % disk) |
222 | e8ae0c20 | Michael Hanselmann | |
223 | e8ae0c20 | Michael Hanselmann | name = m.group(1)
|
224 | e8ae0c20 | Michael Hanselmann | if name not in node2disk[node_name]: |
225 | e8ae0c20 | Michael Hanselmann | node2disk[node_name].append(name) |
226 | e8ae0c20 | Michael Hanselmann | |
227 | e8ae0c20 | Michael Hanselmann | if [node2_full, node_full][int(onmaster)] not in node2disk: |
228 | e8ae0c20 | Michael Hanselmann | raise qa_error.Error("Couldn't find physical disks used on " |
229 | e8ae0c20 | Michael Hanselmann | "%s node" % ["secondary", "master"][int(onmaster)]) |
230 | e8ae0c20 | Michael Hanselmann | |
231 | e8ae0c20 | Michael Hanselmann | # Check whether nodes have ability to stop disks
|
232 | e8ae0c20 | Michael Hanselmann | for node_name, disks in node2disk.iteritems(): |
233 | e8ae0c20 | Michael Hanselmann | cmds = [] |
234 | e8ae0c20 | Michael Hanselmann | for disk in disks: |
235 | e8ae0c20 | Michael Hanselmann | cmds.append(sq(["test", "-f", _GetDiskStatePath(disk)])) |
236 | e8ae0c20 | Michael Hanselmann | AssertEqual(StartSSH(node_name, ' && '.join(cmds)).wait(), 0) |
237 | e8ae0c20 | Michael Hanselmann | |
238 | e8ae0c20 | Michael Hanselmann | # Get device paths
|
239 | e8ae0c20 | Michael Hanselmann | cmd = ['gnt-instance', 'activate-disks', instance['name']] |
240 | e8ae0c20 | Michael Hanselmann | output = qa_utils.GetCommandOutput(master['primary'], sq(cmd))
|
241 | e8ae0c20 | Michael Hanselmann | devpath = [] |
242 | e8ae0c20 | Michael Hanselmann | for line in output.splitlines(): |
243 | e8ae0c20 | Michael Hanselmann | (_, _, tmpdevpath) = line.split(':')
|
244 | e8ae0c20 | Michael Hanselmann | devpath.append(tmpdevpath) |
245 | e8ae0c20 | Michael Hanselmann | |
246 | e8ae0c20 | Michael Hanselmann | # Get drbd device paths
|
247 | e8ae0c20 | Michael Hanselmann | cmd = ['gnt-instance', 'info', instance['name']] |
248 | e8ae0c20 | Michael Hanselmann | output = qa_utils.GetCommandOutput(master['primary'], sq(cmd))
|
249 | e8ae0c20 | Michael Hanselmann | pattern = (r'\s+-\s+type:\s+drbd,\s+.*$'
|
250 | e8ae0c20 | Michael Hanselmann | r'\s+primary:\s+(/dev/drbd\d+)\s+')
|
251 | e8ae0c20 | Michael Hanselmann | drbddevs = re.findall(pattern, output, re.M) |
252 | e8ae0c20 | Michael Hanselmann | |
253 | e8ae0c20 | Michael Hanselmann | halted_disks = [] |
254 | e8ae0c20 | Michael Hanselmann | try:
|
255 | b1ffe1eb | Michael Hanselmann | # Deactivate disks
|
256 | b1ffe1eb | Michael Hanselmann | cmds = [] |
257 | b1ffe1eb | Michael Hanselmann | for name in node2disk[[node2_full, node_full][int(onmaster)]]: |
258 | b1ffe1eb | Michael Hanselmann | halted_disks.append(name) |
259 | b1ffe1eb | Michael Hanselmann | cmds.append(sq(["echo", "offline"]) + " >%s" % _GetDiskStatePath(name)) |
260 | b1ffe1eb | Michael Hanselmann | AssertEqual(StartSSH([node2, node][int(onmaster)]['primary'], |
261 | b1ffe1eb | Michael Hanselmann | ' && '.join(cmds)).wait(), 0) |
262 | b1ffe1eb | Michael Hanselmann | |
263 | e8ae0c20 | Michael Hanselmann | # Write something to the disks and give some time to notice the problem
|
264 | e8ae0c20 | Michael Hanselmann | cmds = [] |
265 | e8ae0c20 | Michael Hanselmann | for disk in devpath: |
266 | e8ae0c20 | Michael Hanselmann | cmds.append(sq(["dd", "count=1", "bs=512", "conv=notrunc", |
267 | e8ae0c20 | Michael Hanselmann | "if=%s" % disk, "of=%s" % disk])) |
268 | e8ae0c20 | Michael Hanselmann | for _ in (0, 1, 2): |
269 | e8ae0c20 | Michael Hanselmann | AssertEqual(StartSSH(node['primary'], ' && '.join(cmds)).wait(), 0) |
270 | e8ae0c20 | Michael Hanselmann | time.sleep(3)
|
271 | e8ae0c20 | Michael Hanselmann | |
272 | b1ffe1eb | Michael Hanselmann | for name in drbddevs: |
273 | b1ffe1eb | Michael Hanselmann | cmd = ['drbdsetup', name, 'show'] |
274 | b1ffe1eb | Michael Hanselmann | AssertEqual(StartSSH(node['primary'], sq(cmd)).wait(), 0) |
275 | b1ffe1eb | Michael Hanselmann | |
276 | e8ae0c20 | Michael Hanselmann | # For manual checks
|
277 | e8ae0c20 | Michael Hanselmann | cmd = ['gnt-instance', 'info', instance['name']] |
278 | e8ae0c20 | Michael Hanselmann | AssertEqual(StartSSH(master['primary'], sq(cmd)).wait(), 0) |
279 | e8ae0c20 | Michael Hanselmann | |
280 | e8ae0c20 | Michael Hanselmann | finally:
|
281 | e8ae0c20 | Michael Hanselmann | # Activate disks again
|
282 | e8ae0c20 | Michael Hanselmann | cmds = [] |
283 | e8ae0c20 | Michael Hanselmann | for name in halted_disks: |
284 | e8ae0c20 | Michael Hanselmann | cmds.append(sq(["echo", "running"]) + " >%s" % _GetDiskStatePath(name)) |
285 | e8ae0c20 | Michael Hanselmann | AssertEqual(StartSSH([node2, node][int(onmaster)]['primary'], |
286 | e8ae0c20 | Michael Hanselmann | '; '.join(cmds)).wait(), 0) |
287 | e8ae0c20 | Michael Hanselmann | |
288 | b1ffe1eb | Michael Hanselmann | if onmaster:
|
289 | b1ffe1eb | Michael Hanselmann | for name in drbddevs: |
290 | b1ffe1eb | Michael Hanselmann | cmd = ['drbdsetup', name, 'detach'] |
291 | b1ffe1eb | Michael Hanselmann | AssertEqual(StartSSH(node['primary'], sq(cmd)).wait(), 0) |
292 | b1ffe1eb | Michael Hanselmann | else:
|
293 | b1ffe1eb | Michael Hanselmann | for name in drbddevs: |
294 | b1ffe1eb | Michael Hanselmann | cmd = ['drbdsetup', name, 'disconnect'] |
295 | b1ffe1eb | Michael Hanselmann | AssertEqual(StartSSH(node2['primary'], sq(cmd)).wait(), 0) |
296 | b1ffe1eb | Michael Hanselmann | |
297 | b1ffe1eb | Michael Hanselmann | # Make sure disks are up again
|
298 | b1ffe1eb | Michael Hanselmann | #cmd = ['gnt-instance', 'activate-disks', instance['name']]
|
299 | b1ffe1eb | Michael Hanselmann | #AssertEqual(StartSSH(master['primary'], sq(cmd)).wait(), 0)
|
300 | b1ffe1eb | Michael Hanselmann | |
301 | e8ae0c20 | Michael Hanselmann | # Restart instance
|
302 | e8ae0c20 | Michael Hanselmann | cmd = ['gnt-instance', 'shutdown', instance['name']] |
303 | e8ae0c20 | Michael Hanselmann | AssertEqual(StartSSH(master['primary'], sq(cmd)).wait(), 0) |
304 | e8ae0c20 | Michael Hanselmann | |
305 | b1ffe1eb | Michael Hanselmann | #cmd = ['gnt-instance', 'startup', '--force', instance['name']]
|
306 | b1ffe1eb | Michael Hanselmann | cmd = ['gnt-instance', 'startup', instance['name']] |
307 | e8ae0c20 | Michael Hanselmann | AssertEqual(StartSSH(master['primary'], sq(cmd)).wait(), 0) |
308 | e8ae0c20 | Michael Hanselmann | |
309 | e8ae0c20 | Michael Hanselmann | cmd = ['gnt-cluster', 'verify'] |
310 | e8ae0c20 | Michael Hanselmann | AssertEqual(StartSSH(master['primary'], sq(cmd)).wait(), 0) |
311 | e8ae0c20 | Michael Hanselmann | |
312 | e8ae0c20 | Michael Hanselmann | |
313 | e8ae0c20 | Michael Hanselmann | def TestInstanceMasterDiskFailure(instance, node, node2): |
314 | e8ae0c20 | Michael Hanselmann | """Testing disk failure on master node."""
|
315 | dfe11bad | Michael Hanselmann | print qa_utils.FormatError("Disk failure on primary node cannot be " |
316 | dfe11bad | Michael Hanselmann | "tested due to potential crashes.")
|
317 | e8ae0c20 | Michael Hanselmann | # The following can cause crashes, thus it's disabled until fixed
|
318 | dfe11bad | Michael Hanselmann | #return _TestInstanceDiskFailure(instance, node, node2, True)
|
319 | e8ae0c20 | Michael Hanselmann | |
320 | e8ae0c20 | Michael Hanselmann | |
321 | e8ae0c20 | Michael Hanselmann | def TestInstanceSecondaryDiskFailure(instance, node, node2): |
322 | e8ae0c20 | Michael Hanselmann | """Testing disk failure on secondary node."""
|
323 | e8ae0c20 | Michael Hanselmann | return _TestInstanceDiskFailure(instance, node, node2, False) |