root / test / py / cmdlib / cluster_unittest.py @ b4726cd7
History | View | Annotate | Download (81.3 kB)
1 | 19830e88 | Thomas Thrainer | #!/usr/bin/python
|
---|---|---|---|
2 | 19830e88 | Thomas Thrainer | #
|
3 | 19830e88 | Thomas Thrainer | |
4 | 0e1b5262 | Thomas Thrainer | # Copyright (C) 2008, 2011, 2012, 2013 Google Inc.
|
5 | 19830e88 | Thomas Thrainer | #
|
6 | 19830e88 | Thomas Thrainer | # This program is free software; you can redistribute it and/or modify
|
7 | 19830e88 | Thomas Thrainer | # it under the terms of the GNU General Public License as published by
|
8 | 19830e88 | Thomas Thrainer | # the Free Software Foundation; either version 2 of the License, or
|
9 | 19830e88 | Thomas Thrainer | # (at your option) any later version.
|
10 | 19830e88 | Thomas Thrainer | #
|
11 | 19830e88 | Thomas Thrainer | # This program is distributed in the hope that it will be useful, but
|
12 | 19830e88 | Thomas Thrainer | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 19830e88 | Thomas Thrainer | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 19830e88 | Thomas Thrainer | # General Public License for more details.
|
15 | 19830e88 | Thomas Thrainer | #
|
16 | 19830e88 | Thomas Thrainer | # You should have received a copy of the GNU General Public License
|
17 | 19830e88 | Thomas Thrainer | # along with this program; if not, write to the Free Software
|
18 | 19830e88 | Thomas Thrainer | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 | 19830e88 | Thomas Thrainer | # 02110-1301, USA.
|
20 | 19830e88 | Thomas Thrainer | |
21 | 19830e88 | Thomas Thrainer | |
22 | 19830e88 | Thomas Thrainer | """Tests for LUCluster*
|
23 | 19830e88 | Thomas Thrainer |
|
24 | 19830e88 | Thomas Thrainer | """
|
25 | 19830e88 | Thomas Thrainer | |
26 | 850be460 | Thomas Thrainer | import OpenSSL |
27 | 850be460 | Thomas Thrainer | |
28 | a6c43c02 | Helga Velroyen | import copy |
29 | 0e1b5262 | Thomas Thrainer | import unittest |
30 | 0e1b5262 | Thomas Thrainer | import operator |
31 | 5b6f9e35 | Helga Velroyen | |
32 | b3cc1646 | Helga Velroyen | from ganeti.cmdlib import cluster |
33 | 0e1b5262 | Thomas Thrainer | from ganeti import constants |
34 | a794b8d7 | Thomas Thrainer | from ganeti import errors |
35 | b730e2a7 | Thomas Thrainer | from ganeti import netutils |
36 | 0e1b5262 | Thomas Thrainer | from ganeti import objects |
37 | 19830e88 | Thomas Thrainer | from ganeti import opcodes |
38 | 0e1b5262 | Thomas Thrainer | from ganeti import utils |
39 | 0e1b5262 | Thomas Thrainer | from ganeti import pathutils |
40 | eb172e55 | Thomas Thrainer | from ganeti import query |
41 | 0e1b5262 | Thomas Thrainer | from ganeti.hypervisor import hv_xen |
42 | 19830e88 | Thomas Thrainer | |
43 | 19830e88 | Thomas Thrainer | from testsupport import * |
44 | 19830e88 | Thomas Thrainer | |
45 | 19830e88 | Thomas Thrainer | import testutils |
46 | 0e1b5262 | Thomas Thrainer | |
47 | 0e1b5262 | Thomas Thrainer | |
48 | 0e1b5262 | Thomas Thrainer | class TestClusterVerifySsh(unittest.TestCase): |
49 | 0e1b5262 | Thomas Thrainer | def testMultipleGroups(self): |
50 | 0e1b5262 | Thomas Thrainer | fn = cluster.LUClusterVerifyGroup._SelectSshCheckNodes |
51 | 0e1b5262 | Thomas Thrainer | mygroupnodes = [ |
52 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node20", group="my", offline=False), |
53 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node21", group="my", offline=False), |
54 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node22", group="my", offline=False), |
55 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node23", group="my", offline=False), |
56 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node24", group="my", offline=False), |
57 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node25", group="my", offline=False), |
58 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node26", group="my", offline=True), |
59 | 0e1b5262 | Thomas Thrainer | ] |
60 | 0e1b5262 | Thomas Thrainer | nodes = [ |
61 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node1", group="g1", offline=True), |
62 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node2", group="g1", offline=False), |
63 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node3", group="g1", offline=False), |
64 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node4", group="g1", offline=True), |
65 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node5", group="g1", offline=False), |
66 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node10", group="xyz", offline=False), |
67 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node11", group="xyz", offline=False), |
68 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node40", group="alloff", offline=True), |
69 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node41", group="alloff", offline=True), |
70 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node50", group="aaa", offline=False), |
71 | 0e1b5262 | Thomas Thrainer | ] + mygroupnodes |
72 | 0e1b5262 | Thomas Thrainer | assert not utils.FindDuplicates(map(operator.attrgetter("name"), nodes)) |
73 | 0e1b5262 | Thomas Thrainer | |
74 | 0e1b5262 | Thomas Thrainer | (online, perhost) = fn(mygroupnodes, "my", nodes)
|
75 | 0e1b5262 | Thomas Thrainer | self.assertEqual(online, ["node%s" % i for i in range(20, 26)]) |
76 | 0e1b5262 | Thomas Thrainer | self.assertEqual(set(perhost.keys()), set(online)) |
77 | 0e1b5262 | Thomas Thrainer | |
78 | 0e1b5262 | Thomas Thrainer | self.assertEqual(perhost, {
|
79 | 0e1b5262 | Thomas Thrainer | "node20": ["node10", "node2", "node50"], |
80 | 0e1b5262 | Thomas Thrainer | "node21": ["node11", "node3", "node50"], |
81 | 0e1b5262 | Thomas Thrainer | "node22": ["node10", "node5", "node50"], |
82 | 0e1b5262 | Thomas Thrainer | "node23": ["node11", "node2", "node50"], |
83 | 0e1b5262 | Thomas Thrainer | "node24": ["node10", "node3", "node50"], |
84 | 0e1b5262 | Thomas Thrainer | "node25": ["node11", "node5", "node50"], |
85 | 0e1b5262 | Thomas Thrainer | }) |
86 | 0e1b5262 | Thomas Thrainer | |
87 | 0e1b5262 | Thomas Thrainer | def testSingleGroup(self): |
88 | 0e1b5262 | Thomas Thrainer | fn = cluster.LUClusterVerifyGroup._SelectSshCheckNodes |
89 | 0e1b5262 | Thomas Thrainer | nodes = [ |
90 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node1", group="default", offline=True), |
91 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node2", group="default", offline=False), |
92 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node3", group="default", offline=False), |
93 | 0e1b5262 | Thomas Thrainer | objects.Node(name="node4", group="default", offline=True), |
94 | 0e1b5262 | Thomas Thrainer | ] |
95 | 0e1b5262 | Thomas Thrainer | assert not utils.FindDuplicates(map(operator.attrgetter("name"), nodes)) |
96 | 0e1b5262 | Thomas Thrainer | |
97 | 0e1b5262 | Thomas Thrainer | (online, perhost) = fn(nodes, "default", nodes)
|
98 | 0e1b5262 | Thomas Thrainer | self.assertEqual(online, ["node2", "node3"]) |
99 | 0e1b5262 | Thomas Thrainer | self.assertEqual(set(perhost.keys()), set(online)) |
100 | 0e1b5262 | Thomas Thrainer | |
101 | 0e1b5262 | Thomas Thrainer | self.assertEqual(perhost, {
|
102 | 0e1b5262 | Thomas Thrainer | "node2": [],
|
103 | 0e1b5262 | Thomas Thrainer | "node3": [],
|
104 | 0e1b5262 | Thomas Thrainer | }) |
105 | 0e1b5262 | Thomas Thrainer | |
106 | 0e1b5262 | Thomas Thrainer | |
107 | 19830e88 | Thomas Thrainer | class TestLUClusterActivateMasterIp(CmdlibTestCase): |
108 | 19830e88 | Thomas Thrainer | def testSuccess(self): |
109 | 19830e88 | Thomas Thrainer | op = opcodes.OpClusterActivateMasterIp() |
110 | 19830e88 | Thomas Thrainer | |
111 | 19830e88 | Thomas Thrainer | self.rpc.call_node_activate_master_ip.return_value = \
|
112 | a794b8d7 | Thomas Thrainer | self.RpcResultsBuilder() \
|
113 | f02733cc | Thomas Thrainer | .CreateSuccessfulNodeResult(self.master)
|
114 | 19830e88 | Thomas Thrainer | |
115 | 19830e88 | Thomas Thrainer | self.ExecOpCode(op)
|
116 | 19830e88 | Thomas Thrainer | |
117 | 19830e88 | Thomas Thrainer | self.rpc.call_node_activate_master_ip.assert_called_once_with(
|
118 | f02733cc | Thomas Thrainer | self.master_uuid, self.cfg.GetMasterNetworkParameters(), False) |
119 | 19830e88 | Thomas Thrainer | |
120 | 19830e88 | Thomas Thrainer | def testFailure(self): |
121 | 19830e88 | Thomas Thrainer | op = opcodes.OpClusterActivateMasterIp() |
122 | 19830e88 | Thomas Thrainer | |
123 | 19830e88 | Thomas Thrainer | self.rpc.call_node_activate_master_ip.return_value = \
|
124 | a794b8d7 | Thomas Thrainer | self.RpcResultsBuilder() \
|
125 | f02733cc | Thomas Thrainer | .CreateFailedNodeResult(self.master) \
|
126 | 19830e88 | Thomas Thrainer | |
127 | 19830e88 | Thomas Thrainer | self.ExecOpCodeExpectOpExecError(op)
|
128 | 19830e88 | Thomas Thrainer | |
129 | 19830e88 | Thomas Thrainer | |
130 | e0b8df13 | Thomas Thrainer | class TestLUClusterDeactivateMasterIp(CmdlibTestCase): |
131 | e0b8df13 | Thomas Thrainer | def testSuccess(self): |
132 | e0b8df13 | Thomas Thrainer | op = opcodes.OpClusterDeactivateMasterIp() |
133 | e0b8df13 | Thomas Thrainer | |
134 | e0b8df13 | Thomas Thrainer | self.rpc.call_node_deactivate_master_ip.return_value = \
|
135 | a794b8d7 | Thomas Thrainer | self.RpcResultsBuilder() \
|
136 | f02733cc | Thomas Thrainer | .CreateSuccessfulNodeResult(self.master)
|
137 | e0b8df13 | Thomas Thrainer | |
138 | e0b8df13 | Thomas Thrainer | self.ExecOpCode(op)
|
139 | e0b8df13 | Thomas Thrainer | |
140 | e0b8df13 | Thomas Thrainer | self.rpc.call_node_deactivate_master_ip.assert_called_once_with(
|
141 | f02733cc | Thomas Thrainer | self.master_uuid, self.cfg.GetMasterNetworkParameters(), False) |
142 | e0b8df13 | Thomas Thrainer | |
143 | e0b8df13 | Thomas Thrainer | def testFailure(self): |
144 | e0b8df13 | Thomas Thrainer | op = opcodes.OpClusterDeactivateMasterIp() |
145 | e0b8df13 | Thomas Thrainer | |
146 | e0b8df13 | Thomas Thrainer | self.rpc.call_node_deactivate_master_ip.return_value = \
|
147 | a794b8d7 | Thomas Thrainer | self.RpcResultsBuilder() \
|
148 | f02733cc | Thomas Thrainer | .CreateFailedNodeResult(self.master) \
|
149 | e0b8df13 | Thomas Thrainer | |
150 | e0b8df13 | Thomas Thrainer | self.ExecOpCodeExpectOpExecError(op)
|
151 | e0b8df13 | Thomas Thrainer | |
152 | e0b8df13 | Thomas Thrainer | |
153 | eb172e55 | Thomas Thrainer | class TestLUClusterConfigQuery(CmdlibTestCase): |
154 | eb172e55 | Thomas Thrainer | def testInvalidField(self): |
155 | eb172e55 | Thomas Thrainer | op = opcodes.OpClusterConfigQuery(output_fields=["pinky_bunny"])
|
156 | eb172e55 | Thomas Thrainer | |
157 | eb172e55 | Thomas Thrainer | self.ExecOpCodeExpectOpPrereqError(op, "pinky_bunny") |
158 | eb172e55 | Thomas Thrainer | |
159 | eb172e55 | Thomas Thrainer | def testAllFields(self): |
160 | eb172e55 | Thomas Thrainer | op = opcodes.OpClusterConfigQuery(output_fields=query.CLUSTER_FIELDS.keys()) |
161 | eb172e55 | Thomas Thrainer | |
162 | eb172e55 | Thomas Thrainer | self.rpc.call_get_watcher_pause.return_value = \
|
163 | a794b8d7 | Thomas Thrainer | self.RpcResultsBuilder() \
|
164 | f02733cc | Thomas Thrainer | .CreateSuccessfulNodeResult(self.master, -1) |
165 | eb172e55 | Thomas Thrainer | |
166 | eb172e55 | Thomas Thrainer | ret = self.ExecOpCode(op)
|
167 | eb172e55 | Thomas Thrainer | |
168 | eb172e55 | Thomas Thrainer | self.assertEqual(1, self.rpc.call_get_watcher_pause.call_count) |
169 | eb172e55 | Thomas Thrainer | self.assertEqual(len(ret), len(query.CLUSTER_FIELDS)) |
170 | eb172e55 | Thomas Thrainer | |
171 | eb172e55 | Thomas Thrainer | def testEmpytFields(self): |
172 | eb172e55 | Thomas Thrainer | op = opcodes.OpClusterConfigQuery(output_fields=[]) |
173 | eb172e55 | Thomas Thrainer | |
174 | eb172e55 | Thomas Thrainer | self.ExecOpCode(op)
|
175 | eb172e55 | Thomas Thrainer | |
176 | eb172e55 | Thomas Thrainer | self.assertFalse(self.rpc.call_get_watcher_pause.called) |
177 | eb172e55 | Thomas Thrainer | |
178 | eb172e55 | Thomas Thrainer | |
179 | bd6fb93b | Thomas Thrainer | class TestLUClusterDestroy(CmdlibTestCase): |
180 | bd6fb93b | Thomas Thrainer | def testExistingNodes(self): |
181 | bd6fb93b | Thomas Thrainer | op = opcodes.OpClusterDestroy() |
182 | bd6fb93b | Thomas Thrainer | |
183 | bd6fb93b | Thomas Thrainer | self.cfg.AddNewNode()
|
184 | bd6fb93b | Thomas Thrainer | self.cfg.AddNewNode()
|
185 | bd6fb93b | Thomas Thrainer | |
186 | bd6fb93b | Thomas Thrainer | self.ExecOpCodeExpectOpPrereqError(op, "still 2 node\(s\)") |
187 | bd6fb93b | Thomas Thrainer | |
188 | bd6fb93b | Thomas Thrainer | def testExistingInstances(self): |
189 | bd6fb93b | Thomas Thrainer | op = opcodes.OpClusterDestroy() |
190 | bd6fb93b | Thomas Thrainer | |
191 | bd6fb93b | Thomas Thrainer | self.cfg.AddNewInstance()
|
192 | bd6fb93b | Thomas Thrainer | self.cfg.AddNewInstance()
|
193 | bd6fb93b | Thomas Thrainer | |
194 | bd6fb93b | Thomas Thrainer | self.ExecOpCodeExpectOpPrereqError(op, "still 2 instance\(s\)") |
195 | bd6fb93b | Thomas Thrainer | |
196 | bd6fb93b | Thomas Thrainer | def testEmptyCluster(self): |
197 | bd6fb93b | Thomas Thrainer | op = opcodes.OpClusterDestroy() |
198 | bd6fb93b | Thomas Thrainer | |
199 | bd6fb93b | Thomas Thrainer | self.ExecOpCode(op)
|
200 | bd6fb93b | Thomas Thrainer | |
201 | f02733cc | Thomas Thrainer | self.assertSingleHooksCall([self.master.name], |
202 | 812e07ab | Thomas Thrainer | "cluster-destroy",
|
203 | 812e07ab | Thomas Thrainer | constants.HOOKS_PHASE_POST) |
204 | bd6fb93b | Thomas Thrainer | |
205 | bd6fb93b | Thomas Thrainer | |
206 | 812e07ab | Thomas Thrainer | class TestLUClusterPostInit(CmdlibTestCase): |
207 | b3cc1646 | Helga Velroyen | |
208 | b3cc1646 | Helga Velroyen | @testutils.patch_object(cluster, "_UpdateMasterClientCert") |
209 | b3cc1646 | Helga Velroyen | def testExecution(self, update_client_cert_mock): |
210 | b3cc1646 | Helga Velroyen | # mock the client certificate creation as it is tested separately
|
211 | b3cc1646 | Helga Velroyen | update_client_cert_mock.return_value = None
|
212 | 5b6f9e35 | Helga Velroyen | # For the purpose of this test, return the same certificate digest for all
|
213 | 5b6f9e35 | Helga Velroyen | # nodes
|
214 | 5b6f9e35 | Helga Velroyen | self.rpc.call_node_crypto_tokens = \
|
215 | 5b6f9e35 | Helga Velroyen | lambda node_uuid, _: self.RpcResultsBuilder() \ |
216 | 5b6f9e35 | Helga Velroyen | .CreateSuccessfulNodeResult(node_uuid, |
217 | 5b6f9e35 | Helga Velroyen | [(constants.CRYPTO_TYPE_SSL_DIGEST, "IA:MA:FA:KE:DI:GE:ST")])
|
218 | 812e07ab | Thomas Thrainer | op = opcodes.OpClusterPostInit() |
219 | 812e07ab | Thomas Thrainer | |
220 | 812e07ab | Thomas Thrainer | self.ExecOpCode(op)
|
221 | 812e07ab | Thomas Thrainer | |
222 | f02733cc | Thomas Thrainer | self.assertSingleHooksCall([self.master.name], |
223 | 812e07ab | Thomas Thrainer | "cluster-init",
|
224 | 812e07ab | Thomas Thrainer | constants.HOOKS_PHASE_POST) |
225 | 812e07ab | Thomas Thrainer | |
226 | b730e2a7 | Thomas Thrainer | |
227 | b730e2a7 | Thomas Thrainer | class TestLUClusterQuery(CmdlibTestCase): |
228 | b730e2a7 | Thomas Thrainer | def testSimpleInvocation(self): |
229 | b730e2a7 | Thomas Thrainer | op = opcodes.OpClusterQuery() |
230 | b730e2a7 | Thomas Thrainer | |
231 | b730e2a7 | Thomas Thrainer | self.ExecOpCode(op)
|
232 | b730e2a7 | Thomas Thrainer | |
233 | b730e2a7 | Thomas Thrainer | def testIPv6Cluster(self): |
234 | b730e2a7 | Thomas Thrainer | op = opcodes.OpClusterQuery() |
235 | b730e2a7 | Thomas Thrainer | |
236 | f02733cc | Thomas Thrainer | self.cluster.primary_ip_family = netutils.IP6Address.family
|
237 | b730e2a7 | Thomas Thrainer | |
238 | b730e2a7 | Thomas Thrainer | self.ExecOpCode(op)
|
239 | b730e2a7 | Thomas Thrainer | |
240 | b730e2a7 | Thomas Thrainer | |
241 | 6aac41fa | Thomas Thrainer | class TestLUClusterRedistConf(CmdlibTestCase): |
242 | 6aac41fa | Thomas Thrainer | def testSimpleInvocation(self): |
243 | 6aac41fa | Thomas Thrainer | op = opcodes.OpClusterRedistConf() |
244 | 6aac41fa | Thomas Thrainer | |
245 | 6aac41fa | Thomas Thrainer | self.ExecOpCode(op)
|
246 | 6aac41fa | Thomas Thrainer | |
247 | 6aac41fa | Thomas Thrainer | |
248 | 08cef8fc | Thomas Thrainer | class TestLUClusterRename(CmdlibTestCase): |
249 | 08cef8fc | Thomas Thrainer | NEW_NAME = "new-name.example.com"
|
250 | 4256f8fe | Sebastian Gebhard | NEW_IP = "203.0.113.100"
|
251 | 08cef8fc | Thomas Thrainer | |
252 | 08cef8fc | Thomas Thrainer | def testNoChanges(self): |
253 | 08cef8fc | Thomas Thrainer | op = opcodes.OpClusterRename(name=self.cfg.GetClusterName())
|
254 | 08cef8fc | Thomas Thrainer | |
255 | 08cef8fc | Thomas Thrainer | self.ExecOpCodeExpectOpPrereqError(op, "name nor the IP address") |
256 | 08cef8fc | Thomas Thrainer | |
257 | 08cef8fc | Thomas Thrainer | def testReachableIp(self): |
258 | 08cef8fc | Thomas Thrainer | op = opcodes.OpClusterRename(name=self.NEW_NAME)
|
259 | 08cef8fc | Thomas Thrainer | |
260 | 08cef8fc | Thomas Thrainer | self.netutils_mod.GetHostname.return_value = \
|
261 | 08cef8fc | Thomas Thrainer | HostnameMock(self.NEW_NAME, self.NEW_IP) |
262 | 08cef8fc | Thomas Thrainer | self.netutils_mod.TcpPing.return_value = True |
263 | 08cef8fc | Thomas Thrainer | |
264 | 08cef8fc | Thomas Thrainer | self.ExecOpCodeExpectOpPrereqError(op, "is reachable on the network") |
265 | 08cef8fc | Thomas Thrainer | |
266 | 08cef8fc | Thomas Thrainer | def testValidRename(self): |
267 | 08cef8fc | Thomas Thrainer | op = opcodes.OpClusterRename(name=self.NEW_NAME)
|
268 | 08cef8fc | Thomas Thrainer | |
269 | 08cef8fc | Thomas Thrainer | self.netutils_mod.GetHostname.return_value = \
|
270 | 08cef8fc | Thomas Thrainer | HostnameMock(self.NEW_NAME, self.NEW_IP) |
271 | 08cef8fc | Thomas Thrainer | |
272 | 08cef8fc | Thomas Thrainer | self.ExecOpCode(op)
|
273 | 08cef8fc | Thomas Thrainer | |
274 | 08cef8fc | Thomas Thrainer | self.assertEqual(1, self.ssh_mod.WriteKnownHostsFile.call_count) |
275 | 08cef8fc | Thomas Thrainer | self.rpc.call_node_deactivate_master_ip.assert_called_once_with(
|
276 | f02733cc | Thomas Thrainer | self.master_uuid, self.cfg.GetMasterNetworkParameters(), False) |
277 | 08cef8fc | Thomas Thrainer | self.rpc.call_node_activate_master_ip.assert_called_once_with(
|
278 | f02733cc | Thomas Thrainer | self.master_uuid, self.cfg.GetMasterNetworkParameters(), False) |
279 | 08cef8fc | Thomas Thrainer | |
280 | 08cef8fc | Thomas Thrainer | def testRenameOfflineMaster(self): |
281 | 08cef8fc | Thomas Thrainer | op = opcodes.OpClusterRename(name=self.NEW_NAME)
|
282 | 08cef8fc | Thomas Thrainer | |
283 | f02733cc | Thomas Thrainer | self.master.offline = True |
284 | 08cef8fc | Thomas Thrainer | self.netutils_mod.GetHostname.return_value = \
|
285 | 08cef8fc | Thomas Thrainer | HostnameMock(self.NEW_NAME, self.NEW_IP) |
286 | 08cef8fc | Thomas Thrainer | |
287 | 08cef8fc | Thomas Thrainer | self.ExecOpCode(op)
|
288 | 08cef8fc | Thomas Thrainer | |
289 | 08cef8fc | Thomas Thrainer | |
290 | c487ae24 | Thomas Thrainer | class TestLUClusterRepairDiskSizes(CmdlibTestCase): |
291 | c487ae24 | Thomas Thrainer | def testNoInstances(self): |
292 | c487ae24 | Thomas Thrainer | op = opcodes.OpClusterRepairDiskSizes() |
293 | c487ae24 | Thomas Thrainer | |
294 | c487ae24 | Thomas Thrainer | self.ExecOpCode(op)
|
295 | c487ae24 | Thomas Thrainer | |
296 | 0c5f1b13 | Thomas Thrainer | def _SetUpInstanceSingleDisk(self, dev_type=constants.DT_PLAIN): |
297 | f02733cc | Thomas Thrainer | pnode = self.master
|
298 | c487ae24 | Thomas Thrainer | snode = self.cfg.AddNewNode()
|
299 | c487ae24 | Thomas Thrainer | |
300 | c487ae24 | Thomas Thrainer | disk = self.cfg.CreateDisk(dev_type=dev_type,
|
301 | c487ae24 | Thomas Thrainer | primary_node=pnode, |
302 | c487ae24 | Thomas Thrainer | secondary_node=snode) |
303 | a794b8d7 | Thomas Thrainer | inst = self.cfg.AddNewInstance(disks=[disk])
|
304 | c487ae24 | Thomas Thrainer | |
305 | c487ae24 | Thomas Thrainer | return (inst, disk)
|
306 | c487ae24 | Thomas Thrainer | |
307 | c487ae24 | Thomas Thrainer | def testSingleInstanceOnFailingNode(self): |
308 | c487ae24 | Thomas Thrainer | (inst, _) = self._SetUpInstanceSingleDisk()
|
309 | c487ae24 | Thomas Thrainer | op = opcodes.OpClusterRepairDiskSizes(instances=[inst.name]) |
310 | c487ae24 | Thomas Thrainer | |
311 | c487ae24 | Thomas Thrainer | self.rpc.call_blockdev_getdimensions.return_value = \
|
312 | a794b8d7 | Thomas Thrainer | self.RpcResultsBuilder() \
|
313 | f02733cc | Thomas Thrainer | .CreateFailedNodeResult(self.master)
|
314 | c487ae24 | Thomas Thrainer | |
315 | c487ae24 | Thomas Thrainer | self.ExecOpCode(op)
|
316 | c487ae24 | Thomas Thrainer | |
317 | c487ae24 | Thomas Thrainer | self.mcpu.assertLogContainsRegex("Failure in blockdev_getdimensions") |
318 | c487ae24 | Thomas Thrainer | |
319 | c487ae24 | Thomas Thrainer | def _ExecOpClusterRepairDiskSizes(self, node_data): |
320 | c487ae24 | Thomas Thrainer | # not specifying instances repairs all
|
321 | c487ae24 | Thomas Thrainer | op = opcodes.OpClusterRepairDiskSizes() |
322 | c487ae24 | Thomas Thrainer | |
323 | c487ae24 | Thomas Thrainer | self.rpc.call_blockdev_getdimensions.return_value = \
|
324 | a794b8d7 | Thomas Thrainer | self.RpcResultsBuilder() \
|
325 | f02733cc | Thomas Thrainer | .CreateSuccessfulNodeResult(self.master, node_data)
|
326 | c487ae24 | Thomas Thrainer | |
327 | c487ae24 | Thomas Thrainer | return self.ExecOpCode(op) |
328 | c487ae24 | Thomas Thrainer | |
329 | c487ae24 | Thomas Thrainer | def testInvalidResultData(self): |
330 | c487ae24 | Thomas Thrainer | for data in [[], [None], ["invalid"], [("still", "invalid")]]: |
331 | c487ae24 | Thomas Thrainer | self.ResetMocks()
|
332 | c487ae24 | Thomas Thrainer | |
333 | c487ae24 | Thomas Thrainer | self._SetUpInstanceSingleDisk()
|
334 | c487ae24 | Thomas Thrainer | self._ExecOpClusterRepairDiskSizes(data)
|
335 | c487ae24 | Thomas Thrainer | |
336 | c487ae24 | Thomas Thrainer | self.mcpu.assertLogContainsRegex("ignoring") |
337 | c487ae24 | Thomas Thrainer | |
338 | c487ae24 | Thomas Thrainer | def testCorrectSize(self): |
339 | c487ae24 | Thomas Thrainer | self._SetUpInstanceSingleDisk()
|
340 | c487ae24 | Thomas Thrainer | changed = self._ExecOpClusterRepairDiskSizes([(1024 * 1024 * 1024, None)]) |
341 | c487ae24 | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
342 | c487ae24 | Thomas Thrainer | self.assertEqual(0, len(changed)) |
343 | c487ae24 | Thomas Thrainer | |
344 | c487ae24 | Thomas Thrainer | def testWrongSize(self): |
345 | c487ae24 | Thomas Thrainer | self._SetUpInstanceSingleDisk()
|
346 | c487ae24 | Thomas Thrainer | changed = self._ExecOpClusterRepairDiskSizes([(512 * 1024 * 1024, None)]) |
347 | c487ae24 | Thomas Thrainer | self.assertEqual(1, len(changed)) |
348 | c487ae24 | Thomas Thrainer | |
349 | c487ae24 | Thomas Thrainer | def testCorrectDRBD(self): |
350 | 0c5f1b13 | Thomas Thrainer | self._SetUpInstanceSingleDisk(dev_type=constants.DT_DRBD8)
|
351 | c487ae24 | Thomas Thrainer | changed = self._ExecOpClusterRepairDiskSizes([(1024 * 1024 * 1024, None)]) |
352 | c487ae24 | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
353 | c487ae24 | Thomas Thrainer | self.assertEqual(0, len(changed)) |
354 | c487ae24 | Thomas Thrainer | |
355 | c487ae24 | Thomas Thrainer | def testWrongDRBDChild(self): |
356 | 0c5f1b13 | Thomas Thrainer | (_, disk) = self._SetUpInstanceSingleDisk(dev_type=constants.DT_DRBD8)
|
357 | c487ae24 | Thomas Thrainer | disk.children[0].size = 512 |
358 | c487ae24 | Thomas Thrainer | changed = self._ExecOpClusterRepairDiskSizes([(1024 * 1024 * 1024, None)]) |
359 | c487ae24 | Thomas Thrainer | self.assertEqual(1, len(changed)) |
360 | c487ae24 | Thomas Thrainer | |
361 | c487ae24 | Thomas Thrainer | def testExclusiveStorageInvalidResultData(self): |
362 | c487ae24 | Thomas Thrainer | self._SetUpInstanceSingleDisk()
|
363 | f02733cc | Thomas Thrainer | self.master.ndparams[constants.ND_EXCLUSIVE_STORAGE] = True |
364 | c487ae24 | Thomas Thrainer | self._ExecOpClusterRepairDiskSizes([(1024 * 1024 * 1024, None)]) |
365 | c487ae24 | Thomas Thrainer | |
366 | c487ae24 | Thomas Thrainer | self.mcpu.assertLogContainsRegex(
|
367 | c487ae24 | Thomas Thrainer | "did not return valid spindles information")
|
368 | c487ae24 | Thomas Thrainer | |
369 | c487ae24 | Thomas Thrainer | def testExclusiveStorageCorrectSpindles(self): |
370 | c487ae24 | Thomas Thrainer | (_, disk) = self._SetUpInstanceSingleDisk()
|
371 | c487ae24 | Thomas Thrainer | disk.spindles = 1
|
372 | f02733cc | Thomas Thrainer | self.master.ndparams[constants.ND_EXCLUSIVE_STORAGE] = True |
373 | c487ae24 | Thomas Thrainer | changed = self._ExecOpClusterRepairDiskSizes([(1024 * 1024 * 1024, 1)]) |
374 | c487ae24 | Thomas Thrainer | self.assertEqual(0, len(changed)) |
375 | c487ae24 | Thomas Thrainer | |
376 | c487ae24 | Thomas Thrainer | def testExclusiveStorageWrongSpindles(self): |
377 | c487ae24 | Thomas Thrainer | self._SetUpInstanceSingleDisk()
|
378 | f02733cc | Thomas Thrainer | self.master.ndparams[constants.ND_EXCLUSIVE_STORAGE] = True |
379 | c487ae24 | Thomas Thrainer | changed = self._ExecOpClusterRepairDiskSizes([(1024 * 1024 * 1024, 1)]) |
380 | c487ae24 | Thomas Thrainer | self.assertEqual(1, len(changed)) |
381 | c487ae24 | Thomas Thrainer | |
382 | c487ae24 | Thomas Thrainer | |
383 | a794b8d7 | Thomas Thrainer | class TestLUClusterSetParams(CmdlibTestCase): |
384 | a794b8d7 | Thomas Thrainer | UID_POOL = [(10, 1000)] |
385 | a794b8d7 | Thomas Thrainer | |
386 | a794b8d7 | Thomas Thrainer | def testUidPool(self): |
387 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(uid_pool=self.UID_POOL)
|
388 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
389 | a794b8d7 | Thomas Thrainer | self.assertEqual(self.UID_POOL, self.cluster.uid_pool) |
390 | a794b8d7 | Thomas Thrainer | |
391 | a794b8d7 | Thomas Thrainer | def testAddUids(self): |
392 | a794b8d7 | Thomas Thrainer | old_pool = [(1, 9)] |
393 | a794b8d7 | Thomas Thrainer | self.cluster.uid_pool = list(old_pool) |
394 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(add_uids=self.UID_POOL)
|
395 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
396 | a794b8d7 | Thomas Thrainer | self.assertEqual(set(self.UID_POOL + old_pool), |
397 | a794b8d7 | Thomas Thrainer | set(self.cluster.uid_pool)) |
398 | a794b8d7 | Thomas Thrainer | |
399 | a794b8d7 | Thomas Thrainer | def testRemoveUids(self): |
400 | a794b8d7 | Thomas Thrainer | additional_pool = [(1, 9)] |
401 | a794b8d7 | Thomas Thrainer | self.cluster.uid_pool = self.UID_POOL + additional_pool |
402 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(remove_uids=self.UID_POOL)
|
403 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
404 | a794b8d7 | Thomas Thrainer | self.assertEqual(additional_pool, self.cluster.uid_pool) |
405 | a794b8d7 | Thomas Thrainer | |
406 | b4726cd7 | Dimitris Bliablias | def testMacPrefix(self): |
407 | b4726cd7 | Dimitris Bliablias | mac_prefix = "aa:01:02"
|
408 | b4726cd7 | Dimitris Bliablias | op = opcodes.OpClusterSetParams(mac_prefix=mac_prefix) |
409 | b4726cd7 | Dimitris Bliablias | self.ExecOpCode(op)
|
410 | b4726cd7 | Dimitris Bliablias | self.assertEqual(mac_prefix, self.cluster.mac_prefix) |
411 | b4726cd7 | Dimitris Bliablias | |
412 | b4726cd7 | Dimitris Bliablias | def testEmptyMacPrefix(self): |
413 | b4726cd7 | Dimitris Bliablias | mac_prefix = ""
|
414 | b4726cd7 | Dimitris Bliablias | op = opcodes.OpClusterSetParams(mac_prefix=mac_prefix) |
415 | b4726cd7 | Dimitris Bliablias | self.ExecOpCodeExpectOpPrereqError(
|
416 | b4726cd7 | Dimitris Bliablias | op, "Parameter 'OP_CLUSTER_SET_PARAMS.mac_prefix' fails validation")
|
417 | b4726cd7 | Dimitris Bliablias | |
418 | b4726cd7 | Dimitris Bliablias | def testInvalidMacPrefix(self): |
419 | b4726cd7 | Dimitris Bliablias | mac_prefix = "az:00:00"
|
420 | b4726cd7 | Dimitris Bliablias | op = opcodes.OpClusterSetParams(mac_prefix=mac_prefix) |
421 | b4726cd7 | Dimitris Bliablias | self.ExecOpCodeExpectOpPrereqError(op, "Invalid MAC address prefix") |
422 | b4726cd7 | Dimitris Bliablias | |
423 | a794b8d7 | Thomas Thrainer | def testMasterNetmask(self): |
424 | f41b569f | Thomas Thrainer | op = opcodes.OpClusterSetParams(master_netmask=26)
|
425 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
426 | f41b569f | Thomas Thrainer | self.assertEqual(26, self.cluster.master_netmask) |
427 | a794b8d7 | Thomas Thrainer | |
428 | a794b8d7 | Thomas Thrainer | def testInvalidDiskparams(self): |
429 | a794b8d7 | Thomas Thrainer | for diskparams in [{constants.DT_DISKLESS: {constants.LV_STRIPES: 0}}, |
430 | 9b9e088c | Raffa Santi | {constants.DT_DRBD8: {constants.RBD_POOL: "pool"}},
|
431 | 9b9e088c | Raffa Santi | {constants.DT_DRBD8: {constants.RBD_ACCESS: "bunny"}}]:
|
432 | a794b8d7 | Thomas Thrainer | self.ResetMocks()
|
433 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(diskparams=diskparams) |
434 | a794b8d7 | Thomas Thrainer | self.ExecOpCodeExpectOpPrereqError(op, "verify diskparams") |
435 | a794b8d7 | Thomas Thrainer | |
436 | a794b8d7 | Thomas Thrainer | def testValidDiskparams(self): |
437 | 9b9e088c | Raffa Santi | diskparams = {constants.DT_RBD: {constants.RBD_POOL: "mock_pool",
|
438 | 9b9e088c | Raffa Santi | constants.RBD_ACCESS: "kernelspace"}}
|
439 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(diskparams=diskparams) |
440 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
441 | a794b8d7 | Thomas Thrainer | self.assertEqual(diskparams[constants.DT_RBD],
|
442 | a794b8d7 | Thomas Thrainer | self.cluster.diskparams[constants.DT_RBD])
|
443 | a794b8d7 | Thomas Thrainer | |
444 | a794b8d7 | Thomas Thrainer | def testMinimalDiskparams(self): |
445 | a794b8d7 | Thomas Thrainer | diskparams = {constants.DT_RBD: {constants.RBD_POOL: "mock_pool"}}
|
446 | a794b8d7 | Thomas Thrainer | self.cluster.diskparams = {}
|
447 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(diskparams=diskparams) |
448 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
449 | a794b8d7 | Thomas Thrainer | self.assertEqual(diskparams, self.cluster.diskparams) |
450 | a794b8d7 | Thomas Thrainer | |
451 | 537dba0c | Raffa Santi | def testValidDiskparamsAccess(self): |
452 | 537dba0c | Raffa Santi | for value in constants.DISK_VALID_ACCESS_MODES: |
453 | 537dba0c | Raffa Santi | self.ResetMocks()
|
454 | 537dba0c | Raffa Santi | op = opcodes.OpClusterSetParams(diskparams={ |
455 | 537dba0c | Raffa Santi | constants.DT_RBD: {constants.RBD_ACCESS: value} |
456 | 537dba0c | Raffa Santi | }) |
457 | 537dba0c | Raffa Santi | self.ExecOpCode(op)
|
458 | 537dba0c | Raffa Santi | got = self.cluster.diskparams[constants.DT_RBD][constants.RBD_ACCESS]
|
459 | 537dba0c | Raffa Santi | self.assertEqual(value, got)
|
460 | 537dba0c | Raffa Santi | |
461 | 537dba0c | Raffa Santi | def testInvalidDiskparamsAccess(self): |
462 | 537dba0c | Raffa Santi | for value in ["default", "pinky_bunny"]: |
463 | 537dba0c | Raffa Santi | self.ResetMocks()
|
464 | 537dba0c | Raffa Santi | op = opcodes.OpClusterSetParams(diskparams={ |
465 | 537dba0c | Raffa Santi | constants.DT_RBD: {constants.RBD_ACCESS: value} |
466 | 537dba0c | Raffa Santi | }) |
467 | 537dba0c | Raffa Santi | self.ExecOpCodeExpectOpPrereqError(op, "Invalid value of 'rbd:access'") |
468 | 537dba0c | Raffa Santi | |
469 | a794b8d7 | Thomas Thrainer | def testUnsetDrbdHelperWithDrbdDisks(self): |
470 | a794b8d7 | Thomas Thrainer | self.cfg.AddNewInstance(disks=[
|
471 | 0c5f1b13 | Thomas Thrainer | self.cfg.CreateDisk(dev_type=constants.DT_DRBD8, create_nodes=True)]) |
472 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(drbd_helper="")
|
473 | a794b8d7 | Thomas Thrainer | self.ExecOpCodeExpectOpPrereqError(op, "Cannot disable drbd helper") |
474 | a794b8d7 | Thomas Thrainer | |
475 | a794b8d7 | Thomas Thrainer | def testFileStorageDir(self): |
476 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(file_storage_dir="/random/path")
|
477 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
478 | a794b8d7 | Thomas Thrainer | |
479 | a794b8d7 | Thomas Thrainer | def testSetFileStorageDirToCurrentValue(self): |
480 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams( |
481 | a794b8d7 | Thomas Thrainer | file_storage_dir=self.cluster.file_storage_dir)
|
482 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
483 | a794b8d7 | Thomas Thrainer | |
484 | a794b8d7 | Thomas Thrainer | self.mcpu.assertLogContainsRegex("file storage dir already set to value") |
485 | a794b8d7 | Thomas Thrainer | |
486 | 70e8dd0a | Helga Velroyen | def testUnsetFileStorageDirFileStorageEnabled(self): |
487 | 70e8dd0a | Helga Velroyen | self.cfg.SetEnabledDiskTemplates([constants.DT_FILE])
|
488 | 70e8dd0a | Helga Velroyen | op = opcodes.OpClusterSetParams(file_storage_dir='')
|
489 | 70e8dd0a | Helga Velroyen | self.ExecOpCodeExpectOpPrereqError(op, "Unsetting the 'file' storage") |
490 | 70e8dd0a | Helga Velroyen | |
491 | 70e8dd0a | Helga Velroyen | def testUnsetFileStorageDirFileStorageDisabled(self): |
492 | 70e8dd0a | Helga Velroyen | self.cfg.SetEnabledDiskTemplates([constants.DT_PLAIN])
|
493 | 70e8dd0a | Helga Velroyen | op = opcodes.OpClusterSetParams(file_storage_dir='')
|
494 | 70e8dd0a | Helga Velroyen | self.ExecOpCode(op)
|
495 | 70e8dd0a | Helga Velroyen | |
496 | 70e8dd0a | Helga Velroyen | def testSetFileStorageDirFileStorageDisabled(self): |
497 | 70e8dd0a | Helga Velroyen | self.cfg.SetEnabledDiskTemplates([constants.DT_PLAIN])
|
498 | 70e8dd0a | Helga Velroyen | op = opcodes.OpClusterSetParams(file_storage_dir='/some/path/')
|
499 | 70e8dd0a | Helga Velroyen | self.ExecOpCode(op)
|
500 | 70e8dd0a | Helga Velroyen | self.mcpu.assertLogContainsRegex("although file storage is not enabled") |
501 | 70e8dd0a | Helga Velroyen | |
502 | a794b8d7 | Thomas Thrainer | def testValidDrbdHelper(self): |
503 | a794b8d7 | Thomas Thrainer | node1 = self.cfg.AddNewNode()
|
504 | a794b8d7 | Thomas Thrainer | node1.offline = True
|
505 | a794b8d7 | Thomas Thrainer | self.rpc.call_drbd_helper.return_value = \
|
506 | a794b8d7 | Thomas Thrainer | self.RpcResultsBuilder() \
|
507 | a794b8d7 | Thomas Thrainer | .AddSuccessfulNode(self.master, "/bin/true") \ |
508 | a794b8d7 | Thomas Thrainer | .AddOfflineNode(node1) \ |
509 | a794b8d7 | Thomas Thrainer | .Build() |
510 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(drbd_helper="/bin/true")
|
511 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
512 | a794b8d7 | Thomas Thrainer | self.mcpu.assertLogContainsRegex("Not checking drbd helper on offline node") |
513 | a794b8d7 | Thomas Thrainer | |
514 | a794b8d7 | Thomas Thrainer | def testDrbdHelperFailingNode(self): |
515 | a794b8d7 | Thomas Thrainer | self.rpc.call_drbd_helper.return_value = \
|
516 | a794b8d7 | Thomas Thrainer | self.RpcResultsBuilder() \
|
517 | a794b8d7 | Thomas Thrainer | .AddFailedNode(self.master) \
|
518 | a794b8d7 | Thomas Thrainer | .Build() |
519 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(drbd_helper="/bin/true")
|
520 | a794b8d7 | Thomas Thrainer | self.ExecOpCodeExpectOpPrereqError(op, "Error checking drbd helper") |
521 | a794b8d7 | Thomas Thrainer | |
522 | a794b8d7 | Thomas Thrainer | def testInvalidDrbdHelper(self): |
523 | a794b8d7 | Thomas Thrainer | self.rpc.call_drbd_helper.return_value = \
|
524 | a794b8d7 | Thomas Thrainer | self.RpcResultsBuilder() \
|
525 | a794b8d7 | Thomas Thrainer | .AddSuccessfulNode(self.master, "/bin/false") \ |
526 | a794b8d7 | Thomas Thrainer | .Build() |
527 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(drbd_helper="/bin/true")
|
528 | a794b8d7 | Thomas Thrainer | self.ExecOpCodeExpectOpPrereqError(op, "drbd helper is /bin/false") |
529 | a794b8d7 | Thomas Thrainer | |
530 | a794b8d7 | Thomas Thrainer | def testDrbdHelperWithoutDrbdDiskTemplate(self): |
531 | a794b8d7 | Thomas Thrainer | drbd_helper = "/bin/random_helper"
|
532 | 1583d0e4 | Thomas Thrainer | self.cfg.SetEnabledDiskTemplates([constants.DT_DISKLESS])
|
533 | a794b8d7 | Thomas Thrainer | self.rpc.call_drbd_helper.return_value = \
|
534 | a794b8d7 | Thomas Thrainer | self.RpcResultsBuilder() \
|
535 | a794b8d7 | Thomas Thrainer | .AddSuccessfulNode(self.master, drbd_helper) \
|
536 | a794b8d7 | Thomas Thrainer | .Build() |
537 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(drbd_helper=drbd_helper) |
538 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
539 | a794b8d7 | Thomas Thrainer | |
540 | a794b8d7 | Thomas Thrainer | self.mcpu.assertLogContainsRegex("but did not enable") |
541 | a794b8d7 | Thomas Thrainer | |
542 | 31ccfc0e | Helga Velroyen | def testResetDrbdHelperDrbdDisabled(self): |
543 | a794b8d7 | Thomas Thrainer | drbd_helper = ""
|
544 | 1583d0e4 | Thomas Thrainer | self.cfg.SetEnabledDiskTemplates([constants.DT_DISKLESS])
|
545 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(drbd_helper=drbd_helper) |
546 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
547 | a794b8d7 | Thomas Thrainer | |
548 | a794b8d7 | Thomas Thrainer | self.assertEqual(None, self.cluster.drbd_usermode_helper) |
549 | a794b8d7 | Thomas Thrainer | |
550 | 31ccfc0e | Helga Velroyen | def testResetDrbdHelperDrbdEnabled(self): |
551 | 31ccfc0e | Helga Velroyen | drbd_helper = ""
|
552 | 31ccfc0e | Helga Velroyen | self.cluster.enabled_disk_templates = [constants.DT_DRBD8]
|
553 | 31ccfc0e | Helga Velroyen | op = opcodes.OpClusterSetParams(drbd_helper=drbd_helper) |
554 | 31ccfc0e | Helga Velroyen | self.ExecOpCodeExpectOpPrereqError(
|
555 | 31ccfc0e | Helga Velroyen | op, "Cannot disable drbd helper while DRBD is enabled.")
|
556 | 31ccfc0e | Helga Velroyen | |
557 | 31ccfc0e | Helga Velroyen | def testEnableDrbdNoHelper(self): |
558 | 31ccfc0e | Helga Velroyen | self.cluster.enabled_disk_templates = [constants.DT_DISKLESS]
|
559 | 31ccfc0e | Helga Velroyen | self.cluster.drbd_usermode_helper = None |
560 | 31ccfc0e | Helga Velroyen | enabled_disk_templates = [constants.DT_DRBD8] |
561 | 31ccfc0e | Helga Velroyen | op = opcodes.OpClusterSetParams( |
562 | 31ccfc0e | Helga Velroyen | enabled_disk_templates=enabled_disk_templates) |
563 | 31ccfc0e | Helga Velroyen | self.ExecOpCodeExpectOpPrereqError(
|
564 | 31ccfc0e | Helga Velroyen | op, "Cannot enable DRBD without a DRBD usermode helper set")
|
565 | 31ccfc0e | Helga Velroyen | |
566 | 31ccfc0e | Helga Velroyen | def testEnableDrbdHelperSet(self): |
567 | 31ccfc0e | Helga Velroyen | drbd_helper = "/bin/random_helper"
|
568 | 31ccfc0e | Helga Velroyen | self.rpc.call_drbd_helper.return_value = \
|
569 | 31ccfc0e | Helga Velroyen | self.RpcResultsBuilder() \
|
570 | 31ccfc0e | Helga Velroyen | .AddSuccessfulNode(self.master, drbd_helper) \
|
571 | 31ccfc0e | Helga Velroyen | .Build() |
572 | 31ccfc0e | Helga Velroyen | self.cfg.SetEnabledDiskTemplates([constants.DT_DISKLESS])
|
573 | 31ccfc0e | Helga Velroyen | self.cluster.drbd_usermode_helper = drbd_helper
|
574 | 31ccfc0e | Helga Velroyen | enabled_disk_templates = [constants.DT_DRBD8] |
575 | 31ccfc0e | Helga Velroyen | op = opcodes.OpClusterSetParams( |
576 | 31ccfc0e | Helga Velroyen | enabled_disk_templates=enabled_disk_templates, |
577 | 31ccfc0e | Helga Velroyen | ipolicy={constants.IPOLICY_DTS: enabled_disk_templates}) |
578 | 31ccfc0e | Helga Velroyen | self.ExecOpCode(op)
|
579 | 31ccfc0e | Helga Velroyen | |
580 | 31ccfc0e | Helga Velroyen | self.assertEqual(drbd_helper, self.cluster.drbd_usermode_helper) |
581 | 31ccfc0e | Helga Velroyen | |
582 | 7c577910 | Helga Velroyen | def testDrbdHelperAlreadySet(self): |
583 | 7c577910 | Helga Velroyen | drbd_helper = "/bin/true"
|
584 | 7c577910 | Helga Velroyen | self.rpc.call_drbd_helper.return_value = \
|
585 | 7c577910 | Helga Velroyen | self.RpcResultsBuilder() \
|
586 | 7c577910 | Helga Velroyen | .AddSuccessfulNode(self.master, "/bin/true") \ |
587 | 7c577910 | Helga Velroyen | .Build() |
588 | 31ccfc0e | Helga Velroyen | self.cfg.SetEnabledDiskTemplates([constants.DT_DISKLESS])
|
589 | 7c577910 | Helga Velroyen | op = opcodes.OpClusterSetParams(drbd_helper=drbd_helper) |
590 | 7c577910 | Helga Velroyen | self.ExecOpCode(op)
|
591 | 7c577910 | Helga Velroyen | |
592 | 7c577910 | Helga Velroyen | self.assertEqual(drbd_helper, self.cluster.drbd_usermode_helper) |
593 | 7c577910 | Helga Velroyen | self.mcpu.assertLogContainsRegex("DRBD helper already in desired state") |
594 | 7c577910 | Helga Velroyen | |
595 | 7c577910 | Helga Velroyen | def testSetDrbdHelper(self): |
596 | 7c577910 | Helga Velroyen | drbd_helper = "/bin/true"
|
597 | 7c577910 | Helga Velroyen | self.rpc.call_drbd_helper.return_value = \
|
598 | 7c577910 | Helga Velroyen | self.RpcResultsBuilder() \
|
599 | 7c577910 | Helga Velroyen | .AddSuccessfulNode(self.master, "/bin/true") \ |
600 | 7c577910 | Helga Velroyen | .Build() |
601 | 7c577910 | Helga Velroyen | self.cluster.drbd_usermode_helper = "/bin/false" |
602 | 31ccfc0e | Helga Velroyen | self.cfg.SetEnabledDiskTemplates([constants.DT_DRBD8])
|
603 | 7c577910 | Helga Velroyen | op = opcodes.OpClusterSetParams(drbd_helper=drbd_helper) |
604 | 7c577910 | Helga Velroyen | self.ExecOpCode(op)
|
605 | 7c577910 | Helga Velroyen | |
606 | 7c577910 | Helga Velroyen | self.assertEqual(drbd_helper, self.cluster.drbd_usermode_helper) |
607 | 7c577910 | Helga Velroyen | |
608 | a794b8d7 | Thomas Thrainer | def testBeparams(self): |
609 | a794b8d7 | Thomas Thrainer | beparams = {constants.BE_VCPUS: 32}
|
610 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(beparams=beparams) |
611 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
612 | a794b8d7 | Thomas Thrainer | self.assertEqual(32, self.cluster |
613 | a794b8d7 | Thomas Thrainer | .beparams[constants.PP_DEFAULT][constants.BE_VCPUS]) |
614 | a794b8d7 | Thomas Thrainer | |
615 | a794b8d7 | Thomas Thrainer | def testNdparams(self): |
616 | a794b8d7 | Thomas Thrainer | ndparams = {constants.ND_EXCLUSIVE_STORAGE: True}
|
617 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(ndparams=ndparams) |
618 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
619 | a794b8d7 | Thomas Thrainer | self.assertEqual(True, self.cluster |
620 | a794b8d7 | Thomas Thrainer | .ndparams[constants.ND_EXCLUSIVE_STORAGE]) |
621 | a794b8d7 | Thomas Thrainer | |
622 | a794b8d7 | Thomas Thrainer | def testNdparamsResetOobProgram(self): |
623 | a794b8d7 | Thomas Thrainer | ndparams = {constants.ND_OOB_PROGRAM: ""}
|
624 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(ndparams=ndparams) |
625 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
626 | a794b8d7 | Thomas Thrainer | self.assertEqual(constants.NDC_DEFAULTS[constants.ND_OOB_PROGRAM],
|
627 | a794b8d7 | Thomas Thrainer | self.cluster.ndparams[constants.ND_OOB_PROGRAM])
|
628 | a794b8d7 | Thomas Thrainer | |
629 | a794b8d7 | Thomas Thrainer | def testHvState(self): |
630 | a794b8d7 | Thomas Thrainer | hv_state = {constants.HT_FAKE: {constants.HVST_CPU_TOTAL: 8}}
|
631 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(hv_state=hv_state) |
632 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
633 | a794b8d7 | Thomas Thrainer | self.assertEqual(8, self.cluster.hv_state_static |
634 | a794b8d7 | Thomas Thrainer | [constants.HT_FAKE][constants.HVST_CPU_TOTAL]) |
635 | a794b8d7 | Thomas Thrainer | |
636 | a794b8d7 | Thomas Thrainer | def testDiskState(self): |
637 | a794b8d7 | Thomas Thrainer | disk_state = { |
638 | 0c5f1b13 | Thomas Thrainer | constants.DT_PLAIN: { |
639 | a794b8d7 | Thomas Thrainer | "mock_vg": {constants.DS_DISK_TOTAL: 10} |
640 | a794b8d7 | Thomas Thrainer | } |
641 | a794b8d7 | Thomas Thrainer | } |
642 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(disk_state=disk_state) |
643 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
644 | a794b8d7 | Thomas Thrainer | self.assertEqual(10, self.cluster |
645 | 0c5f1b13 | Thomas Thrainer | .disk_state_static[constants.DT_PLAIN]["mock_vg"]
|
646 | a794b8d7 | Thomas Thrainer | [constants.DS_DISK_TOTAL]) |
647 | a794b8d7 | Thomas Thrainer | |
648 | a794b8d7 | Thomas Thrainer | def testDefaultIPolicy(self): |
649 | a794b8d7 | Thomas Thrainer | ipolicy = constants.IPOLICY_DEFAULTS |
650 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(ipolicy=ipolicy) |
651 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
652 | a794b8d7 | Thomas Thrainer | |
653 | a794b8d7 | Thomas Thrainer | def testIPolicyNewViolation(self): |
654 | a794b8d7 | Thomas Thrainer | import ganeti.constants as C |
655 | a794b8d7 | Thomas Thrainer | ipolicy = C.IPOLICY_DEFAULTS |
656 | a794b8d7 | Thomas Thrainer | ipolicy[C.ISPECS_MINMAX][0][C.ISPECS_MIN][C.ISPEC_MEM_SIZE] = 128 |
657 | a794b8d7 | Thomas Thrainer | ipolicy[C.ISPECS_MINMAX][0][C.ISPECS_MAX][C.ISPEC_MEM_SIZE] = 128 |
658 | a794b8d7 | Thomas Thrainer | |
659 | a794b8d7 | Thomas Thrainer | self.cfg.AddNewInstance(beparams={C.BE_MINMEM: 512, C.BE_MAXMEM: 512}) |
660 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(ipolicy=ipolicy) |
661 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
662 | a794b8d7 | Thomas Thrainer | |
663 | a794b8d7 | Thomas Thrainer | self.mcpu.assertLogContainsRegex("instances violate them") |
664 | a794b8d7 | Thomas Thrainer | |
665 | a794b8d7 | Thomas Thrainer | def testNicparamsNoInstance(self): |
666 | a794b8d7 | Thomas Thrainer | nicparams = { |
667 | a794b8d7 | Thomas Thrainer | constants.NIC_LINK: "mock_bridge"
|
668 | a794b8d7 | Thomas Thrainer | } |
669 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(nicparams=nicparams) |
670 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
671 | a794b8d7 | Thomas Thrainer | |
672 | a794b8d7 | Thomas Thrainer | self.assertEqual("mock_bridge", |
673 | a794b8d7 | Thomas Thrainer | self.cluster.nicparams
|
674 | a794b8d7 | Thomas Thrainer | [constants.PP_DEFAULT][constants.NIC_LINK]) |
675 | a794b8d7 | Thomas Thrainer | |
676 | a794b8d7 | Thomas Thrainer | def testNicparamsInvalidConf(self): |
677 | a794b8d7 | Thomas Thrainer | nicparams = { |
678 | 850be460 | Thomas Thrainer | constants.NIC_MODE: constants.NIC_MODE_BRIDGED, |
679 | 850be460 | Thomas Thrainer | constants.NIC_LINK: ""
|
680 | a794b8d7 | Thomas Thrainer | } |
681 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(nicparams=nicparams) |
682 | a794b8d7 | Thomas Thrainer | self.ExecOpCodeExpectException(op, errors.ConfigurationError, "NIC link") |
683 | a794b8d7 | Thomas Thrainer | |
684 | a794b8d7 | Thomas Thrainer | def testNicparamsInvalidInstanceConf(self): |
685 | a794b8d7 | Thomas Thrainer | nicparams = { |
686 | a794b8d7 | Thomas Thrainer | constants.NIC_MODE: constants.NIC_MODE_BRIDGED, |
687 | a794b8d7 | Thomas Thrainer | constants.NIC_LINK: "mock_bridge"
|
688 | a794b8d7 | Thomas Thrainer | } |
689 | a794b8d7 | Thomas Thrainer | self.cfg.AddNewInstance(nics=[
|
690 | a794b8d7 | Thomas Thrainer | self.cfg.CreateNic(nicparams={constants.NIC_LINK: None})]) |
691 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(nicparams=nicparams) |
692 | a794b8d7 | Thomas Thrainer | self.ExecOpCodeExpectOpPrereqError(op, "Missing bridged NIC link") |
693 | a794b8d7 | Thomas Thrainer | |
694 | a794b8d7 | Thomas Thrainer | def testNicparamsMissingIp(self): |
695 | a794b8d7 | Thomas Thrainer | nicparams = { |
696 | a794b8d7 | Thomas Thrainer | constants.NIC_MODE: constants.NIC_MODE_ROUTED |
697 | a794b8d7 | Thomas Thrainer | } |
698 | a794b8d7 | Thomas Thrainer | self.cfg.AddNewInstance()
|
699 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(nicparams=nicparams) |
700 | a794b8d7 | Thomas Thrainer | self.ExecOpCodeExpectOpPrereqError(op, "routed NIC with no ip address") |
701 | a794b8d7 | Thomas Thrainer | |
702 | a794b8d7 | Thomas Thrainer | def testNicparamsWithInstance(self): |
703 | a794b8d7 | Thomas Thrainer | nicparams = { |
704 | a794b8d7 | Thomas Thrainer | constants.NIC_LINK: "mock_bridge"
|
705 | a794b8d7 | Thomas Thrainer | } |
706 | a794b8d7 | Thomas Thrainer | self.cfg.AddNewInstance()
|
707 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(nicparams=nicparams) |
708 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
709 | a794b8d7 | Thomas Thrainer | |
710 | a794b8d7 | Thomas Thrainer | def testDefaultHvparams(self): |
711 | a794b8d7 | Thomas Thrainer | hvparams = constants.HVC_DEFAULTS |
712 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(hvparams=hvparams) |
713 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
714 | a794b8d7 | Thomas Thrainer | |
715 | a794b8d7 | Thomas Thrainer | self.assertEqual(hvparams, self.cluster.hvparams) |
716 | a794b8d7 | Thomas Thrainer | |
717 | a794b8d7 | Thomas Thrainer | def testMinimalHvparams(self): |
718 | a794b8d7 | Thomas Thrainer | hvparams = { |
719 | a794b8d7 | Thomas Thrainer | constants.HT_FAKE: { |
720 | a794b8d7 | Thomas Thrainer | constants.HV_MIGRATION_MODE: constants.HT_MIGRATION_NONLIVE |
721 | a794b8d7 | Thomas Thrainer | } |
722 | a794b8d7 | Thomas Thrainer | } |
723 | a794b8d7 | Thomas Thrainer | self.cluster.hvparams = {}
|
724 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(hvparams=hvparams) |
725 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
726 | a794b8d7 | Thomas Thrainer | |
727 | a794b8d7 | Thomas Thrainer | self.assertEqual(hvparams, self.cluster.hvparams) |
728 | a794b8d7 | Thomas Thrainer | |
729 | a794b8d7 | Thomas Thrainer | def testOsHvp(self): |
730 | a794b8d7 | Thomas Thrainer | os_hvp = { |
731 | a794b8d7 | Thomas Thrainer | "mocked_os": {
|
732 | a794b8d7 | Thomas Thrainer | constants.HT_FAKE: { |
733 | a794b8d7 | Thomas Thrainer | constants.HV_MIGRATION_MODE: constants.HT_MIGRATION_NONLIVE |
734 | a794b8d7 | Thomas Thrainer | } |
735 | a794b8d7 | Thomas Thrainer | }, |
736 | a794b8d7 | Thomas Thrainer | "other_os": constants.HVC_DEFAULTS
|
737 | a794b8d7 | Thomas Thrainer | } |
738 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(os_hvp=os_hvp) |
739 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
740 | a794b8d7 | Thomas Thrainer | |
741 | a794b8d7 | Thomas Thrainer | self.assertEqual(constants.HT_MIGRATION_NONLIVE,
|
742 | a794b8d7 | Thomas Thrainer | self.cluster.os_hvp["mocked_os"][constants.HT_FAKE] |
743 | a794b8d7 | Thomas Thrainer | [constants.HV_MIGRATION_MODE]) |
744 | a794b8d7 | Thomas Thrainer | self.assertEqual(constants.HVC_DEFAULTS, self.cluster.os_hvp["other_os"]) |
745 | a794b8d7 | Thomas Thrainer | |
746 | a794b8d7 | Thomas Thrainer | def testRemoveOsHvp(self): |
747 | a794b8d7 | Thomas Thrainer | os_hvp = {"mocked_os": {constants.HT_FAKE: None}} |
748 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(os_hvp=os_hvp) |
749 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
750 | a794b8d7 | Thomas Thrainer | |
751 | a794b8d7 | Thomas Thrainer | assert constants.HT_FAKE not in self.cluster.os_hvp["mocked_os"] |
752 | a794b8d7 | Thomas Thrainer | |
753 | a794b8d7 | Thomas Thrainer | def testDefaultOsHvp(self): |
754 | a794b8d7 | Thomas Thrainer | os_hvp = {"mocked_os": constants.HVC_DEFAULTS.copy()}
|
755 | a794b8d7 | Thomas Thrainer | self.cluster.os_hvp = {"mocked_os": {}} |
756 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(os_hvp=os_hvp) |
757 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
758 | a794b8d7 | Thomas Thrainer | |
759 | a794b8d7 | Thomas Thrainer | self.assertEqual(os_hvp, self.cluster.os_hvp) |
760 | a794b8d7 | Thomas Thrainer | |
761 | a794b8d7 | Thomas Thrainer | def testOsparams(self): |
762 | a794b8d7 | Thomas Thrainer | osparams = { |
763 | a794b8d7 | Thomas Thrainer | "mocked_os": {
|
764 | a794b8d7 | Thomas Thrainer | "param1": "value1", |
765 | a794b8d7 | Thomas Thrainer | "param2": None |
766 | a794b8d7 | Thomas Thrainer | }, |
767 | a794b8d7 | Thomas Thrainer | "other_os": {
|
768 | a794b8d7 | Thomas Thrainer | "param1": None |
769 | a794b8d7 | Thomas Thrainer | } |
770 | a794b8d7 | Thomas Thrainer | } |
771 | a794b8d7 | Thomas Thrainer | self.cluster.osparams = {"other_os": {"param1": "value1"}} |
772 | 07e3c124 | Santi Raffa | self.cluster.osparams_private_cluster = {}
|
773 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(osparams=osparams) |
774 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
775 | a794b8d7 | Thomas Thrainer | |
776 | a794b8d7 | Thomas Thrainer | self.assertEqual({"mocked_os": {"param1": "value1"}}, self.cluster.osparams) |
777 | a794b8d7 | Thomas Thrainer | |
778 | a794b8d7 | Thomas Thrainer | def testEnabledHypervisors(self): |
779 | a794b8d7 | Thomas Thrainer | enabled_hypervisors = [constants.HT_XEN_HVM, constants.HT_XEN_PVM] |
780 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(enabled_hypervisors=enabled_hypervisors) |
781 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
782 | a794b8d7 | Thomas Thrainer | |
783 | a794b8d7 | Thomas Thrainer | self.assertEqual(enabled_hypervisors, self.cluster.enabled_hypervisors) |
784 | a794b8d7 | Thomas Thrainer | |
785 | a794b8d7 | Thomas Thrainer | def testEnabledHypervisorsWithoutHypervisorParams(self): |
786 | a794b8d7 | Thomas Thrainer | enabled_hypervisors = [constants.HT_FAKE] |
787 | a794b8d7 | Thomas Thrainer | self.cluster.hvparams = {}
|
788 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(enabled_hypervisors=enabled_hypervisors) |
789 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
790 | a794b8d7 | Thomas Thrainer | |
791 | a794b8d7 | Thomas Thrainer | self.assertEqual(enabled_hypervisors, self.cluster.enabled_hypervisors) |
792 | a794b8d7 | Thomas Thrainer | self.assertEqual(constants.HVC_DEFAULTS[constants.HT_FAKE],
|
793 | a794b8d7 | Thomas Thrainer | self.cluster.hvparams[constants.HT_FAKE])
|
794 | a794b8d7 | Thomas Thrainer | |
795 | a794b8d7 | Thomas Thrainer | @testutils.patch_object(utils, "FindFile") |
796 | a794b8d7 | Thomas Thrainer | def testValidDefaultIallocator(self, find_file_mock): |
797 | a794b8d7 | Thomas Thrainer | find_file_mock.return_value = "/random/path"
|
798 | a794b8d7 | Thomas Thrainer | default_iallocator = "/random/path"
|
799 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(default_iallocator=default_iallocator) |
800 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
801 | a794b8d7 | Thomas Thrainer | |
802 | a794b8d7 | Thomas Thrainer | self.assertEqual(default_iallocator, self.cluster.default_iallocator) |
803 | a794b8d7 | Thomas Thrainer | |
804 | a794b8d7 | Thomas Thrainer | @testutils.patch_object(utils, "FindFile") |
805 | a794b8d7 | Thomas Thrainer | def testInvalidDefaultIallocator(self, find_file_mock): |
806 | a794b8d7 | Thomas Thrainer | find_file_mock.return_value = None
|
807 | a794b8d7 | Thomas Thrainer | default_iallocator = "/random/path"
|
808 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(default_iallocator=default_iallocator) |
809 | a794b8d7 | Thomas Thrainer | self.ExecOpCodeExpectOpPrereqError(op, "Invalid default iallocator script") |
810 | a794b8d7 | Thomas Thrainer | |
811 | a794b8d7 | Thomas Thrainer | def testEnabledDiskTemplates(self): |
812 | a794b8d7 | Thomas Thrainer | enabled_disk_templates = [constants.DT_DISKLESS, constants.DT_PLAIN] |
813 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams( |
814 | 1583d0e4 | Thomas Thrainer | enabled_disk_templates=enabled_disk_templates, |
815 | 1583d0e4 | Thomas Thrainer | ipolicy={constants.IPOLICY_DTS: enabled_disk_templates}) |
816 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
817 | a794b8d7 | Thomas Thrainer | |
818 | a794b8d7 | Thomas Thrainer | self.assertEqual(enabled_disk_templates,
|
819 | a794b8d7 | Thomas Thrainer | self.cluster.enabled_disk_templates)
|
820 | a794b8d7 | Thomas Thrainer | |
821 | 5859dad6 | Helga Velroyen | def testEnabledDiskTemplatesVsIpolicy(self): |
822 | 5859dad6 | Helga Velroyen | enabled_disk_templates = [constants.DT_DISKLESS, constants.DT_PLAIN] |
823 | 5859dad6 | Helga Velroyen | op = opcodes.OpClusterSetParams( |
824 | 5859dad6 | Helga Velroyen | enabled_disk_templates=enabled_disk_templates, |
825 | 5859dad6 | Helga Velroyen | ipolicy={constants.IPOLICY_DTS: [constants.DT_FILE]}) |
826 | 5859dad6 | Helga Velroyen | self.ExecOpCodeExpectOpPrereqError(op, "but not enabled on the cluster") |
827 | 5859dad6 | Helga Velroyen | |
828 | 916c0e6f | Helga Velroyen | def testDisablingDiskTemplatesOfInstances(self): |
829 | 916c0e6f | Helga Velroyen | old_disk_templates = [constants.DT_DISKLESS, constants.DT_PLAIN] |
830 | 916c0e6f | Helga Velroyen | self.cfg.SetEnabledDiskTemplates(old_disk_templates)
|
831 | 916c0e6f | Helga Velroyen | self.cfg.AddNewInstance(
|
832 | 916c0e6f | Helga Velroyen | disks=[self.cfg.CreateDisk(dev_type=constants.DT_PLAIN)])
|
833 | 916c0e6f | Helga Velroyen | new_disk_templates = [constants.DT_DISKLESS, constants.DT_DRBD8] |
834 | 916c0e6f | Helga Velroyen | op = opcodes.OpClusterSetParams( |
835 | 916c0e6f | Helga Velroyen | enabled_disk_templates=new_disk_templates, |
836 | 916c0e6f | Helga Velroyen | ipolicy={constants.IPOLICY_DTS: new_disk_templates}) |
837 | 916c0e6f | Helga Velroyen | self.ExecOpCodeExpectOpPrereqError(op, "least one instance using it") |
838 | 916c0e6f | Helga Velroyen | |
839 | a794b8d7 | Thomas Thrainer | def testEnabledDiskTemplatesWithoutVgName(self): |
840 | a794b8d7 | Thomas Thrainer | enabled_disk_templates = [constants.DT_PLAIN] |
841 | a794b8d7 | Thomas Thrainer | self.cluster.volume_group_name = None |
842 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams( |
843 | a794b8d7 | Thomas Thrainer | enabled_disk_templates=enabled_disk_templates) |
844 | a794b8d7 | Thomas Thrainer | self.ExecOpCodeExpectOpPrereqError(op, "specify a volume group") |
845 | a794b8d7 | Thomas Thrainer | |
846 | a794b8d7 | Thomas Thrainer | def testDisableDiskTemplateWithExistingInstance(self): |
847 | a794b8d7 | Thomas Thrainer | enabled_disk_templates = [constants.DT_DISKLESS] |
848 | a794b8d7 | Thomas Thrainer | self.cfg.AddNewInstance(
|
849 | 0c5f1b13 | Thomas Thrainer | disks=[self.cfg.CreateDisk(dev_type=constants.DT_PLAIN)])
|
850 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams( |
851 | 1583d0e4 | Thomas Thrainer | enabled_disk_templates=enabled_disk_templates, |
852 | 1583d0e4 | Thomas Thrainer | ipolicy={constants.IPOLICY_DTS: enabled_disk_templates}) |
853 | a794b8d7 | Thomas Thrainer | self.ExecOpCodeExpectOpPrereqError(op, "Cannot disable disk template") |
854 | a794b8d7 | Thomas Thrainer | |
855 | a794b8d7 | Thomas Thrainer | def testVgNameNoLvmDiskTemplateEnabled(self): |
856 | a794b8d7 | Thomas Thrainer | vg_name = "test_vg"
|
857 | 1583d0e4 | Thomas Thrainer | self.cfg.SetEnabledDiskTemplates([constants.DT_DISKLESS])
|
858 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(vg_name=vg_name) |
859 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
860 | a794b8d7 | Thomas Thrainer | |
861 | a794b8d7 | Thomas Thrainer | self.assertEqual(vg_name, self.cluster.volume_group_name) |
862 | 1583d0e4 | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
863 | a794b8d7 | Thomas Thrainer | |
864 | a794b8d7 | Thomas Thrainer | def testUnsetVgNameWithLvmDiskTemplateEnabled(self): |
865 | a794b8d7 | Thomas Thrainer | vg_name = ""
|
866 | a794b8d7 | Thomas Thrainer | self.cluster.enabled_disk_templates = [constants.DT_PLAIN]
|
867 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(vg_name=vg_name) |
868 | a794b8d7 | Thomas Thrainer | self.ExecOpCodeExpectOpPrereqError(op, "Cannot unset volume group") |
869 | a794b8d7 | Thomas Thrainer | |
870 | a794b8d7 | Thomas Thrainer | def testUnsetVgNameWithLvmInstance(self): |
871 | a794b8d7 | Thomas Thrainer | vg_name = ""
|
872 | a794b8d7 | Thomas Thrainer | self.cfg.AddNewInstance(
|
873 | 0c5f1b13 | Thomas Thrainer | disks=[self.cfg.CreateDisk(dev_type=constants.DT_PLAIN)])
|
874 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(vg_name=vg_name) |
875 | 1583d0e4 | Thomas Thrainer | self.ExecOpCodeExpectOpPrereqError(op, "Cannot unset volume group") |
876 | a794b8d7 | Thomas Thrainer | |
877 | a794b8d7 | Thomas Thrainer | def testUnsetVgNameWithNoLvmDiskTemplateEnabled(self): |
878 | a794b8d7 | Thomas Thrainer | vg_name = ""
|
879 | 1583d0e4 | Thomas Thrainer | self.cfg.SetEnabledDiskTemplates([constants.DT_DISKLESS])
|
880 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(vg_name=vg_name) |
881 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
882 | a794b8d7 | Thomas Thrainer | |
883 | a794b8d7 | Thomas Thrainer | self.assertEqual(None, self.cluster.volume_group_name) |
884 | a794b8d7 | Thomas Thrainer | |
885 | a794b8d7 | Thomas Thrainer | def testVgNameToOldName(self): |
886 | a794b8d7 | Thomas Thrainer | vg_name = self.cluster.volume_group_name
|
887 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(vg_name=vg_name) |
888 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
889 | a794b8d7 | Thomas Thrainer | |
890 | a794b8d7 | Thomas Thrainer | self.mcpu.assertLogContainsRegex("already in desired state") |
891 | a794b8d7 | Thomas Thrainer | |
892 | a794b8d7 | Thomas Thrainer | def testVgNameWithFailingNode(self): |
893 | a794b8d7 | Thomas Thrainer | vg_name = "test_vg"
|
894 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(vg_name=vg_name) |
895 | a794b8d7 | Thomas Thrainer | self.rpc.call_vg_list.return_value = \
|
896 | a794b8d7 | Thomas Thrainer | self.RpcResultsBuilder() \
|
897 | a794b8d7 | Thomas Thrainer | .AddFailedNode(self.master) \
|
898 | a794b8d7 | Thomas Thrainer | .Build() |
899 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
900 | a794b8d7 | Thomas Thrainer | |
901 | a794b8d7 | Thomas Thrainer | self.mcpu.assertLogContainsRegex("Error while gathering data on node") |
902 | a794b8d7 | Thomas Thrainer | |
903 | a794b8d7 | Thomas Thrainer | def testVgNameWithValidNode(self): |
904 | a794b8d7 | Thomas Thrainer | vg_name = "test_vg"
|
905 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(vg_name=vg_name) |
906 | a794b8d7 | Thomas Thrainer | self.rpc.call_vg_list.return_value = \
|
907 | a794b8d7 | Thomas Thrainer | self.RpcResultsBuilder() \
|
908 | a794b8d7 | Thomas Thrainer | .AddSuccessfulNode(self.master, {vg_name: 1024 * 1024}) \ |
909 | a794b8d7 | Thomas Thrainer | .Build() |
910 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
911 | a794b8d7 | Thomas Thrainer | |
912 | a794b8d7 | Thomas Thrainer | def testVgNameWithTooSmallNode(self): |
913 | a794b8d7 | Thomas Thrainer | vg_name = "test_vg"
|
914 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(vg_name=vg_name) |
915 | a794b8d7 | Thomas Thrainer | self.rpc.call_vg_list.return_value = \
|
916 | a794b8d7 | Thomas Thrainer | self.RpcResultsBuilder() \
|
917 | a794b8d7 | Thomas Thrainer | .AddSuccessfulNode(self.master, {vg_name: 1}) \ |
918 | a794b8d7 | Thomas Thrainer | .Build() |
919 | a794b8d7 | Thomas Thrainer | self.ExecOpCodeExpectOpPrereqError(op, "too small") |
920 | a794b8d7 | Thomas Thrainer | |
921 | a794b8d7 | Thomas Thrainer | def testMiscParameters(self): |
922 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(candidate_pool_size=123,
|
923 | a794b8d7 | Thomas Thrainer | maintain_node_health=True,
|
924 | a794b8d7 | Thomas Thrainer | modify_etc_hosts=True,
|
925 | a794b8d7 | Thomas Thrainer | prealloc_wipe_disks=True,
|
926 | a794b8d7 | Thomas Thrainer | reserved_lvs=["/dev/mock_lv"],
|
927 | a794b8d7 | Thomas Thrainer | use_external_mip_script=True)
|
928 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
929 | a794b8d7 | Thomas Thrainer | |
930 | a794b8d7 | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
931 | a794b8d7 | Thomas Thrainer | self.assertEqual(123, self.cluster.candidate_pool_size) |
932 | a794b8d7 | Thomas Thrainer | self.assertEqual(True, self.cluster.maintain_node_health) |
933 | a794b8d7 | Thomas Thrainer | self.assertEqual(True, self.cluster.modify_etc_hosts) |
934 | a794b8d7 | Thomas Thrainer | self.assertEqual(True, self.cluster.prealloc_wipe_disks) |
935 | a794b8d7 | Thomas Thrainer | self.assertEqual(["/dev/mock_lv"], self.cluster.reserved_lvs) |
936 | a794b8d7 | Thomas Thrainer | self.assertEqual(True, self.cluster.use_external_mip_script) |
937 | a794b8d7 | Thomas Thrainer | |
938 | a794b8d7 | Thomas Thrainer | def testAddHiddenOs(self): |
939 | a794b8d7 | Thomas Thrainer | self.cluster.hidden_os = ["hidden1", "hidden2"] |
940 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(hidden_os=[(constants.DDM_ADD, "hidden2"),
|
941 | a794b8d7 | Thomas Thrainer | (constants.DDM_ADD, "hidden3")])
|
942 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
943 | a794b8d7 | Thomas Thrainer | |
944 | a794b8d7 | Thomas Thrainer | self.assertEqual(["hidden1", "hidden2", "hidden3"], self.cluster.hidden_os) |
945 | a794b8d7 | Thomas Thrainer | self.mcpu.assertLogContainsRegex("OS hidden2 already") |
946 | a794b8d7 | Thomas Thrainer | |
947 | a794b8d7 | Thomas Thrainer | def testRemoveBlacklistedOs(self): |
948 | a794b8d7 | Thomas Thrainer | self.cluster.blacklisted_os = ["blisted1", "blisted2"] |
949 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(blacklisted_os=[ |
950 | a794b8d7 | Thomas Thrainer | (constants.DDM_REMOVE, "blisted2"),
|
951 | a794b8d7 | Thomas Thrainer | (constants.DDM_REMOVE, "blisted3")])
|
952 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
953 | a794b8d7 | Thomas Thrainer | |
954 | a794b8d7 | Thomas Thrainer | self.assertEqual(["blisted1"], self.cluster.blacklisted_os) |
955 | a794b8d7 | Thomas Thrainer | self.mcpu.assertLogContainsRegex("OS blisted3 not found") |
956 | a794b8d7 | Thomas Thrainer | |
957 | a794b8d7 | Thomas Thrainer | def testMasterNetdev(self): |
958 | a794b8d7 | Thomas Thrainer | master_netdev = "test_dev"
|
959 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(master_netdev=master_netdev) |
960 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
961 | a794b8d7 | Thomas Thrainer | |
962 | a794b8d7 | Thomas Thrainer | self.assertEqual(master_netdev, self.cluster.master_netdev) |
963 | a794b8d7 | Thomas Thrainer | |
964 | a794b8d7 | Thomas Thrainer | def testMasterNetdevFailNoForce(self): |
965 | a794b8d7 | Thomas Thrainer | master_netdev = "test_dev"
|
966 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(master_netdev=master_netdev) |
967 | a794b8d7 | Thomas Thrainer | self.rpc.call_node_deactivate_master_ip.return_value = \
|
968 | a794b8d7 | Thomas Thrainer | self.RpcResultsBuilder() \
|
969 | a794b8d7 | Thomas Thrainer | .CreateFailedNodeResult(self.master)
|
970 | a794b8d7 | Thomas Thrainer | self.ExecOpCodeExpectOpExecError(op, "Could not disable the master ip") |
971 | a794b8d7 | Thomas Thrainer | |
972 | a794b8d7 | Thomas Thrainer | def testMasterNetdevFailForce(self): |
973 | a794b8d7 | Thomas Thrainer | master_netdev = "test_dev"
|
974 | a794b8d7 | Thomas Thrainer | op = opcodes.OpClusterSetParams(master_netdev=master_netdev, |
975 | a794b8d7 | Thomas Thrainer | force=True)
|
976 | a794b8d7 | Thomas Thrainer | self.rpc.call_node_deactivate_master_ip.return_value = \
|
977 | a794b8d7 | Thomas Thrainer | self.RpcResultsBuilder() \
|
978 | a794b8d7 | Thomas Thrainer | .CreateFailedNodeResult(self.master)
|
979 | a794b8d7 | Thomas Thrainer | self.ExecOpCode(op)
|
980 | a794b8d7 | Thomas Thrainer | |
981 | a794b8d7 | Thomas Thrainer | self.mcpu.assertLogContainsRegex("Could not disable the master ip") |
982 | a794b8d7 | Thomas Thrainer | |
983 | a794b8d7 | Thomas Thrainer | |
984 | c60f7675 | Thomas Thrainer | class TestLUClusterVerify(CmdlibTestCase): |
985 | c60f7675 | Thomas Thrainer | def testVerifyAllGroups(self): |
986 | c60f7675 | Thomas Thrainer | op = opcodes.OpClusterVerify() |
987 | c60f7675 | Thomas Thrainer | result = self.ExecOpCode(op)
|
988 | c60f7675 | Thomas Thrainer | |
989 | c60f7675 | Thomas Thrainer | self.assertEqual(2, len(result["jobs"])) |
990 | c60f7675 | Thomas Thrainer | |
991 | c60f7675 | Thomas Thrainer | def testVerifyDefaultGroups(self): |
992 | c60f7675 | Thomas Thrainer | op = opcodes.OpClusterVerify(group_name="default")
|
993 | c60f7675 | Thomas Thrainer | result = self.ExecOpCode(op)
|
994 | c60f7675 | Thomas Thrainer | |
995 | c60f7675 | Thomas Thrainer | self.assertEqual(1, len(result["jobs"])) |
996 | c60f7675 | Thomas Thrainer | |
997 | 850be460 | Thomas Thrainer | |
998 | 850be460 | Thomas Thrainer | class TestLUClusterVerifyConfig(CmdlibTestCase): |
999 | 850be460 | Thomas Thrainer | |
1000 | 850be460 | Thomas Thrainer | def setUp(self): |
1001 | 850be460 | Thomas Thrainer | super(TestLUClusterVerifyConfig, self).setUp() |
1002 | 850be460 | Thomas Thrainer | |
1003 | 850be460 | Thomas Thrainer | self._load_cert_patcher = testutils \
|
1004 | 850be460 | Thomas Thrainer | .patch_object(OpenSSL.crypto, "load_certificate")
|
1005 | 850be460 | Thomas Thrainer | self._load_cert_mock = self._load_cert_patcher.start() |
1006 | 850be460 | Thomas Thrainer | self._verify_cert_patcher = testutils \
|
1007 | a6c43c02 | Helga Velroyen | .patch_object(utils, "VerifyCertificate")
|
1008 | 850be460 | Thomas Thrainer | self._verify_cert_mock = self._verify_cert_patcher.start() |
1009 | 850be460 | Thomas Thrainer | self._read_file_patcher = testutils.patch_object(utils, "ReadFile") |
1010 | 850be460 | Thomas Thrainer | self._read_file_mock = self._read_file_patcher.start() |
1011 | 850be460 | Thomas Thrainer | self._can_read_patcher = testutils.patch_object(utils, "CanRead") |
1012 | 850be460 | Thomas Thrainer | self._can_read_mock = self._can_read_patcher.start() |
1013 | 850be460 | Thomas Thrainer | |
1014 | 850be460 | Thomas Thrainer | self._can_read_mock.return_value = True |
1015 | 850be460 | Thomas Thrainer | self._read_file_mock.return_value = True |
1016 | 850be460 | Thomas Thrainer | self._verify_cert_mock.return_value = (None, "") |
1017 | 850be460 | Thomas Thrainer | self._load_cert_mock.return_value = True |
1018 | 850be460 | Thomas Thrainer | |
1019 | 850be460 | Thomas Thrainer | def tearDown(self): |
1020 | 850be460 | Thomas Thrainer | super(TestLUClusterVerifyConfig, self).tearDown() |
1021 | 850be460 | Thomas Thrainer | |
1022 | 850be460 | Thomas Thrainer | self._can_read_patcher.stop()
|
1023 | 850be460 | Thomas Thrainer | self._read_file_patcher.stop()
|
1024 | 850be460 | Thomas Thrainer | self._verify_cert_patcher.stop()
|
1025 | 850be460 | Thomas Thrainer | self._load_cert_patcher.stop()
|
1026 | 850be460 | Thomas Thrainer | |
1027 | 850be460 | Thomas Thrainer | def testSuccessfulRun(self): |
1028 | 850be460 | Thomas Thrainer | self.cfg.AddNewInstance()
|
1029 | 850be460 | Thomas Thrainer | op = opcodes.OpClusterVerifyConfig() |
1030 | 850be460 | Thomas Thrainer | result = self.ExecOpCode(op)
|
1031 | 850be460 | Thomas Thrainer | self.assertTrue(result)
|
1032 | 850be460 | Thomas Thrainer | |
1033 | 850be460 | Thomas Thrainer | def testDanglingNode(self): |
1034 | 850be460 | Thomas Thrainer | node = self.cfg.AddNewNode()
|
1035 | 850be460 | Thomas Thrainer | self.cfg.AddNewInstance(primary_node=node)
|
1036 | 850be460 | Thomas Thrainer | node.group = "invalid"
|
1037 | 850be460 | Thomas Thrainer | op = opcodes.OpClusterVerifyConfig() |
1038 | 850be460 | Thomas Thrainer | result = self.ExecOpCode(op)
|
1039 | 850be460 | Thomas Thrainer | |
1040 | 850be460 | Thomas Thrainer | self.mcpu.assertLogContainsRegex(
|
1041 | 850be460 | Thomas Thrainer | "following nodes \(and their instances\) belong to a non existing group")
|
1042 | 850be460 | Thomas Thrainer | self.assertFalse(result)
|
1043 | 850be460 | Thomas Thrainer | |
1044 | 850be460 | Thomas Thrainer | def testDanglingInstance(self): |
1045 | 850be460 | Thomas Thrainer | inst = self.cfg.AddNewInstance()
|
1046 | 850be460 | Thomas Thrainer | inst.primary_node = "invalid"
|
1047 | 850be460 | Thomas Thrainer | op = opcodes.OpClusterVerifyConfig() |
1048 | 850be460 | Thomas Thrainer | result = self.ExecOpCode(op)
|
1049 | 850be460 | Thomas Thrainer | |
1050 | 850be460 | Thomas Thrainer | self.mcpu.assertLogContainsRegex(
|
1051 | 850be460 | Thomas Thrainer | "following instances have a non-existing primary-node")
|
1052 | 850be460 | Thomas Thrainer | self.assertFalse(result)
|
1053 | 850be460 | Thomas Thrainer | |
1054 | 850be460 | Thomas Thrainer | |
1055 | b8f45292 | Thomas Thrainer | class TestLUClusterVerifyGroup(CmdlibTestCase): |
1056 | b8f45292 | Thomas Thrainer | def testEmptyNodeGroup(self): |
1057 | b8f45292 | Thomas Thrainer | group = self.cfg.AddNewNodeGroup()
|
1058 | 9fdb10be | Thomas Thrainer | op = opcodes.OpClusterVerifyGroup(group_name=group.name, verbose=True)
|
1059 | b8f45292 | Thomas Thrainer | |
1060 | b8f45292 | Thomas Thrainer | result = self.ExecOpCode(op)
|
1061 | b8f45292 | Thomas Thrainer | |
1062 | b8f45292 | Thomas Thrainer | self.assertTrue(result)
|
1063 | b8f45292 | Thomas Thrainer | self.mcpu.assertLogContainsRegex("Empty node group, skipping verification") |
1064 | b8f45292 | Thomas Thrainer | |
1065 | b8f45292 | Thomas Thrainer | def testSimpleInvocation(self): |
1066 | 9fdb10be | Thomas Thrainer | op = opcodes.OpClusterVerifyGroup(group_name="default", verbose=True) |
1067 | 9fdb10be | Thomas Thrainer | |
1068 | 9fdb10be | Thomas Thrainer | self.ExecOpCode(op)
|
1069 | 9fdb10be | Thomas Thrainer | |
1070 | 9fdb10be | Thomas Thrainer | def testSimpleInvocationWithInstance(self): |
1071 | 9fdb10be | Thomas Thrainer | self.cfg.AddNewInstance(disks=[])
|
1072 | 9fdb10be | Thomas Thrainer | op = opcodes.OpClusterVerifyGroup(group_name="default", verbose=True) |
1073 | 9fdb10be | Thomas Thrainer | |
1074 | 9fdb10be | Thomas Thrainer | self.ExecOpCode(op)
|
1075 | 9fdb10be | Thomas Thrainer | |
1076 | 9fdb10be | Thomas Thrainer | def testGhostNode(self): |
1077 | 9fdb10be | Thomas Thrainer | group = self.cfg.AddNewNodeGroup()
|
1078 | 9fdb10be | Thomas Thrainer | node = self.cfg.AddNewNode(group=group.uuid, offline=True) |
1079 | 9fdb10be | Thomas Thrainer | self.master.offline = True |
1080 | 9fdb10be | Thomas Thrainer | self.cfg.AddNewInstance(disk_template=constants.DT_DRBD8,
|
1081 | 9fdb10be | Thomas Thrainer | primary_node=self.master,
|
1082 | 9fdb10be | Thomas Thrainer | secondary_node=node) |
1083 | 9fdb10be | Thomas Thrainer | |
1084 | 9fdb10be | Thomas Thrainer | self.rpc.call_blockdev_getmirrorstatus_multi.return_value = \
|
1085 | 9fdb10be | Thomas Thrainer | RpcResultsBuilder() \ |
1086 | 9fdb10be | Thomas Thrainer | .AddOfflineNode(self.master) \
|
1087 | 9fdb10be | Thomas Thrainer | .Build() |
1088 | 9fdb10be | Thomas Thrainer | |
1089 | 9fdb10be | Thomas Thrainer | op = opcodes.OpClusterVerifyGroup(group_name="default", verbose=True) |
1090 | 9fdb10be | Thomas Thrainer | |
1091 | 9fdb10be | Thomas Thrainer | self.ExecOpCode(op)
|
1092 | 9fdb10be | Thomas Thrainer | |
1093 | 9fdb10be | Thomas Thrainer | def testValidRpcResult(self): |
1094 | 9fdb10be | Thomas Thrainer | self.cfg.AddNewInstance(disks=[])
|
1095 | 9fdb10be | Thomas Thrainer | |
1096 | 9fdb10be | Thomas Thrainer | self.rpc.call_node_verify.return_value = \
|
1097 | 9fdb10be | Thomas Thrainer | RpcResultsBuilder() \ |
1098 | 9fdb10be | Thomas Thrainer | .AddSuccessfulNode(self.master, {}) \
|
1099 | 9fdb10be | Thomas Thrainer | .Build() |
1100 | 9fdb10be | Thomas Thrainer | |
1101 | 9fdb10be | Thomas Thrainer | op = opcodes.OpClusterVerifyGroup(group_name="default", verbose=True) |
1102 | b8f45292 | Thomas Thrainer | |
1103 | b8f45292 | Thomas Thrainer | self.ExecOpCode(op)
|
1104 | b8f45292 | Thomas Thrainer | |
1105 | b8f45292 | Thomas Thrainer | |
1106 | d5104ca4 | Helga Velroyen | class TestLUClusterVerifyClientCerts(CmdlibTestCase): |
1107 | d5104ca4 | Helga Velroyen | |
1108 | d5104ca4 | Helga Velroyen | def _AddNormalNode(self): |
1109 | d5104ca4 | Helga Velroyen | self.normalnode = copy.deepcopy(self.master) |
1110 | d5104ca4 | Helga Velroyen | self.normalnode.master_candidate = False |
1111 | d5104ca4 | Helga Velroyen | self.normalnode.uuid = "normal-node-uuid" |
1112 | d5104ca4 | Helga Velroyen | self.cfg.AddNode(self.normalnode, None) |
1113 | d5104ca4 | Helga Velroyen | |
1114 | d5104ca4 | Helga Velroyen | def testVerifyMasterCandidate(self): |
1115 | d5104ca4 | Helga Velroyen | client_cert = "client-cert-digest"
|
1116 | d5104ca4 | Helga Velroyen | self.cluster.candidate_certs = {self.master.uuid: client_cert} |
1117 | d5104ca4 | Helga Velroyen | self.rpc.call_node_verify.return_value = \
|
1118 | d5104ca4 | Helga Velroyen | RpcResultsBuilder() \ |
1119 | d5104ca4 | Helga Velroyen | .AddSuccessfulNode(self.master,
|
1120 | d5104ca4 | Helga Velroyen | {constants.NV_CLIENT_CERT: (None, client_cert)}) \
|
1121 | d5104ca4 | Helga Velroyen | .Build() |
1122 | d5104ca4 | Helga Velroyen | op = opcodes.OpClusterVerifyGroup(group_name="default", verbose=True) |
1123 | d5104ca4 | Helga Velroyen | self.ExecOpCode(op)
|
1124 | d5104ca4 | Helga Velroyen | |
1125 | d5104ca4 | Helga Velroyen | def testVerifyMasterCandidateInvalid(self): |
1126 | d5104ca4 | Helga Velroyen | client_cert = "client-cert-digest"
|
1127 | d5104ca4 | Helga Velroyen | self.cluster.candidate_certs = {self.master.uuid: client_cert} |
1128 | d5104ca4 | Helga Velroyen | self.rpc.call_node_verify.return_value = \
|
1129 | d5104ca4 | Helga Velroyen | RpcResultsBuilder() \ |
1130 | d5104ca4 | Helga Velroyen | .AddSuccessfulNode(self.master,
|
1131 | d5104ca4 | Helga Velroyen | {constants.NV_CLIENT_CERT: (666, "Invalid Certificate")}) \ |
1132 | d5104ca4 | Helga Velroyen | .Build() |
1133 | d5104ca4 | Helga Velroyen | op = opcodes.OpClusterVerifyGroup(group_name="default", verbose=True) |
1134 | d5104ca4 | Helga Velroyen | self.ExecOpCode(op)
|
1135 | d5104ca4 | Helga Velroyen | self.mcpu.assertLogContainsRegex("Client certificate") |
1136 | d5104ca4 | Helga Velroyen | self.mcpu.assertLogContainsRegex("failed validation") |
1137 | d5104ca4 | Helga Velroyen | |
1138 | d5104ca4 | Helga Velroyen | def testVerifyNoMasterCandidateMap(self): |
1139 | d5104ca4 | Helga Velroyen | client_cert = "client-cert-digest"
|
1140 | d5104ca4 | Helga Velroyen | self.cluster.candidate_certs = {}
|
1141 | d5104ca4 | Helga Velroyen | self.rpc.call_node_verify.return_value = \
|
1142 | d5104ca4 | Helga Velroyen | RpcResultsBuilder() \ |
1143 | d5104ca4 | Helga Velroyen | .AddSuccessfulNode(self.master,
|
1144 | d5104ca4 | Helga Velroyen | {constants.NV_CLIENT_CERT: (None, client_cert)}) \
|
1145 | d5104ca4 | Helga Velroyen | .Build() |
1146 | d5104ca4 | Helga Velroyen | op = opcodes.OpClusterVerifyGroup(group_name="default", verbose=True) |
1147 | d5104ca4 | Helga Velroyen | self.ExecOpCode(op)
|
1148 | d5104ca4 | Helga Velroyen | self.mcpu.assertLogContainsRegex(
|
1149 | d5104ca4 | Helga Velroyen | "list of master candidate certificates is empty")
|
1150 | d5104ca4 | Helga Velroyen | |
1151 | d5104ca4 | Helga Velroyen | def testVerifyNoSharingMasterCandidates(self): |
1152 | d5104ca4 | Helga Velroyen | client_cert = "client-cert-digest"
|
1153 | d5104ca4 | Helga Velroyen | self.cluster.candidate_certs = {
|
1154 | d5104ca4 | Helga Velroyen | self.master.uuid: client_cert,
|
1155 | d5104ca4 | Helga Velroyen | "some-other-master-candidate-uuid": client_cert}
|
1156 | d5104ca4 | Helga Velroyen | self.rpc.call_node_verify.return_value = \
|
1157 | d5104ca4 | Helga Velroyen | RpcResultsBuilder() \ |
1158 | d5104ca4 | Helga Velroyen | .AddSuccessfulNode(self.master,
|
1159 | d5104ca4 | Helga Velroyen | {constants.NV_CLIENT_CERT: (None, client_cert)}) \
|
1160 | d5104ca4 | Helga Velroyen | .Build() |
1161 | d5104ca4 | Helga Velroyen | op = opcodes.OpClusterVerifyGroup(group_name="default", verbose=True) |
1162 | d5104ca4 | Helga Velroyen | self.ExecOpCode(op)
|
1163 | d5104ca4 | Helga Velroyen | self.mcpu.assertLogContainsRegex(
|
1164 | d5104ca4 | Helga Velroyen | "two master candidates configured to use the same")
|
1165 | d5104ca4 | Helga Velroyen | |
1166 | d5104ca4 | Helga Velroyen | def testVerifyMasterCandidateCertMismatch(self): |
1167 | d5104ca4 | Helga Velroyen | client_cert = "client-cert-digest"
|
1168 | d5104ca4 | Helga Velroyen | self.cluster.candidate_certs = {self.master.uuid: "different-cert-digest"} |
1169 | d5104ca4 | Helga Velroyen | self.rpc.call_node_verify.return_value = \
|
1170 | d5104ca4 | Helga Velroyen | RpcResultsBuilder() \ |
1171 | d5104ca4 | Helga Velroyen | .AddSuccessfulNode(self.master,
|
1172 | d5104ca4 | Helga Velroyen | {constants.NV_CLIENT_CERT: (None, client_cert)}) \
|
1173 | d5104ca4 | Helga Velroyen | .Build() |
1174 | d5104ca4 | Helga Velroyen | op = opcodes.OpClusterVerifyGroup(group_name="default", verbose=True) |
1175 | d5104ca4 | Helga Velroyen | self.ExecOpCode(op)
|
1176 | d5104ca4 | Helga Velroyen | self.mcpu.assertLogContainsRegex("does not match its entry") |
1177 | d5104ca4 | Helga Velroyen | |
1178 | d5104ca4 | Helga Velroyen | def testVerifyMasterCandidateUnregistered(self): |
1179 | d5104ca4 | Helga Velroyen | client_cert = "client-cert-digest"
|
1180 | d5104ca4 | Helga Velroyen | self.cluster.candidate_certs = {"other-node-uuid": "different-cert-digest"} |
1181 | d5104ca4 | Helga Velroyen | self.rpc.call_node_verify.return_value = \
|
1182 | d5104ca4 | Helga Velroyen | RpcResultsBuilder() \ |
1183 | d5104ca4 | Helga Velroyen | .AddSuccessfulNode(self.master,
|
1184 | d5104ca4 | Helga Velroyen | {constants.NV_CLIENT_CERT: (None, client_cert)}) \
|
1185 | d5104ca4 | Helga Velroyen | .Build() |
1186 | d5104ca4 | Helga Velroyen | op = opcodes.OpClusterVerifyGroup(group_name="default", verbose=True) |
1187 | d5104ca4 | Helga Velroyen | self.ExecOpCode(op)
|
1188 | d5104ca4 | Helga Velroyen | self.mcpu.assertLogContainsRegex("does not have an entry") |
1189 | d5104ca4 | Helga Velroyen | |
1190 | d5104ca4 | Helga Velroyen | def testVerifyMasterCandidateOtherNodesCert(self): |
1191 | d5104ca4 | Helga Velroyen | client_cert = "client-cert-digest"
|
1192 | d5104ca4 | Helga Velroyen | self.cluster.candidate_certs = {"other-node-uuid": client_cert} |
1193 | d5104ca4 | Helga Velroyen | self.rpc.call_node_verify.return_value = \
|
1194 | d5104ca4 | Helga Velroyen | RpcResultsBuilder() \ |
1195 | d5104ca4 | Helga Velroyen | .AddSuccessfulNode(self.master,
|
1196 | d5104ca4 | Helga Velroyen | {constants.NV_CLIENT_CERT: (None, client_cert)}) \
|
1197 | d5104ca4 | Helga Velroyen | .Build() |
1198 | d5104ca4 | Helga Velroyen | op = opcodes.OpClusterVerifyGroup(group_name="default", verbose=True) |
1199 | d5104ca4 | Helga Velroyen | self.ExecOpCode(op)
|
1200 | d5104ca4 | Helga Velroyen | self.mcpu.assertLogContainsRegex("using a certificate of another node") |
1201 | d5104ca4 | Helga Velroyen | |
1202 | d5104ca4 | Helga Velroyen | def testNormalNodeStillInList(self): |
1203 | d5104ca4 | Helga Velroyen | self._AddNormalNode()
|
1204 | d5104ca4 | Helga Velroyen | client_cert_master = "client-cert-digest-master"
|
1205 | d5104ca4 | Helga Velroyen | client_cert_normal = "client-cert-digest-normal"
|
1206 | d5104ca4 | Helga Velroyen | self.cluster.candidate_certs = {
|
1207 | d5104ca4 | Helga Velroyen | self.normalnode.uuid: client_cert_normal,
|
1208 | d5104ca4 | Helga Velroyen | self.master.uuid: client_cert_master}
|
1209 | d5104ca4 | Helga Velroyen | self.rpc.call_node_verify.return_value = \
|
1210 | d5104ca4 | Helga Velroyen | RpcResultsBuilder() \ |
1211 | d5104ca4 | Helga Velroyen | .AddSuccessfulNode(self.normalnode,
|
1212 | d5104ca4 | Helga Velroyen | {constants.NV_CLIENT_CERT: (None, client_cert_normal)}) \
|
1213 | d5104ca4 | Helga Velroyen | .AddSuccessfulNode(self.master,
|
1214 | d5104ca4 | Helga Velroyen | {constants.NV_CLIENT_CERT: (None, client_cert_master)}) \
|
1215 | d5104ca4 | Helga Velroyen | .Build() |
1216 | d5104ca4 | Helga Velroyen | op = opcodes.OpClusterVerifyGroup(group_name="default", verbose=True) |
1217 | d5104ca4 | Helga Velroyen | self.ExecOpCode(op)
|
1218 | d5104ca4 | Helga Velroyen | self.mcpu.assertLogContainsRegex("not a master candidate") |
1219 | d5104ca4 | Helga Velroyen | self.mcpu.assertLogContainsRegex("still listed") |
1220 | d5104ca4 | Helga Velroyen | |
1221 | d5104ca4 | Helga Velroyen | def testNormalNodeStealingMasterCandidateCert(self): |
1222 | d5104ca4 | Helga Velroyen | self._AddNormalNode()
|
1223 | d5104ca4 | Helga Velroyen | client_cert_master = "client-cert-digest-master"
|
1224 | d5104ca4 | Helga Velroyen | self.cluster.candidate_certs = {
|
1225 | d5104ca4 | Helga Velroyen | self.master.uuid: client_cert_master}
|
1226 | d5104ca4 | Helga Velroyen | self.rpc.call_node_verify.return_value = \
|
1227 | d5104ca4 | Helga Velroyen | RpcResultsBuilder() \ |
1228 | d5104ca4 | Helga Velroyen | .AddSuccessfulNode(self.normalnode,
|
1229 | d5104ca4 | Helga Velroyen | {constants.NV_CLIENT_CERT: (None, client_cert_master)}) \
|
1230 | d5104ca4 | Helga Velroyen | .AddSuccessfulNode(self.master,
|
1231 | d5104ca4 | Helga Velroyen | {constants.NV_CLIENT_CERT: (None, client_cert_master)}) \
|
1232 | d5104ca4 | Helga Velroyen | .Build() |
1233 | d5104ca4 | Helga Velroyen | op = opcodes.OpClusterVerifyGroup(group_name="default", verbose=True) |
1234 | d5104ca4 | Helga Velroyen | self.ExecOpCode(op)
|
1235 | d5104ca4 | Helga Velroyen | self.mcpu.assertLogContainsRegex("not a master candidate") |
1236 | d5104ca4 | Helga Velroyen | self.mcpu.assertLogContainsRegex(
|
1237 | d5104ca4 | Helga Velroyen | "certificate of another node which is master candidate")
|
1238 | d5104ca4 | Helga Velroyen | |
1239 | d5104ca4 | Helga Velroyen | |
1240 | b8f45292 | Thomas Thrainer | class TestLUClusterVerifyGroupMethods(CmdlibTestCase): |
1241 | b8f45292 | Thomas Thrainer | """Base class for testing individual methods in LUClusterVerifyGroup.
|
1242 | b8f45292 | Thomas Thrainer |
|
1243 | b8f45292 | Thomas Thrainer | """
|
1244 | b8f45292 | Thomas Thrainer | def setUp(self): |
1245 | b8f45292 | Thomas Thrainer | super(TestLUClusterVerifyGroupMethods, self).setUp() |
1246 | b8f45292 | Thomas Thrainer | self.op = opcodes.OpClusterVerifyGroup(group_name="default") |
1247 | b8f45292 | Thomas Thrainer | |
1248 | 9fdb10be | Thomas Thrainer | def PrepareLU(self, lu): |
1249 | 9fdb10be | Thomas Thrainer | lu._exclusive_storage = False
|
1250 | 9fdb10be | Thomas Thrainer | lu.master_node = self.master_uuid
|
1251 | 9fdb10be | Thomas Thrainer | lu.group_info = self.group
|
1252 | 9fdb10be | Thomas Thrainer | cluster.LUClusterVerifyGroup.all_node_info = \ |
1253 | 9fdb10be | Thomas Thrainer | property(fget=lambda _: self.cfg.GetAllNodesInfo()) |
1254 | 9fdb10be | Thomas Thrainer | |
1255 | b8f45292 | Thomas Thrainer | |
1256 | b8f45292 | Thomas Thrainer | class TestLUClusterVerifyGroupVerifyNode(TestLUClusterVerifyGroupMethods): |
1257 | b8f45292 | Thomas Thrainer | @withLockedLU
|
1258 | b8f45292 | Thomas Thrainer | def testInvalidNodeResult(self, lu): |
1259 | b8f45292 | Thomas Thrainer | self.assertFalse(lu._VerifyNode(self.master, None)) |
1260 | b8f45292 | Thomas Thrainer | self.assertFalse(lu._VerifyNode(self.master, "")) |
1261 | b8f45292 | Thomas Thrainer | |
1262 | b8f45292 | Thomas Thrainer | @withLockedLU
|
1263 | b8f45292 | Thomas Thrainer | def testInvalidVersion(self, lu): |
1264 | b8f45292 | Thomas Thrainer | self.assertFalse(lu._VerifyNode(self.master, {"version": None})) |
1265 | b8f45292 | Thomas Thrainer | self.assertFalse(lu._VerifyNode(self.master, {"version": ""})) |
1266 | b8f45292 | Thomas Thrainer | self.assertFalse(lu._VerifyNode(self.master, { |
1267 | b8f45292 | Thomas Thrainer | "version": (constants.PROTOCOL_VERSION - 1, constants.RELEASE_VERSION) |
1268 | b8f45292 | Thomas Thrainer | })) |
1269 | b8f45292 | Thomas Thrainer | |
1270 | b8f45292 | Thomas Thrainer | self.mcpu.ClearLogMessages()
|
1271 | b8f45292 | Thomas Thrainer | self.assertTrue(lu._VerifyNode(self.master, { |
1272 | b8f45292 | Thomas Thrainer | "version": (constants.PROTOCOL_VERSION, constants.RELEASE_VERSION + "x") |
1273 | b8f45292 | Thomas Thrainer | })) |
1274 | b8f45292 | Thomas Thrainer | self.mcpu.assertLogContainsRegex("software version mismatch") |
1275 | b8f45292 | Thomas Thrainer | |
1276 | b8f45292 | Thomas Thrainer | def _GetValidNodeResult(self, additional_fields): |
1277 | b8f45292 | Thomas Thrainer | ret = { |
1278 | b8f45292 | Thomas Thrainer | "version": (constants.PROTOCOL_VERSION, constants.RELEASE_VERSION),
|
1279 | b8f45292 | Thomas Thrainer | constants.NV_NODESETUP: [] |
1280 | b8f45292 | Thomas Thrainer | } |
1281 | b8f45292 | Thomas Thrainer | ret.update(additional_fields) |
1282 | b8f45292 | Thomas Thrainer | return ret
|
1283 | b8f45292 | Thomas Thrainer | |
1284 | b8f45292 | Thomas Thrainer | @withLockedLU
|
1285 | b8f45292 | Thomas Thrainer | def testHypervisor(self, lu): |
1286 | b8f45292 | Thomas Thrainer | lu._VerifyNode(self.master, self._GetValidNodeResult({ |
1287 | b8f45292 | Thomas Thrainer | constants.NV_HYPERVISOR: { |
1288 | b8f45292 | Thomas Thrainer | constants.HT_XEN_PVM: None,
|
1289 | b8f45292 | Thomas Thrainer | constants.HT_XEN_HVM: "mock error"
|
1290 | b8f45292 | Thomas Thrainer | } |
1291 | b8f45292 | Thomas Thrainer | })) |
1292 | b8f45292 | Thomas Thrainer | self.mcpu.assertLogContainsRegex(constants.HT_XEN_HVM)
|
1293 | b8f45292 | Thomas Thrainer | self.mcpu.assertLogContainsRegex("mock error") |
1294 | b8f45292 | Thomas Thrainer | |
1295 | b8f45292 | Thomas Thrainer | @withLockedLU
|
1296 | b8f45292 | Thomas Thrainer | def testHvParams(self, lu): |
1297 | b8f45292 | Thomas Thrainer | lu._VerifyNode(self.master, self._GetValidNodeResult({ |
1298 | b8f45292 | Thomas Thrainer | constants.NV_HVPARAMS: [("mock item", constants.HT_XEN_HVM, "mock error")] |
1299 | b8f45292 | Thomas Thrainer | })) |
1300 | b8f45292 | Thomas Thrainer | self.mcpu.assertLogContainsRegex(constants.HT_XEN_HVM)
|
1301 | b8f45292 | Thomas Thrainer | self.mcpu.assertLogContainsRegex("mock item") |
1302 | b8f45292 | Thomas Thrainer | self.mcpu.assertLogContainsRegex("mock error") |
1303 | b8f45292 | Thomas Thrainer | |
1304 | b8f45292 | Thomas Thrainer | @withLockedLU
|
1305 | b8f45292 | Thomas Thrainer | def testSuccessfulResult(self, lu): |
1306 | b8f45292 | Thomas Thrainer | self.assertTrue(lu._VerifyNode(self.master, self._GetValidNodeResult({}))) |
1307 | b8f45292 | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1308 | b8f45292 | Thomas Thrainer | |
1309 | b8f45292 | Thomas Thrainer | |
1310 | b8f45292 | Thomas Thrainer | class TestLUClusterVerifyGroupVerifyNodeTime(TestLUClusterVerifyGroupMethods): |
1311 | b8f45292 | Thomas Thrainer | @withLockedLU
|
1312 | b8f45292 | Thomas Thrainer | def testInvalidNodeResult(self, lu): |
1313 | b8f45292 | Thomas Thrainer | for ndata in [{}, {constants.NV_TIME: "invalid"}]: |
1314 | b8f45292 | Thomas Thrainer | self.mcpu.ClearLogMessages()
|
1315 | b8f45292 | Thomas Thrainer | lu._VerifyNodeTime(self.master, ndata, None, None) |
1316 | b8f45292 | Thomas Thrainer | |
1317 | b8f45292 | Thomas Thrainer | self.mcpu.assertLogContainsRegex("Node returned invalid time") |
1318 | b8f45292 | Thomas Thrainer | |
1319 | b8f45292 | Thomas Thrainer | @withLockedLU
|
1320 | b8f45292 | Thomas Thrainer | def testNodeDiverges(self, lu): |
1321 | b8f45292 | Thomas Thrainer | for ntime in [(0, 0), (2000, 0)]: |
1322 | b8f45292 | Thomas Thrainer | self.mcpu.ClearLogMessages()
|
1323 | b8f45292 | Thomas Thrainer | lu._VerifyNodeTime(self.master, {constants.NV_TIME: ntime}, 1000, 1005) |
1324 | b8f45292 | Thomas Thrainer | |
1325 | b8f45292 | Thomas Thrainer | self.mcpu.assertLogContainsRegex("Node time diverges") |
1326 | b8f45292 | Thomas Thrainer | |
1327 | b8f45292 | Thomas Thrainer | @withLockedLU
|
1328 | b8f45292 | Thomas Thrainer | def testSuccessfulResult(self, lu): |
1329 | b8f45292 | Thomas Thrainer | lu._VerifyNodeTime(self.master, {constants.NV_TIME: (0, 0)}, 0, 5) |
1330 | b8f45292 | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1331 | b8f45292 | Thomas Thrainer | |
1332 | 9fdb10be | Thomas Thrainer | |
1333 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupUpdateVerifyNodeLVM( |
1334 | 9fdb10be | Thomas Thrainer | TestLUClusterVerifyGroupMethods): |
1335 | 9fdb10be | Thomas Thrainer | def setUp(self): |
1336 | 9fdb10be | Thomas Thrainer | super(TestLUClusterVerifyGroupUpdateVerifyNodeLVM, self).setUp() |
1337 | 9fdb10be | Thomas Thrainer | self.VALID_NRESULT = {
|
1338 | 9fdb10be | Thomas Thrainer | constants.NV_VGLIST: {"mock_vg": 30000}, |
1339 | 9fdb10be | Thomas Thrainer | constants.NV_PVLIST: [ |
1340 | 9fdb10be | Thomas Thrainer | { |
1341 | 9fdb10be | Thomas Thrainer | "name": "mock_pv", |
1342 | 9fdb10be | Thomas Thrainer | "vg_name": "mock_vg", |
1343 | 9fdb10be | Thomas Thrainer | "size": 5000, |
1344 | 9fdb10be | Thomas Thrainer | "free": 2500, |
1345 | 9fdb10be | Thomas Thrainer | "attributes": [],
|
1346 | 9fdb10be | Thomas Thrainer | "lv_list": []
|
1347 | 9fdb10be | Thomas Thrainer | } |
1348 | 9fdb10be | Thomas Thrainer | ] |
1349 | 9fdb10be | Thomas Thrainer | } |
1350 | 9fdb10be | Thomas Thrainer | |
1351 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1352 | 9fdb10be | Thomas Thrainer | def testNoVgName(self, lu): |
1353 | 9fdb10be | Thomas Thrainer | lu._UpdateVerifyNodeLVM(self.master, {}, None, None) |
1354 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1355 | 9fdb10be | Thomas Thrainer | |
1356 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1357 | 9fdb10be | Thomas Thrainer | def testEmptyNodeResult(self, lu): |
1358 | 9fdb10be | Thomas Thrainer | lu._UpdateVerifyNodeLVM(self.master, {}, "mock_vg", None) |
1359 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("unable to check volume groups") |
1360 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("Can't get PV list from node") |
1361 | 9fdb10be | Thomas Thrainer | |
1362 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1363 | 9fdb10be | Thomas Thrainer | def testValidNodeResult(self, lu): |
1364 | 9fdb10be | Thomas Thrainer | lu._UpdateVerifyNodeLVM(self.master, self.VALID_NRESULT, "mock_vg", None) |
1365 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1366 | 9fdb10be | Thomas Thrainer | |
1367 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1368 | 9fdb10be | Thomas Thrainer | def testValidNodeResultExclusiveStorage(self, lu): |
1369 | 9fdb10be | Thomas Thrainer | lu._exclusive_storage = True
|
1370 | 9fdb10be | Thomas Thrainer | lu._UpdateVerifyNodeLVM(self.master, self.VALID_NRESULT, "mock_vg", |
1371 | 9fdb10be | Thomas Thrainer | cluster.LUClusterVerifyGroup.NodeImage()) |
1372 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1373 | 9fdb10be | Thomas Thrainer | |
1374 | 9fdb10be | Thomas Thrainer | |
1375 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupVerifyGroupDRBDVersion( |
1376 | 9fdb10be | Thomas Thrainer | TestLUClusterVerifyGroupMethods): |
1377 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1378 | 9fdb10be | Thomas Thrainer | def testEmptyNodeResult(self, lu): |
1379 | 9fdb10be | Thomas Thrainer | lu._VerifyGroupDRBDVersion({}) |
1380 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1381 | 9fdb10be | Thomas Thrainer | |
1382 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1383 | 9fdb10be | Thomas Thrainer | def testValidNodeResult(self, lu): |
1384 | 9fdb10be | Thomas Thrainer | lu._VerifyGroupDRBDVersion( |
1385 | 9fdb10be | Thomas Thrainer | RpcResultsBuilder() |
1386 | 9fdb10be | Thomas Thrainer | .AddSuccessfulNode(self.master, {
|
1387 | 9fdb10be | Thomas Thrainer | constants.NV_DRBDVERSION: "8.3.0"
|
1388 | 9fdb10be | Thomas Thrainer | }) |
1389 | 9fdb10be | Thomas Thrainer | .Build()) |
1390 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1391 | 9fdb10be | Thomas Thrainer | |
1392 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1393 | 9fdb10be | Thomas Thrainer | def testDifferentVersions(self, lu): |
1394 | 9fdb10be | Thomas Thrainer | node1 = self.cfg.AddNewNode()
|
1395 | 9fdb10be | Thomas Thrainer | lu._VerifyGroupDRBDVersion( |
1396 | 9fdb10be | Thomas Thrainer | RpcResultsBuilder() |
1397 | 9fdb10be | Thomas Thrainer | .AddSuccessfulNode(self.master, {
|
1398 | 9fdb10be | Thomas Thrainer | constants.NV_DRBDVERSION: "8.3.0"
|
1399 | 9fdb10be | Thomas Thrainer | }) |
1400 | 9fdb10be | Thomas Thrainer | .AddSuccessfulNode(node1, { |
1401 | 9fdb10be | Thomas Thrainer | constants.NV_DRBDVERSION: "8.4.0"
|
1402 | 9fdb10be | Thomas Thrainer | }) |
1403 | 9fdb10be | Thomas Thrainer | .Build()) |
1404 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("DRBD version mismatch: 8.3.0") |
1405 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("DRBD version mismatch: 8.4.0") |
1406 | 9fdb10be | Thomas Thrainer | |
1407 | 9fdb10be | Thomas Thrainer | |
1408 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupVerifyGroupLVM(TestLUClusterVerifyGroupMethods): |
1409 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1410 | 9fdb10be | Thomas Thrainer | def testNoVgName(self, lu): |
1411 | 9fdb10be | Thomas Thrainer | lu._VerifyGroupLVM(None, None) |
1412 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1413 | 9fdb10be | Thomas Thrainer | |
1414 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1415 | 9fdb10be | Thomas Thrainer | def testNoExclusiveStorage(self, lu): |
1416 | 9fdb10be | Thomas Thrainer | lu._VerifyGroupLVM(None, "mock_vg") |
1417 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1418 | 9fdb10be | Thomas Thrainer | |
1419 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1420 | 9fdb10be | Thomas Thrainer | def testNoPvInfo(self, lu): |
1421 | 9fdb10be | Thomas Thrainer | lu._exclusive_storage = True
|
1422 | 9fdb10be | Thomas Thrainer | nimg = cluster.LUClusterVerifyGroup.NodeImage() |
1423 | 9fdb10be | Thomas Thrainer | lu._VerifyGroupLVM({self.master.uuid: nimg}, "mock_vg") |
1424 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1425 | 9fdb10be | Thomas Thrainer | |
1426 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1427 | 9fdb10be | Thomas Thrainer | def testValidPvInfos(self, lu): |
1428 | 9fdb10be | Thomas Thrainer | lu._exclusive_storage = True
|
1429 | 9fdb10be | Thomas Thrainer | node2 = self.cfg.AddNewNode()
|
1430 | 9fdb10be | Thomas Thrainer | nimg1 = cluster.LUClusterVerifyGroup.NodeImage(uuid=self.master.uuid)
|
1431 | 9fdb10be | Thomas Thrainer | nimg1.pv_min = 10000
|
1432 | 9fdb10be | Thomas Thrainer | nimg1.pv_max = 10010
|
1433 | 9fdb10be | Thomas Thrainer | nimg2 = cluster.LUClusterVerifyGroup.NodeImage(uuid=node2.uuid) |
1434 | 9fdb10be | Thomas Thrainer | nimg2.pv_min = 9998
|
1435 | 9fdb10be | Thomas Thrainer | nimg2.pv_max = 10005
|
1436 | 9fdb10be | Thomas Thrainer | lu._VerifyGroupLVM({self.master.uuid: nimg1, node2.uuid: nimg2}, "mock_vg") |
1437 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1438 | 9fdb10be | Thomas Thrainer | |
1439 | 9fdb10be | Thomas Thrainer | |
1440 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupVerifyNodeBridges( |
1441 | 9fdb10be | Thomas Thrainer | TestLUClusterVerifyGroupMethods): |
1442 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1443 | 9fdb10be | Thomas Thrainer | def testNoBridges(self, lu): |
1444 | 9fdb10be | Thomas Thrainer | lu._VerifyNodeBridges(None, None, None) |
1445 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1446 | 9fdb10be | Thomas Thrainer | |
1447 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1448 | 9fdb10be | Thomas Thrainer | def testInvalidBridges(self, lu): |
1449 | 9fdb10be | Thomas Thrainer | for ndata in [{}, {constants.NV_BRIDGES: ""}]: |
1450 | 9fdb10be | Thomas Thrainer | self.mcpu.ClearLogMessages()
|
1451 | 9fdb10be | Thomas Thrainer | lu._VerifyNodeBridges(self.master, ndata, ["mock_bridge"]) |
1452 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("not return valid bridge information") |
1453 | 9fdb10be | Thomas Thrainer | |
1454 | 9fdb10be | Thomas Thrainer | self.mcpu.ClearLogMessages()
|
1455 | 9fdb10be | Thomas Thrainer | lu._VerifyNodeBridges(self.master, {constants.NV_BRIDGES: ["mock_bridge"]}, |
1456 | 9fdb10be | Thomas Thrainer | ["mock_bridge"])
|
1457 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("missing bridge") |
1458 | 9fdb10be | Thomas Thrainer | |
1459 | 9fdb10be | Thomas Thrainer | |
1460 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupVerifyNodeUserScripts( |
1461 | 9fdb10be | Thomas Thrainer | TestLUClusterVerifyGroupMethods): |
1462 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1463 | 9fdb10be | Thomas Thrainer | def testNoUserScripts(self, lu): |
1464 | 9fdb10be | Thomas Thrainer | lu._VerifyNodeUserScripts(self.master, {})
|
1465 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("did not return user scripts information") |
1466 | 9fdb10be | Thomas Thrainer | |
1467 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1468 | 9fdb10be | Thomas Thrainer | def testBrokenUserScripts(self, lu): |
1469 | 9fdb10be | Thomas Thrainer | lu._VerifyNodeUserScripts(self.master,
|
1470 | 9fdb10be | Thomas Thrainer | {constants.NV_USERSCRIPTS: ["script"]})
|
1471 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("scripts not present or not executable") |
1472 | 9fdb10be | Thomas Thrainer | |
1473 | 9fdb10be | Thomas Thrainer | |
1474 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupVerifyNodeNetwork( |
1475 | 9fdb10be | Thomas Thrainer | TestLUClusterVerifyGroupMethods): |
1476 | 9fdb10be | Thomas Thrainer | |
1477 | 9fdb10be | Thomas Thrainer | def setUp(self): |
1478 | 9fdb10be | Thomas Thrainer | super(TestLUClusterVerifyGroupVerifyNodeNetwork, self).setUp() |
1479 | 9fdb10be | Thomas Thrainer | self.VALID_NRESULT = {
|
1480 | 9fdb10be | Thomas Thrainer | constants.NV_NODELIST: {}, |
1481 | 9fdb10be | Thomas Thrainer | constants.NV_NODENETTEST: {}, |
1482 | 9fdb10be | Thomas Thrainer | constants.NV_MASTERIP: True
|
1483 | 9fdb10be | Thomas Thrainer | } |
1484 | 9fdb10be | Thomas Thrainer | |
1485 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1486 | 9fdb10be | Thomas Thrainer | def testEmptyNodeResult(self, lu): |
1487 | 9fdb10be | Thomas Thrainer | lu._VerifyNodeNetwork(self.master, {})
|
1488 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex(
|
1489 | 9fdb10be | Thomas Thrainer | "node hasn't returned node ssh connectivity data")
|
1490 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex(
|
1491 | 9fdb10be | Thomas Thrainer | "node hasn't returned node tcp connectivity data")
|
1492 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex(
|
1493 | 9fdb10be | Thomas Thrainer | "node hasn't returned node master IP reachability data")
|
1494 | 9fdb10be | Thomas Thrainer | |
1495 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1496 | 9fdb10be | Thomas Thrainer | def testValidResult(self, lu): |
1497 | 9fdb10be | Thomas Thrainer | lu._VerifyNodeNetwork(self.master, self.VALID_NRESULT) |
1498 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1499 | 9fdb10be | Thomas Thrainer | |
1500 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1501 | 9fdb10be | Thomas Thrainer | def testSshProblem(self, lu): |
1502 | 9fdb10be | Thomas Thrainer | self.VALID_NRESULT.update({
|
1503 | 9fdb10be | Thomas Thrainer | constants.NV_NODELIST: { |
1504 | 9fdb10be | Thomas Thrainer | "mock_node": "mock_error" |
1505 | 9fdb10be | Thomas Thrainer | } |
1506 | 9fdb10be | Thomas Thrainer | }) |
1507 | 9fdb10be | Thomas Thrainer | lu._VerifyNodeNetwork(self.master, self.VALID_NRESULT) |
1508 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("ssh communication with node 'mock_node'") |
1509 | 9fdb10be | Thomas Thrainer | |
1510 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1511 | 9fdb10be | Thomas Thrainer | def testTcpProblem(self, lu): |
1512 | 9fdb10be | Thomas Thrainer | self.VALID_NRESULT.update({
|
1513 | 9fdb10be | Thomas Thrainer | constants.NV_NODENETTEST: { |
1514 | 9fdb10be | Thomas Thrainer | "mock_node": "mock_error" |
1515 | 9fdb10be | Thomas Thrainer | } |
1516 | 9fdb10be | Thomas Thrainer | }) |
1517 | 9fdb10be | Thomas Thrainer | lu._VerifyNodeNetwork(self.master, self.VALID_NRESULT) |
1518 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("tcp communication with node 'mock_node'") |
1519 | 9fdb10be | Thomas Thrainer | |
1520 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1521 | 9fdb10be | Thomas Thrainer | def testMasterIpNotReachable(self, lu): |
1522 | 9fdb10be | Thomas Thrainer | self.VALID_NRESULT.update({
|
1523 | 9fdb10be | Thomas Thrainer | constants.NV_MASTERIP: False
|
1524 | 9fdb10be | Thomas Thrainer | }) |
1525 | 9fdb10be | Thomas Thrainer | node1 = self.cfg.AddNewNode()
|
1526 | 9fdb10be | Thomas Thrainer | lu._VerifyNodeNetwork(self.master, self.VALID_NRESULT) |
1527 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex(
|
1528 | 9fdb10be | Thomas Thrainer | "the master node cannot reach the master IP")
|
1529 | 9fdb10be | Thomas Thrainer | |
1530 | 9fdb10be | Thomas Thrainer | self.mcpu.ClearLogMessages()
|
1531 | 9fdb10be | Thomas Thrainer | lu._VerifyNodeNetwork(node1, self.VALID_NRESULT)
|
1532 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("cannot reach the master IP") |
1533 | 9fdb10be | Thomas Thrainer | |
1534 | 9fdb10be | Thomas Thrainer | |
1535 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupVerifyInstance(TestLUClusterVerifyGroupMethods): |
1536 | 9fdb10be | Thomas Thrainer | def setUp(self): |
1537 | 9fdb10be | Thomas Thrainer | super(TestLUClusterVerifyGroupVerifyInstance, self).setUp() |
1538 | 9fdb10be | Thomas Thrainer | |
1539 | 9fdb10be | Thomas Thrainer | self.node1 = self.cfg.AddNewNode() |
1540 | 9fdb10be | Thomas Thrainer | self.drbd_inst = self.cfg.AddNewInstance( |
1541 | 0c5f1b13 | Thomas Thrainer | disks=[self.cfg.CreateDisk(dev_type=constants.DT_DRBD8,
|
1542 | 9fdb10be | Thomas Thrainer | primary_node=self.master,
|
1543 | 9fdb10be | Thomas Thrainer | secondary_node=self.node1)])
|
1544 | 9fdb10be | Thomas Thrainer | self.running_inst = self.cfg.AddNewInstance( |
1545 | 9fdb10be | Thomas Thrainer | admin_state=constants.ADMINST_UP, disks_active=True)
|
1546 | 9fdb10be | Thomas Thrainer | self.diskless_inst = self.cfg.AddNewInstance(disks=[]) |
1547 | 9fdb10be | Thomas Thrainer | |
1548 | 9fdb10be | Thomas Thrainer | self.master_img = \
|
1549 | 9fdb10be | Thomas Thrainer | cluster.LUClusterVerifyGroup.NodeImage(uuid=self.master_uuid)
|
1550 | 9fdb10be | Thomas Thrainer | self.master_img.volumes = ["/".join(disk.logical_id) |
1551 | 9fdb10be | Thomas Thrainer | for inst in [self.running_inst, |
1552 | 9fdb10be | Thomas Thrainer | self.diskless_inst]
|
1553 | 9fdb10be | Thomas Thrainer | for disk in inst.disks] |
1554 | 9fdb10be | Thomas Thrainer | self.master_img.volumes.extend(
|
1555 | 9fdb10be | Thomas Thrainer | ["/".join(disk.logical_id) for disk in self.drbd_inst.disks[0].children]) |
1556 | 9fdb10be | Thomas Thrainer | self.master_img.instances = [self.running_inst.uuid] |
1557 | 9fdb10be | Thomas Thrainer | self.node1_img = \
|
1558 | 9fdb10be | Thomas Thrainer | cluster.LUClusterVerifyGroup.NodeImage(uuid=self.node1.uuid)
|
1559 | 9fdb10be | Thomas Thrainer | self.node1_img.volumes = \
|
1560 | 9fdb10be | Thomas Thrainer | ["/".join(disk.logical_id) for disk in self.drbd_inst.disks[0].children] |
1561 | 9fdb10be | Thomas Thrainer | self.node_imgs = {
|
1562 | 9fdb10be | Thomas Thrainer | self.master_uuid: self.master_img, |
1563 | 9fdb10be | Thomas Thrainer | self.node1.uuid: self.node1_img |
1564 | 9fdb10be | Thomas Thrainer | } |
1565 | 9fdb10be | Thomas Thrainer | self.diskstatus = {
|
1566 | 9fdb10be | Thomas Thrainer | self.master_uuid: [
|
1567 | 9fdb10be | Thomas Thrainer | (True, objects.BlockDevStatus(ldisk_status=constants.LDS_OKAY))
|
1568 | 9fdb10be | Thomas Thrainer | for _ in self.running_inst.disks |
1569 | 9fdb10be | Thomas Thrainer | ] |
1570 | 9fdb10be | Thomas Thrainer | } |
1571 | 9fdb10be | Thomas Thrainer | |
1572 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1573 | 9fdb10be | Thomas Thrainer | def testDisklessInst(self, lu): |
1574 | 9fdb10be | Thomas Thrainer | lu._VerifyInstance(self.diskless_inst, self.node_imgs, {}) |
1575 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1576 | 9fdb10be | Thomas Thrainer | |
1577 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1578 | 9fdb10be | Thomas Thrainer | def testOfflineNode(self, lu): |
1579 | 9fdb10be | Thomas Thrainer | self.master_img.offline = True |
1580 | 9fdb10be | Thomas Thrainer | lu._VerifyInstance(self.drbd_inst, self.node_imgs, {}) |
1581 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1582 | 9fdb10be | Thomas Thrainer | |
1583 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1584 | 9fdb10be | Thomas Thrainer | def testRunningOnOfflineNode(self, lu): |
1585 | 9fdb10be | Thomas Thrainer | self.master_img.offline = True |
1586 | 9fdb10be | Thomas Thrainer | lu._VerifyInstance(self.running_inst, self.node_imgs, {}) |
1587 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex(
|
1588 | 9fdb10be | Thomas Thrainer | "instance is marked as running and lives on offline node")
|
1589 | 9fdb10be | Thomas Thrainer | |
1590 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1591 | 9fdb10be | Thomas Thrainer | def testMissingVolume(self, lu): |
1592 | 9fdb10be | Thomas Thrainer | self.master_img.volumes = []
|
1593 | 9fdb10be | Thomas Thrainer | lu._VerifyInstance(self.running_inst, self.node_imgs, {}) |
1594 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("volume .* missing") |
1595 | 9fdb10be | Thomas Thrainer | |
1596 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1597 | 9fdb10be | Thomas Thrainer | def testRunningInstanceOnWrongNode(self, lu): |
1598 | 9fdb10be | Thomas Thrainer | self.master_img.instances = []
|
1599 | 9fdb10be | Thomas Thrainer | self.diskless_inst.admin_state = constants.ADMINST_UP
|
1600 | 9fdb10be | Thomas Thrainer | lu._VerifyInstance(self.running_inst, self.node_imgs, {}) |
1601 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("instance not running on its primary node") |
1602 | 9fdb10be | Thomas Thrainer | |
1603 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1604 | 9fdb10be | Thomas Thrainer | def testRunningInstanceOnRightNode(self, lu): |
1605 | 9fdb10be | Thomas Thrainer | self.master_img.instances = [self.running_inst.uuid] |
1606 | 9fdb10be | Thomas Thrainer | lu._VerifyInstance(self.running_inst, self.node_imgs, {}) |
1607 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1608 | 9fdb10be | Thomas Thrainer | |
1609 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1610 | 9fdb10be | Thomas Thrainer | def testValidDiskStatus(self, lu): |
1611 | 9fdb10be | Thomas Thrainer | lu._VerifyInstance(self.running_inst, self.node_imgs, self.diskstatus) |
1612 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1613 | 9fdb10be | Thomas Thrainer | |
1614 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1615 | 9fdb10be | Thomas Thrainer | def testDegradedDiskStatus(self, lu): |
1616 | 9fdb10be | Thomas Thrainer | self.diskstatus[self.master_uuid][0][1].is_degraded = True |
1617 | 9fdb10be | Thomas Thrainer | lu._VerifyInstance(self.running_inst, self.node_imgs, self.diskstatus) |
1618 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("instance .* is degraded") |
1619 | 9fdb10be | Thomas Thrainer | |
1620 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1621 | 9fdb10be | Thomas Thrainer | def testNotOkayDiskStatus(self, lu): |
1622 | 9fdb10be | Thomas Thrainer | self.diskstatus[self.master_uuid][0][1].ldisk_status = constants.LDS_FAULTY |
1623 | 9fdb10be | Thomas Thrainer | lu._VerifyInstance(self.running_inst, self.node_imgs, self.diskstatus) |
1624 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("instance .* state is 'faulty'") |
1625 | 9fdb10be | Thomas Thrainer | |
1626 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1627 | 9fdb10be | Thomas Thrainer | def testExclusiveStorageWithInvalidInstance(self, lu): |
1628 | 9fdb10be | Thomas Thrainer | self.master.ndparams[constants.ND_EXCLUSIVE_STORAGE] = True |
1629 | 9fdb10be | Thomas Thrainer | lu._VerifyInstance(self.drbd_inst, self.node_imgs, self.diskstatus) |
1630 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex(
|
1631 | 9fdb10be | Thomas Thrainer | "instance has template drbd, which is not supported")
|
1632 | 9fdb10be | Thomas Thrainer | |
1633 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1634 | 9fdb10be | Thomas Thrainer | def testExclusiveStorageWithValidInstance(self, lu): |
1635 | 9fdb10be | Thomas Thrainer | self.master.ndparams[constants.ND_EXCLUSIVE_STORAGE] = True |
1636 | 9fdb10be | Thomas Thrainer | self.running_inst.disks[0].spindles = 1 |
1637 | 9fdb10be | Thomas Thrainer | lu._VerifyInstance(self.running_inst, self.node_imgs, self.diskstatus) |
1638 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1639 | 9fdb10be | Thomas Thrainer | |
1640 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1641 | 9fdb10be | Thomas Thrainer | def testDrbdInTwoGroups(self, lu): |
1642 | 9fdb10be | Thomas Thrainer | group = self.cfg.AddNewNodeGroup()
|
1643 | 9fdb10be | Thomas Thrainer | self.node1.group = group.uuid
|
1644 | 9fdb10be | Thomas Thrainer | lu._VerifyInstance(self.drbd_inst, self.node_imgs, self.diskstatus) |
1645 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex(
|
1646 | 9fdb10be | Thomas Thrainer | "instance has primary and secondary nodes in different groups")
|
1647 | 9fdb10be | Thomas Thrainer | |
1648 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1649 | 9fdb10be | Thomas Thrainer | def testOfflineSecondary(self, lu): |
1650 | 9fdb10be | Thomas Thrainer | self.node1_img.offline = True |
1651 | 9fdb10be | Thomas Thrainer | lu._VerifyInstance(self.drbd_inst, self.node_imgs, self.diskstatus) |
1652 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("instance has offline secondary node\(s\)") |
1653 | 9fdb10be | Thomas Thrainer | |
1654 | 9fdb10be | Thomas Thrainer | |
1655 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupVerifyOrphanVolumes( |
1656 | 9fdb10be | Thomas Thrainer | TestLUClusterVerifyGroupMethods): |
1657 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1658 | 9fdb10be | Thomas Thrainer | def testOrphanedVolume(self, lu): |
1659 | 9fdb10be | Thomas Thrainer | master_img = cluster.LUClusterVerifyGroup.NodeImage(uuid=self.master_uuid)
|
1660 | 9fdb10be | Thomas Thrainer | master_img.volumes = ["mock_vg/disk_0", "mock_vg/disk_1", "mock_vg/disk_2"] |
1661 | 9fdb10be | Thomas Thrainer | node_imgs = { |
1662 | 9fdb10be | Thomas Thrainer | self.master_uuid: master_img
|
1663 | 9fdb10be | Thomas Thrainer | } |
1664 | 9fdb10be | Thomas Thrainer | node_vol_should = { |
1665 | 9fdb10be | Thomas Thrainer | self.master_uuid: ["mock_vg/disk_0"] |
1666 | 9fdb10be | Thomas Thrainer | } |
1667 | 9fdb10be | Thomas Thrainer | |
1668 | 9fdb10be | Thomas Thrainer | lu._VerifyOrphanVolumes(node_vol_should, node_imgs, |
1669 | 9fdb10be | Thomas Thrainer | utils.FieldSet("mock_vg/disk_2"))
|
1670 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("volume mock_vg/disk_1 is unknown") |
1671 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogDoesNotContainRegex("volume mock_vg/disk_0 is unknown") |
1672 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogDoesNotContainRegex("volume mock_vg/disk_2 is unknown") |
1673 | 9fdb10be | Thomas Thrainer | |
1674 | 9fdb10be | Thomas Thrainer | |
1675 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupVerifyNPlusOneMemory( |
1676 | 9fdb10be | Thomas Thrainer | TestLUClusterVerifyGroupMethods): |
1677 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1678 | 9fdb10be | Thomas Thrainer | def testN1Failure(self, lu): |
1679 | 9fdb10be | Thomas Thrainer | group1 = self.cfg.AddNewNodeGroup()
|
1680 | 9fdb10be | Thomas Thrainer | |
1681 | 9fdb10be | Thomas Thrainer | node1 = self.cfg.AddNewNode()
|
1682 | 9fdb10be | Thomas Thrainer | node2 = self.cfg.AddNewNode(group=group1)
|
1683 | 9fdb10be | Thomas Thrainer | node3 = self.cfg.AddNewNode()
|
1684 | 9fdb10be | Thomas Thrainer | |
1685 | 9fdb10be | Thomas Thrainer | inst1 = self.cfg.AddNewInstance()
|
1686 | 9fdb10be | Thomas Thrainer | inst2 = self.cfg.AddNewInstance()
|
1687 | 9fdb10be | Thomas Thrainer | inst3 = self.cfg.AddNewInstance()
|
1688 | 9fdb10be | Thomas Thrainer | |
1689 | 9fdb10be | Thomas Thrainer | node1_img = cluster.LUClusterVerifyGroup.NodeImage(uuid=node1.uuid) |
1690 | 9fdb10be | Thomas Thrainer | node1_img.sbp = { |
1691 | 9fdb10be | Thomas Thrainer | self.master_uuid: [inst1.uuid, inst2.uuid, inst3.uuid]
|
1692 | 9fdb10be | Thomas Thrainer | } |
1693 | 9fdb10be | Thomas Thrainer | |
1694 | 9fdb10be | Thomas Thrainer | node2_img = cluster.LUClusterVerifyGroup.NodeImage(uuid=node2.uuid) |
1695 | 9fdb10be | Thomas Thrainer | |
1696 | 9fdb10be | Thomas Thrainer | node3_img = cluster.LUClusterVerifyGroup.NodeImage(uuid=node3.uuid) |
1697 | 9fdb10be | Thomas Thrainer | node3_img.offline = True
|
1698 | 9fdb10be | Thomas Thrainer | |
1699 | 9fdb10be | Thomas Thrainer | node_imgs = { |
1700 | 9fdb10be | Thomas Thrainer | node1.uuid: node1_img, |
1701 | 9fdb10be | Thomas Thrainer | node2.uuid: node2_img, |
1702 | 9fdb10be | Thomas Thrainer | node3.uuid: node3_img |
1703 | 9fdb10be | Thomas Thrainer | } |
1704 | 9fdb10be | Thomas Thrainer | |
1705 | 9fdb10be | Thomas Thrainer | lu._VerifyNPlusOneMemory(node_imgs, self.cfg.GetAllInstancesInfo())
|
1706 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex(
|
1707 | 9fdb10be | Thomas Thrainer | "not enough memory to accomodate instance failovers")
|
1708 | 9fdb10be | Thomas Thrainer | |
1709 | 9fdb10be | Thomas Thrainer | self.mcpu.ClearLogMessages()
|
1710 | 9fdb10be | Thomas Thrainer | node1_img.mfree = 1000
|
1711 | 9fdb10be | Thomas Thrainer | lu._VerifyNPlusOneMemory(node_imgs, self.cfg.GetAllInstancesInfo())
|
1712 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1713 | 9fdb10be | Thomas Thrainer | |
1714 | 9fdb10be | Thomas Thrainer | |
1715 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupVerifyFiles(TestLUClusterVerifyGroupMethods): |
1716 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1717 | 9fdb10be | Thomas Thrainer | def test(self, lu): |
1718 | 9fdb10be | Thomas Thrainer | node1 = self.cfg.AddNewNode(master_candidate=False, offline=False, |
1719 | 9fdb10be | Thomas Thrainer | vm_capable=True)
|
1720 | 9fdb10be | Thomas Thrainer | node2 = self.cfg.AddNewNode(master_candidate=True, vm_capable=False) |
1721 | 9fdb10be | Thomas Thrainer | node3 = self.cfg.AddNewNode(master_candidate=False, offline=False, |
1722 | 9fdb10be | Thomas Thrainer | vm_capable=True)
|
1723 | 9fdb10be | Thomas Thrainer | node4 = self.cfg.AddNewNode(master_candidate=False, offline=False, |
1724 | 9fdb10be | Thomas Thrainer | vm_capable=True)
|
1725 | 9fdb10be | Thomas Thrainer | node5 = self.cfg.AddNewNode(master_candidate=False, offline=True) |
1726 | 9fdb10be | Thomas Thrainer | |
1727 | 9fdb10be | Thomas Thrainer | nodeinfo = [self.master, node1, node2, node3, node4, node5]
|
1728 | 9fdb10be | Thomas Thrainer | files_all = set([
|
1729 | 9fdb10be | Thomas Thrainer | pathutils.CLUSTER_DOMAIN_SECRET_FILE, |
1730 | 9fdb10be | Thomas Thrainer | pathutils.RAPI_CERT_FILE, |
1731 | 9fdb10be | Thomas Thrainer | pathutils.RAPI_USERS_FILE, |
1732 | 9fdb10be | Thomas Thrainer | ]) |
1733 | 9fdb10be | Thomas Thrainer | files_opt = set([
|
1734 | 9fdb10be | Thomas Thrainer | pathutils.RAPI_USERS_FILE, |
1735 | 9fdb10be | Thomas Thrainer | hv_xen.XL_CONFIG_FILE, |
1736 | 9fdb10be | Thomas Thrainer | pathutils.VNC_PASSWORD_FILE, |
1737 | 9fdb10be | Thomas Thrainer | ]) |
1738 | 9fdb10be | Thomas Thrainer | files_mc = set([
|
1739 | 9fdb10be | Thomas Thrainer | pathutils.CLUSTER_CONF_FILE, |
1740 | 9fdb10be | Thomas Thrainer | ]) |
1741 | 9fdb10be | Thomas Thrainer | files_vm = set([
|
1742 | 9fdb10be | Thomas Thrainer | hv_xen.XEND_CONFIG_FILE, |
1743 | 9fdb10be | Thomas Thrainer | hv_xen.XL_CONFIG_FILE, |
1744 | 9fdb10be | Thomas Thrainer | pathutils.VNC_PASSWORD_FILE, |
1745 | 9fdb10be | Thomas Thrainer | ]) |
1746 | 9fdb10be | Thomas Thrainer | nvinfo = RpcResultsBuilder() \ |
1747 | 9fdb10be | Thomas Thrainer | .AddSuccessfulNode(self.master, {
|
1748 | 9fdb10be | Thomas Thrainer | constants.NV_FILELIST: { |
1749 | 9fdb10be | Thomas Thrainer | pathutils.CLUSTER_CONF_FILE: "82314f897f38b35f9dab2f7c6b1593e0",
|
1750 | 9fdb10be | Thomas Thrainer | pathutils.RAPI_CERT_FILE: "babbce8f387bc082228e544a2146fee4",
|
1751 | 9fdb10be | Thomas Thrainer | pathutils.CLUSTER_DOMAIN_SECRET_FILE: "cds-47b5b3f19202936bb4",
|
1752 | 9fdb10be | Thomas Thrainer | hv_xen.XEND_CONFIG_FILE: "b4a8a824ab3cac3d88839a9adeadf310",
|
1753 | 9fdb10be | Thomas Thrainer | hv_xen.XL_CONFIG_FILE: "77935cee92afd26d162f9e525e3d49b9"
|
1754 | 9fdb10be | Thomas Thrainer | }}) \ |
1755 | 9fdb10be | Thomas Thrainer | .AddSuccessfulNode(node1, { |
1756 | 9fdb10be | Thomas Thrainer | constants.NV_FILELIST: { |
1757 | 9fdb10be | Thomas Thrainer | pathutils.RAPI_CERT_FILE: "97f0356500e866387f4b84233848cc4a",
|
1758 | 9fdb10be | Thomas Thrainer | hv_xen.XEND_CONFIG_FILE: "b4a8a824ab3cac3d88839a9adeadf310",
|
1759 | 9fdb10be | Thomas Thrainer | } |
1760 | 9fdb10be | Thomas Thrainer | }) \ |
1761 | 9fdb10be | Thomas Thrainer | .AddSuccessfulNode(node2, { |
1762 | 9fdb10be | Thomas Thrainer | constants.NV_FILELIST: { |
1763 | 9fdb10be | Thomas Thrainer | pathutils.RAPI_CERT_FILE: "97f0356500e866387f4b84233848cc4a",
|
1764 | 9fdb10be | Thomas Thrainer | pathutils.CLUSTER_DOMAIN_SECRET_FILE: "cds-47b5b3f19202936bb4",
|
1765 | 9fdb10be | Thomas Thrainer | } |
1766 | 9fdb10be | Thomas Thrainer | }) \ |
1767 | 9fdb10be | Thomas Thrainer | .AddSuccessfulNode(node3, { |
1768 | 9fdb10be | Thomas Thrainer | constants.NV_FILELIST: { |
1769 | 9fdb10be | Thomas Thrainer | pathutils.RAPI_CERT_FILE: "97f0356500e866387f4b84233848cc4a",
|
1770 | 9fdb10be | Thomas Thrainer | pathutils.CLUSTER_CONF_FILE: "conf-a6d4b13e407867f7a7b4f0f232a8f527",
|
1771 | 9fdb10be | Thomas Thrainer | pathutils.CLUSTER_DOMAIN_SECRET_FILE: "cds-47b5b3f19202936bb4",
|
1772 | 9fdb10be | Thomas Thrainer | pathutils.RAPI_USERS_FILE: "rapiusers-ea3271e8d810ef3",
|
1773 | 9fdb10be | Thomas Thrainer | hv_xen.XL_CONFIG_FILE: "77935cee92afd26d162f9e525e3d49b9"
|
1774 | 9fdb10be | Thomas Thrainer | } |
1775 | 9fdb10be | Thomas Thrainer | }) \ |
1776 | 9fdb10be | Thomas Thrainer | .AddSuccessfulNode(node4, {}) \ |
1777 | 9fdb10be | Thomas Thrainer | .AddOfflineNode(node5) \ |
1778 | 9fdb10be | Thomas Thrainer | .Build() |
1779 | 9fdb10be | Thomas Thrainer | assert set(nvinfo.keys()) == set(map(operator.attrgetter("uuid"), nodeinfo)) |
1780 | 9fdb10be | Thomas Thrainer | |
1781 | 9fdb10be | Thomas Thrainer | lu._VerifyFiles(nodeinfo, self.master_uuid, nvinfo,
|
1782 | 9fdb10be | Thomas Thrainer | (files_all, files_opt, files_mc, files_vm)) |
1783 | 9fdb10be | Thomas Thrainer | |
1784 | 9fdb10be | Thomas Thrainer | expected_msgs = [ |
1785 | 9fdb10be | Thomas Thrainer | "File %s found with 2 different checksums (variant 1 on"
|
1786 | 9fdb10be | Thomas Thrainer | " %s, %s, %s; variant 2 on %s)" %
|
1787 | 9fdb10be | Thomas Thrainer | (pathutils.RAPI_CERT_FILE, node1.name, node2.name, node3.name, |
1788 | 9fdb10be | Thomas Thrainer | self.master.name),
|
1789 | 9fdb10be | Thomas Thrainer | "File %s is missing from node(s) %s" %
|
1790 | 9fdb10be | Thomas Thrainer | (pathutils.CLUSTER_DOMAIN_SECRET_FILE, node1.name), |
1791 | 9fdb10be | Thomas Thrainer | "File %s should not exist on node(s) %s" %
|
1792 | 9fdb10be | Thomas Thrainer | (pathutils.CLUSTER_CONF_FILE, node3.name), |
1793 | 9fdb10be | Thomas Thrainer | "File %s is missing from node(s) %s" %
|
1794 | 9fdb10be | Thomas Thrainer | (hv_xen.XEND_CONFIG_FILE, node3.name), |
1795 | 9fdb10be | Thomas Thrainer | "File %s is missing from node(s) %s" %
|
1796 | 9fdb10be | Thomas Thrainer | (pathutils.CLUSTER_CONF_FILE, node2.name), |
1797 | 9fdb10be | Thomas Thrainer | "File %s found with 2 different checksums (variant 1 on"
|
1798 | 9fdb10be | Thomas Thrainer | " %s; variant 2 on %s)" %
|
1799 | 9fdb10be | Thomas Thrainer | (pathutils.CLUSTER_CONF_FILE, self.master.name, node3.name),
|
1800 | 9fdb10be | Thomas Thrainer | "File %s is optional, but it must exist on all or no nodes (not"
|
1801 | 9fdb10be | Thomas Thrainer | " found on %s, %s, %s)" %
|
1802 | 9fdb10be | Thomas Thrainer | (pathutils.RAPI_USERS_FILE, self.master.name, node1.name, node2.name),
|
1803 | 9fdb10be | Thomas Thrainer | "File %s is optional, but it must exist on all or no nodes (not"
|
1804 | 9fdb10be | Thomas Thrainer | " found on %s)" % (hv_xen.XL_CONFIG_FILE, node1.name),
|
1805 | 9fdb10be | Thomas Thrainer | "Node did not return file checksum data",
|
1806 | 9fdb10be | Thomas Thrainer | ] |
1807 | 9fdb10be | Thomas Thrainer | |
1808 | 9fdb10be | Thomas Thrainer | self.assertEqual(len(self.mcpu.GetLogMessages()), len(expected_msgs)) |
1809 | 9fdb10be | Thomas Thrainer | for expected_msg in expected_msgs: |
1810 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsInLine(expected_msg)
|
1811 | 9fdb10be | Thomas Thrainer | |
1812 | 9fdb10be | Thomas Thrainer | |
1813 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupVerifyNodeDrbd(TestLUClusterVerifyGroupMethods): |
1814 | 9fdb10be | Thomas Thrainer | def setUp(self): |
1815 | 9fdb10be | Thomas Thrainer | super(TestLUClusterVerifyGroupVerifyNodeDrbd, self).setUp() |
1816 | 9fdb10be | Thomas Thrainer | |
1817 | 9fdb10be | Thomas Thrainer | self.node1 = self.cfg.AddNewNode() |
1818 | 9fdb10be | Thomas Thrainer | self.node2 = self.cfg.AddNewNode() |
1819 | 9fdb10be | Thomas Thrainer | self.inst = self.cfg.AddNewInstance( |
1820 | 0c5f1b13 | Thomas Thrainer | disks=[self.cfg.CreateDisk(dev_type=constants.DT_DRBD8,
|
1821 | 9fdb10be | Thomas Thrainer | primary_node=self.node1,
|
1822 | 9fdb10be | Thomas Thrainer | secondary_node=self.node2)],
|
1823 | 9fdb10be | Thomas Thrainer | admin_state=constants.ADMINST_UP) |
1824 | 9fdb10be | Thomas Thrainer | |
1825 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1826 | 9fdb10be | Thomas Thrainer | def testNoDrbdHelper(self, lu): |
1827 | 9fdb10be | Thomas Thrainer | lu._VerifyNodeDrbd(self.master, {}, self.cfg.GetAllInstancesInfo(), None, |
1828 | 9fdb10be | Thomas Thrainer | self.cfg.ComputeDRBDMap())
|
1829 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1830 | 9fdb10be | Thomas Thrainer | |
1831 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1832 | 9fdb10be | Thomas Thrainer | def testDrbdHelperInvalidNodeResult(self, lu): |
1833 | 9fdb10be | Thomas Thrainer | for ndata, expected in [({}, "no drbd usermode helper returned"), |
1834 | 9fdb10be | Thomas Thrainer | ({constants.NV_DRBDHELPER: (False, "")}, |
1835 | 9fdb10be | Thomas Thrainer | "drbd usermode helper check unsuccessful"),
|
1836 | 9fdb10be | Thomas Thrainer | ({constants.NV_DRBDHELPER: (True, "/bin/false")}, |
1837 | 9fdb10be | Thomas Thrainer | "wrong drbd usermode helper")]:
|
1838 | 9fdb10be | Thomas Thrainer | self.mcpu.ClearLogMessages()
|
1839 | 9fdb10be | Thomas Thrainer | lu._VerifyNodeDrbd(self.master, ndata, self.cfg.GetAllInstancesInfo(), |
1840 | 9fdb10be | Thomas Thrainer | "/bin/true", self.cfg.ComputeDRBDMap()) |
1841 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex(expected)
|
1842 | 9fdb10be | Thomas Thrainer | |
1843 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1844 | 9fdb10be | Thomas Thrainer | def testNoNodeResult(self, lu): |
1845 | 9fdb10be | Thomas Thrainer | lu._VerifyNodeDrbd(self.node1, {}, self.cfg.GetAllInstancesInfo(), |
1846 | 9fdb10be | Thomas Thrainer | None, self.cfg.ComputeDRBDMap()) |
1847 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("drbd minor 1 of .* is not active") |
1848 | 9fdb10be | Thomas Thrainer | |
1849 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1850 | 9fdb10be | Thomas Thrainer | def testInvalidNodeResult(self, lu): |
1851 | 9fdb10be | Thomas Thrainer | lu._VerifyNodeDrbd(self.node1, {constants.NV_DRBDLIST: ""}, |
1852 | 9fdb10be | Thomas Thrainer | self.cfg.GetAllInstancesInfo(), None, |
1853 | 9fdb10be | Thomas Thrainer | self.cfg.ComputeDRBDMap())
|
1854 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("cannot parse drbd status file") |
1855 | 9fdb10be | Thomas Thrainer | |
1856 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1857 | 9fdb10be | Thomas Thrainer | def testWrongMinorInUse(self, lu): |
1858 | 9fdb10be | Thomas Thrainer | lu._VerifyNodeDrbd(self.node1, {constants.NV_DRBDLIST: [2]}, |
1859 | 9fdb10be | Thomas Thrainer | self.cfg.GetAllInstancesInfo(), None, |
1860 | 9fdb10be | Thomas Thrainer | self.cfg.ComputeDRBDMap())
|
1861 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("drbd minor 1 of .* is not active") |
1862 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("unallocated drbd minor 2 is in use") |
1863 | 9fdb10be | Thomas Thrainer | |
1864 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1865 | 9fdb10be | Thomas Thrainer | def testValidResult(self, lu): |
1866 | 9fdb10be | Thomas Thrainer | lu._VerifyNodeDrbd(self.node1, {constants.NV_DRBDLIST: [1]}, |
1867 | 9fdb10be | Thomas Thrainer | self.cfg.GetAllInstancesInfo(), None, |
1868 | 9fdb10be | Thomas Thrainer | self.cfg.ComputeDRBDMap())
|
1869 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1870 | 9fdb10be | Thomas Thrainer | |
1871 | 9fdb10be | Thomas Thrainer | |
1872 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupVerifyNodeOs(TestLUClusterVerifyGroupMethods): |
1873 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1874 | 9fdb10be | Thomas Thrainer | def testUpdateNodeOsInvalidNodeResult(self, lu): |
1875 | 9fdb10be | Thomas Thrainer | for ndata in [{}, {constants.NV_OSLIST: ""}, {constants.NV_OSLIST: [""]}, |
1876 | 9fdb10be | Thomas Thrainer | {constants.NV_OSLIST: [["1", "2"]]}]: |
1877 | 9fdb10be | Thomas Thrainer | self.mcpu.ClearLogMessages()
|
1878 | 9fdb10be | Thomas Thrainer | nimage = cluster.LUClusterVerifyGroup.NodeImage(uuid=self.master_uuid)
|
1879 | 9fdb10be | Thomas Thrainer | lu._UpdateNodeOS(self.master, ndata, nimage)
|
1880 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("node hasn't returned valid OS data") |
1881 | 9fdb10be | Thomas Thrainer | |
1882 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1883 | 9fdb10be | Thomas Thrainer | def testUpdateNodeOsValidNodeResult(self, lu): |
1884 | 9fdb10be | Thomas Thrainer | ndata = { |
1885 | 9fdb10be | Thomas Thrainer | constants.NV_OSLIST: [ |
1886 | 9fdb10be | Thomas Thrainer | ["mock_OS", "/mocked/path", True, "", ["default"], [], |
1887 | 9fdb10be | Thomas Thrainer | [constants.OS_API_V20]], |
1888 | 9fdb10be | Thomas Thrainer | ["Another_Mock", "/random", True, "", ["var1", "var2"], |
1889 | 9fdb10be | Thomas Thrainer | [{"param1": "val1"}, {"param2": "val2"}], constants.OS_API_VERSIONS] |
1890 | 9fdb10be | Thomas Thrainer | ] |
1891 | 9fdb10be | Thomas Thrainer | } |
1892 | 9fdb10be | Thomas Thrainer | nimage = cluster.LUClusterVerifyGroup.NodeImage(uuid=self.master_uuid)
|
1893 | 9fdb10be | Thomas Thrainer | lu._UpdateNodeOS(self.master, ndata, nimage)
|
1894 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1895 | 9fdb10be | Thomas Thrainer | |
1896 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1897 | 9fdb10be | Thomas Thrainer | def testVerifyNodeOs(self, lu): |
1898 | 9fdb10be | Thomas Thrainer | node = self.cfg.AddNewNode()
|
1899 | 9fdb10be | Thomas Thrainer | nimg_root = cluster.LUClusterVerifyGroup.NodeImage(uuid=self.master_uuid)
|
1900 | 9fdb10be | Thomas Thrainer | nimg = cluster.LUClusterVerifyGroup.NodeImage(uuid=node.uuid) |
1901 | 9fdb10be | Thomas Thrainer | |
1902 | 9fdb10be | Thomas Thrainer | nimg_root.os_fail = False
|
1903 | 9fdb10be | Thomas Thrainer | nimg_root.oslist = { |
1904 | 9fdb10be | Thomas Thrainer | "mock_os": [("/mocked/path", True, "", set(["default"]), set(), |
1905 | 9fdb10be | Thomas Thrainer | set([constants.OS_API_V20]))],
|
1906 | 9fdb10be | Thomas Thrainer | "broken_base_os": [("/broken", False, "", set(), set(), |
1907 | 9fdb10be | Thomas Thrainer | set([constants.OS_API_V20]))],
|
1908 | 9fdb10be | Thomas Thrainer | "only_on_root": [("/random", True, "", set(), set(), set())], |
1909 | 9fdb10be | Thomas Thrainer | "diffing_os": [("/pinky", True, "", set(["var1", "var2"]), |
1910 | 9fdb10be | Thomas Thrainer | set([("param1", "val1"), ("param2", "val2")]), |
1911 | 9fdb10be | Thomas Thrainer | set([constants.OS_API_V20]))]
|
1912 | 9fdb10be | Thomas Thrainer | } |
1913 | 9fdb10be | Thomas Thrainer | nimg.os_fail = False
|
1914 | 9fdb10be | Thomas Thrainer | nimg.oslist = { |
1915 | 9fdb10be | Thomas Thrainer | "mock_os": [("/mocked/path", True, "", set(["default"]), set(), |
1916 | 9fdb10be | Thomas Thrainer | set([constants.OS_API_V20]))],
|
1917 | 9fdb10be | Thomas Thrainer | "only_on_test": [("/random", True, "", set(), set(), set())], |
1918 | 9fdb10be | Thomas Thrainer | "diffing_os": [("/bunny", True, "", set(["var1", "var3"]), |
1919 | 9fdb10be | Thomas Thrainer | set([("param1", "val1"), ("param3", "val3")]), |
1920 | 9fdb10be | Thomas Thrainer | set([constants.OS_API_V15]))],
|
1921 | 9fdb10be | Thomas Thrainer | "broken_os": [("/broken", False, "", set(), set(), |
1922 | 9fdb10be | Thomas Thrainer | set([constants.OS_API_V20]))],
|
1923 | 9fdb10be | Thomas Thrainer | "multi_entries": [
|
1924 | 9fdb10be | Thomas Thrainer | ("/multi1", True, "", set(), set(), set([constants.OS_API_V20])), |
1925 | 9fdb10be | Thomas Thrainer | ("/multi2", True, "", set(), set(), set([constants.OS_API_V20]))] |
1926 | 9fdb10be | Thomas Thrainer | } |
1927 | 9fdb10be | Thomas Thrainer | |
1928 | 9fdb10be | Thomas Thrainer | lu._VerifyNodeOS(node, nimg, nimg_root) |
1929 | 9fdb10be | Thomas Thrainer | |
1930 | 9fdb10be | Thomas Thrainer | expected_msgs = [ |
1931 | 9fdb10be | Thomas Thrainer | "Extra OS only_on_test not present on reference node",
|
1932 | 9fdb10be | Thomas Thrainer | "OSes present on reference node .* but missing on this node:" +
|
1933 | 9fdb10be | Thomas Thrainer | " only_on_root",
|
1934 | 9fdb10be | Thomas Thrainer | "OS API version for diffing_os differs",
|
1935 | 9fdb10be | Thomas Thrainer | "OS variants list for diffing_os differs",
|
1936 | 9fdb10be | Thomas Thrainer | "OS parameters for diffing_os differs",
|
1937 | 9fdb10be | Thomas Thrainer | "Invalid OS broken_os",
|
1938 | 9fdb10be | Thomas Thrainer | "Extra OS broken_os not present on reference node",
|
1939 | 9fdb10be | Thomas Thrainer | "OS 'multi_entries' has multiple entries",
|
1940 | 9fdb10be | Thomas Thrainer | "Extra OS multi_entries not present on reference node"
|
1941 | 9fdb10be | Thomas Thrainer | ] |
1942 | 9fdb10be | Thomas Thrainer | |
1943 | 9fdb10be | Thomas Thrainer | self.assertEqual(len(expected_msgs), len(self.mcpu.GetLogMessages())) |
1944 | 9fdb10be | Thomas Thrainer | for expected_msg in expected_msgs: |
1945 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex(expected_msg)
|
1946 | 9fdb10be | Thomas Thrainer | |
1947 | 9fdb10be | Thomas Thrainer | |
1948 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupVerifyAcceptedFileStoragePaths( |
1949 | 9fdb10be | Thomas Thrainer | TestLUClusterVerifyGroupMethods): |
1950 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1951 | 9fdb10be | Thomas Thrainer | def testNotMaster(self, lu): |
1952 | 9fdb10be | Thomas Thrainer | lu._VerifyAcceptedFileStoragePaths(self.master, {}, False) |
1953 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1954 | 9fdb10be | Thomas Thrainer | |
1955 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1956 | 9fdb10be | Thomas Thrainer | def testNotMasterButRetunedValue(self, lu): |
1957 | 9fdb10be | Thomas Thrainer | lu._VerifyAcceptedFileStoragePaths( |
1958 | 9fdb10be | Thomas Thrainer | self.master, {constants.NV_ACCEPTED_STORAGE_PATHS: []}, False) |
1959 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex(
|
1960 | 9fdb10be | Thomas Thrainer | "Node should not have returned forbidden file storage paths")
|
1961 | 9fdb10be | Thomas Thrainer | |
1962 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1963 | 9fdb10be | Thomas Thrainer | def testMasterInvalidNodeResult(self, lu): |
1964 | 9fdb10be | Thomas Thrainer | lu._VerifyAcceptedFileStoragePaths(self.master, {}, True) |
1965 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex(
|
1966 | 9fdb10be | Thomas Thrainer | "Node did not return forbidden file storage paths")
|
1967 | 9fdb10be | Thomas Thrainer | |
1968 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1969 | 9fdb10be | Thomas Thrainer | def testMasterForbiddenPaths(self, lu): |
1970 | 9fdb10be | Thomas Thrainer | lu._VerifyAcceptedFileStoragePaths( |
1971 | 9fdb10be | Thomas Thrainer | self.master, {constants.NV_ACCEPTED_STORAGE_PATHS: ["/forbidden"]}, True) |
1972 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("Found forbidden file storage paths") |
1973 | 9fdb10be | Thomas Thrainer | |
1974 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1975 | 9fdb10be | Thomas Thrainer | def testMasterSuccess(self, lu): |
1976 | 9fdb10be | Thomas Thrainer | lu._VerifyAcceptedFileStoragePaths( |
1977 | 9fdb10be | Thomas Thrainer | self.master, {constants.NV_ACCEPTED_STORAGE_PATHS: []}, True) |
1978 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1979 | 9fdb10be | Thomas Thrainer | |
1980 | 9fdb10be | Thomas Thrainer | |
1981 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupVerifyStoragePaths( |
1982 | 9fdb10be | Thomas Thrainer | TestLUClusterVerifyGroupMethods): |
1983 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1984 | 9fdb10be | Thomas Thrainer | def testVerifyFileStoragePathsSuccess(self, lu): |
1985 | 9fdb10be | Thomas Thrainer | lu._VerifyFileStoragePaths(self.master, {})
|
1986 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1987 | 9fdb10be | Thomas Thrainer | |
1988 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1989 | 9fdb10be | Thomas Thrainer | def testVerifyFileStoragePathsFailure(self, lu): |
1990 | 9fdb10be | Thomas Thrainer | lu._VerifyFileStoragePaths(self.master,
|
1991 | 9fdb10be | Thomas Thrainer | {constants.NV_FILE_STORAGE_PATH: "/fail/path"})
|
1992 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex(
|
1993 | 9fdb10be | Thomas Thrainer | "The configured file storage path is unusable")
|
1994 | 9fdb10be | Thomas Thrainer | |
1995 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
1996 | 9fdb10be | Thomas Thrainer | def testVerifySharedFileStoragePathsSuccess(self, lu): |
1997 | 9fdb10be | Thomas Thrainer | lu._VerifySharedFileStoragePaths(self.master, {})
|
1998 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
1999 | 9fdb10be | Thomas Thrainer | |
2000 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2001 | 9fdb10be | Thomas Thrainer | def testVerifySharedFileStoragePathsFailure(self, lu): |
2002 | 9fdb10be | Thomas Thrainer | lu._VerifySharedFileStoragePaths( |
2003 | 9fdb10be | Thomas Thrainer | self.master, {constants.NV_SHARED_FILE_STORAGE_PATH: "/fail/path"}) |
2004 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex(
|
2005 | 9fdb10be | Thomas Thrainer | "The configured sharedfile storage path is unusable")
|
2006 | 9fdb10be | Thomas Thrainer | |
2007 | 9fdb10be | Thomas Thrainer | |
2008 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupVerifyOob(TestLUClusterVerifyGroupMethods): |
2009 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2010 | 9fdb10be | Thomas Thrainer | def testEmptyResult(self, lu): |
2011 | 9fdb10be | Thomas Thrainer | lu._VerifyOob(self.master, {})
|
2012 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
2013 | 9fdb10be | Thomas Thrainer | |
2014 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2015 | 9fdb10be | Thomas Thrainer | def testErrorResults(self, lu): |
2016 | 9fdb10be | Thomas Thrainer | lu._VerifyOob(self.master, {constants.NV_OOB_PATHS: ["path1", "path2"]}) |
2017 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("path1") |
2018 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("path2") |
2019 | 9fdb10be | Thomas Thrainer | |
2020 | 9fdb10be | Thomas Thrainer | |
2021 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupUpdateNodeVolumes( |
2022 | 9fdb10be | Thomas Thrainer | TestLUClusterVerifyGroupMethods): |
2023 | 9fdb10be | Thomas Thrainer | def setUp(self): |
2024 | 9fdb10be | Thomas Thrainer | super(TestLUClusterVerifyGroupUpdateNodeVolumes, self).setUp() |
2025 | 9fdb10be | Thomas Thrainer | self.nimg = cluster.LUClusterVerifyGroup.NodeImage(uuid=self.master_uuid) |
2026 | 9fdb10be | Thomas Thrainer | |
2027 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2028 | 9fdb10be | Thomas Thrainer | def testNoVgName(self, lu): |
2029 | 9fdb10be | Thomas Thrainer | lu._UpdateNodeVolumes(self.master, {}, self.nimg, None) |
2030 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
2031 | 9fdb10be | Thomas Thrainer | self.assertTrue(self.nimg.lvm_fail) |
2032 | 9fdb10be | Thomas Thrainer | |
2033 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2034 | 9fdb10be | Thomas Thrainer | def testErrorMessage(self, lu): |
2035 | 9fdb10be | Thomas Thrainer | lu._UpdateNodeVolumes(self.master, {constants.NV_LVLIST: "mock error"}, |
2036 | 9fdb10be | Thomas Thrainer | self.nimg, "mock_vg") |
2037 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("LVM problem on node: mock error") |
2038 | 9fdb10be | Thomas Thrainer | self.assertTrue(self.nimg.lvm_fail) |
2039 | 9fdb10be | Thomas Thrainer | |
2040 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2041 | 9fdb10be | Thomas Thrainer | def testInvalidNodeResult(self, lu): |
2042 | 9fdb10be | Thomas Thrainer | lu._UpdateNodeVolumes(self.master, {constants.NV_LVLIST: [1, 2, 3]}, |
2043 | 9fdb10be | Thomas Thrainer | self.nimg, "mock_vg") |
2044 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("rpc call to node failed") |
2045 | 9fdb10be | Thomas Thrainer | self.assertTrue(self.nimg.lvm_fail) |
2046 | 9fdb10be | Thomas Thrainer | |
2047 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2048 | 9fdb10be | Thomas Thrainer | def testValidNodeResult(self, lu): |
2049 | 9fdb10be | Thomas Thrainer | lu._UpdateNodeVolumes(self.master, {constants.NV_LVLIST: {}},
|
2050 | 9fdb10be | Thomas Thrainer | self.nimg, "mock_vg") |
2051 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
2052 | 9fdb10be | Thomas Thrainer | self.assertFalse(self.nimg.lvm_fail) |
2053 | 9fdb10be | Thomas Thrainer | |
2054 | 9fdb10be | Thomas Thrainer | |
2055 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupUpdateNodeInstances( |
2056 | 9fdb10be | Thomas Thrainer | TestLUClusterVerifyGroupMethods): |
2057 | 9fdb10be | Thomas Thrainer | def setUp(self): |
2058 | 9fdb10be | Thomas Thrainer | super(TestLUClusterVerifyGroupUpdateNodeInstances, self).setUp() |
2059 | 9fdb10be | Thomas Thrainer | self.nimg = cluster.LUClusterVerifyGroup.NodeImage(uuid=self.master_uuid) |
2060 | 9fdb10be | Thomas Thrainer | |
2061 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2062 | 9fdb10be | Thomas Thrainer | def testInvalidNodeResult(self, lu): |
2063 | 9fdb10be | Thomas Thrainer | lu._UpdateNodeInstances(self.master, {}, self.nimg) |
2064 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("rpc call to node failed") |
2065 | 9fdb10be | Thomas Thrainer | |
2066 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2067 | 9fdb10be | Thomas Thrainer | def testValidNodeResult(self, lu): |
2068 | 9fdb10be | Thomas Thrainer | inst = self.cfg.AddNewInstance()
|
2069 | 9fdb10be | Thomas Thrainer | lu._UpdateNodeInstances(self.master,
|
2070 | 9fdb10be | Thomas Thrainer | {constants.NV_INSTANCELIST: [inst.name]}, |
2071 | 9fdb10be | Thomas Thrainer | self.nimg)
|
2072 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
2073 | 9fdb10be | Thomas Thrainer | |
2074 | 9fdb10be | Thomas Thrainer | |
2075 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupUpdateNodeInfo(TestLUClusterVerifyGroupMethods): |
2076 | 9fdb10be | Thomas Thrainer | def setUp(self): |
2077 | 9fdb10be | Thomas Thrainer | super(TestLUClusterVerifyGroupUpdateNodeInfo, self).setUp() |
2078 | 9fdb10be | Thomas Thrainer | self.nimg = cluster.LUClusterVerifyGroup.NodeImage(uuid=self.master_uuid) |
2079 | 9fdb10be | Thomas Thrainer | self.valid_hvresult = {constants.NV_HVINFO: {"memory_free": 1024}} |
2080 | 9fdb10be | Thomas Thrainer | |
2081 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2082 | 9fdb10be | Thomas Thrainer | def testInvalidHvNodeResult(self, lu): |
2083 | 9fdb10be | Thomas Thrainer | for ndata in [{}, {constants.NV_HVINFO: ""}]: |
2084 | 9fdb10be | Thomas Thrainer | self.mcpu.ClearLogMessages()
|
2085 | 9fdb10be | Thomas Thrainer | lu._UpdateNodeInfo(self.master, ndata, self.nimg, None) |
2086 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("rpc call to node failed") |
2087 | 9fdb10be | Thomas Thrainer | |
2088 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2089 | 9fdb10be | Thomas Thrainer | def testInvalidMemoryFreeHvNodeResult(self, lu): |
2090 | 9fdb10be | Thomas Thrainer | lu._UpdateNodeInfo(self.master,
|
2091 | 9fdb10be | Thomas Thrainer | {constants.NV_HVINFO: {"memory_free": "abc"}}, |
2092 | 9fdb10be | Thomas Thrainer | self.nimg, None) |
2093 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex(
|
2094 | 9fdb10be | Thomas Thrainer | "node returned invalid nodeinfo, check hypervisor")
|
2095 | 9fdb10be | Thomas Thrainer | |
2096 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2097 | 9fdb10be | Thomas Thrainer | def testValidHvNodeResult(self, lu): |
2098 | 9fdb10be | Thomas Thrainer | lu._UpdateNodeInfo(self.master, self.valid_hvresult, self.nimg, None) |
2099 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
2100 | 9fdb10be | Thomas Thrainer | |
2101 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2102 | 9fdb10be | Thomas Thrainer | def testInvalidVgNodeResult(self, lu): |
2103 | 9fdb10be | Thomas Thrainer | for vgdata in [[], ""]: |
2104 | 9fdb10be | Thomas Thrainer | self.mcpu.ClearLogMessages()
|
2105 | 9fdb10be | Thomas Thrainer | ndata = {constants.NV_VGLIST: vgdata} |
2106 | 9fdb10be | Thomas Thrainer | ndata.update(self.valid_hvresult)
|
2107 | 9fdb10be | Thomas Thrainer | lu._UpdateNodeInfo(self.master, ndata, self.nimg, "mock_vg") |
2108 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex(
|
2109 | 9fdb10be | Thomas Thrainer | "node didn't return data for the volume group 'mock_vg'")
|
2110 | 9fdb10be | Thomas Thrainer | |
2111 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2112 | 9fdb10be | Thomas Thrainer | def testInvalidDiskFreeVgNodeResult(self, lu): |
2113 | 9fdb10be | Thomas Thrainer | self.valid_hvresult.update({
|
2114 | 9fdb10be | Thomas Thrainer | constants.NV_VGLIST: {"mock_vg": "abc"} |
2115 | 9fdb10be | Thomas Thrainer | }) |
2116 | 9fdb10be | Thomas Thrainer | lu._UpdateNodeInfo(self.master, self.valid_hvresult, self.nimg, "mock_vg") |
2117 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex(
|
2118 | 9fdb10be | Thomas Thrainer | "node returned invalid LVM info, check LVM status")
|
2119 | 9fdb10be | Thomas Thrainer | |
2120 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2121 | 9fdb10be | Thomas Thrainer | def testValidVgNodeResult(self, lu): |
2122 | 9fdb10be | Thomas Thrainer | self.valid_hvresult.update({
|
2123 | 9fdb10be | Thomas Thrainer | constants.NV_VGLIST: {"mock_vg": 10000} |
2124 | 9fdb10be | Thomas Thrainer | }) |
2125 | 9fdb10be | Thomas Thrainer | lu._UpdateNodeInfo(self.master, self.valid_hvresult, self.nimg, "mock_vg") |
2126 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
2127 | 9fdb10be | Thomas Thrainer | |
2128 | 9fdb10be | Thomas Thrainer | |
2129 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupCollectDiskInfo(TestLUClusterVerifyGroupMethods): |
2130 | 9fdb10be | Thomas Thrainer | def setUp(self): |
2131 | 9fdb10be | Thomas Thrainer | super(TestLUClusterVerifyGroupCollectDiskInfo, self).setUp() |
2132 | 9fdb10be | Thomas Thrainer | |
2133 | 9fdb10be | Thomas Thrainer | self.node1 = self.cfg.AddNewNode() |
2134 | 9fdb10be | Thomas Thrainer | self.node2 = self.cfg.AddNewNode() |
2135 | 9fdb10be | Thomas Thrainer | self.node3 = self.cfg.AddNewNode() |
2136 | 9fdb10be | Thomas Thrainer | |
2137 | 9fdb10be | Thomas Thrainer | self.diskless_inst = \
|
2138 | 9fdb10be | Thomas Thrainer | self.cfg.AddNewInstance(primary_node=self.node1, |
2139 | 9fdb10be | Thomas Thrainer | disk_template=constants.DT_DISKLESS) |
2140 | 9fdb10be | Thomas Thrainer | self.plain_inst = \
|
2141 | 9fdb10be | Thomas Thrainer | self.cfg.AddNewInstance(primary_node=self.node2, |
2142 | 9fdb10be | Thomas Thrainer | disk_template=constants.DT_PLAIN) |
2143 | 9fdb10be | Thomas Thrainer | self.drbd_inst = \
|
2144 | 9fdb10be | Thomas Thrainer | self.cfg.AddNewInstance(primary_node=self.node3, |
2145 | 9fdb10be | Thomas Thrainer | secondary_node=self.node2,
|
2146 | 9fdb10be | Thomas Thrainer | disk_template=constants.DT_DRBD8) |
2147 | 9fdb10be | Thomas Thrainer | |
2148 | 9fdb10be | Thomas Thrainer | self.node1_img = cluster.LUClusterVerifyGroup.NodeImage(
|
2149 | 9fdb10be | Thomas Thrainer | uuid=self.node1.uuid)
|
2150 | 9fdb10be | Thomas Thrainer | self.node1_img.pinst = [self.diskless_inst.uuid] |
2151 | 9fdb10be | Thomas Thrainer | self.node1_img.sinst = []
|
2152 | 9fdb10be | Thomas Thrainer | self.node2_img = cluster.LUClusterVerifyGroup.NodeImage(
|
2153 | 9fdb10be | Thomas Thrainer | uuid=self.node2.uuid)
|
2154 | 9fdb10be | Thomas Thrainer | self.node2_img.pinst = [self.plain_inst.uuid] |
2155 | 9fdb10be | Thomas Thrainer | self.node2_img.sinst = [self.drbd_inst.uuid] |
2156 | 9fdb10be | Thomas Thrainer | self.node3_img = cluster.LUClusterVerifyGroup.NodeImage(
|
2157 | 9fdb10be | Thomas Thrainer | uuid=self.node3.uuid)
|
2158 | 9fdb10be | Thomas Thrainer | self.node3_img.pinst = [self.drbd_inst.uuid] |
2159 | 9fdb10be | Thomas Thrainer | self.node3_img.sinst = []
|
2160 | 9fdb10be | Thomas Thrainer | |
2161 | 9fdb10be | Thomas Thrainer | self.node_images = {
|
2162 | 9fdb10be | Thomas Thrainer | self.node1.uuid: self.node1_img, |
2163 | 9fdb10be | Thomas Thrainer | self.node2.uuid: self.node2_img, |
2164 | 9fdb10be | Thomas Thrainer | self.node3.uuid: self.node3_img |
2165 | 9fdb10be | Thomas Thrainer | } |
2166 | 9fdb10be | Thomas Thrainer | |
2167 | 9fdb10be | Thomas Thrainer | self.node_uuids = [self.node1.uuid, self.node2.uuid, self.node3.uuid] |
2168 | 9fdb10be | Thomas Thrainer | |
2169 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2170 | 9fdb10be | Thomas Thrainer | def testSuccessfulRun(self, lu): |
2171 | 9fdb10be | Thomas Thrainer | self.rpc.call_blockdev_getmirrorstatus_multi.return_value = \
|
2172 | 9fdb10be | Thomas Thrainer | RpcResultsBuilder() \ |
2173 | 9fdb10be | Thomas Thrainer | .AddSuccessfulNode(self.node2, [(True, ""), (True, "")]) \ |
2174 | 9fdb10be | Thomas Thrainer | .AddSuccessfulNode(self.node3, [(True, "")]) \ |
2175 | 9fdb10be | Thomas Thrainer | .Build() |
2176 | 9fdb10be | Thomas Thrainer | |
2177 | 9fdb10be | Thomas Thrainer | lu._CollectDiskInfo(self.node_uuids, self.node_images, |
2178 | 9fdb10be | Thomas Thrainer | self.cfg.GetAllInstancesInfo())
|
2179 | 9fdb10be | Thomas Thrainer | |
2180 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
2181 | 9fdb10be | Thomas Thrainer | |
2182 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2183 | 9fdb10be | Thomas Thrainer | def testOfflineAndFailingNodes(self, lu): |
2184 | 9fdb10be | Thomas Thrainer | self.rpc.call_blockdev_getmirrorstatus_multi.return_value = \
|
2185 | 9fdb10be | Thomas Thrainer | RpcResultsBuilder() \ |
2186 | 9fdb10be | Thomas Thrainer | .AddOfflineNode(self.node2) \
|
2187 | 9fdb10be | Thomas Thrainer | .AddFailedNode(self.node3) \
|
2188 | 9fdb10be | Thomas Thrainer | .Build() |
2189 | 9fdb10be | Thomas Thrainer | |
2190 | 9fdb10be | Thomas Thrainer | lu._CollectDiskInfo(self.node_uuids, self.node_images, |
2191 | 9fdb10be | Thomas Thrainer | self.cfg.GetAllInstancesInfo())
|
2192 | 9fdb10be | Thomas Thrainer | |
2193 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("while getting disk information") |
2194 | 9fdb10be | Thomas Thrainer | |
2195 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2196 | 9fdb10be | Thomas Thrainer | def testInvalidNodeResult(self, lu): |
2197 | 9fdb10be | Thomas Thrainer | self.rpc.call_blockdev_getmirrorstatus_multi.return_value = \
|
2198 | 9fdb10be | Thomas Thrainer | RpcResultsBuilder() \ |
2199 | 9fdb10be | Thomas Thrainer | .AddSuccessfulNode(self.node2, [(True,), (False,)]) \ |
2200 | 9fdb10be | Thomas Thrainer | .AddSuccessfulNode(self.node3, [""]) \ |
2201 | 9fdb10be | Thomas Thrainer | .Build() |
2202 | 9fdb10be | Thomas Thrainer | |
2203 | 9fdb10be | Thomas Thrainer | lu._CollectDiskInfo(self.node_uuids, self.node_images, |
2204 | 9fdb10be | Thomas Thrainer | self.cfg.GetAllInstancesInfo())
|
2205 | 9fdb10be | Thomas Thrainer | # logging is not performed through mcpu
|
2206 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogIsEmpty()
|
2207 | 9fdb10be | Thomas Thrainer | |
2208 | 9fdb10be | Thomas Thrainer | |
2209 | 9fdb10be | Thomas Thrainer | class TestLUClusterVerifyGroupHooksCallBack(TestLUClusterVerifyGroupMethods): |
2210 | 9fdb10be | Thomas Thrainer | def setUp(self): |
2211 | 9fdb10be | Thomas Thrainer | super(TestLUClusterVerifyGroupHooksCallBack, self).setUp() |
2212 | 9fdb10be | Thomas Thrainer | |
2213 | 9fdb10be | Thomas Thrainer | self.feedback_fn = lambda _: None |
2214 | 9fdb10be | Thomas Thrainer | |
2215 | 9fdb10be | Thomas Thrainer | def PrepareLU(self, lu): |
2216 | 9fdb10be | Thomas Thrainer | super(TestLUClusterVerifyGroupHooksCallBack, self).PrepareLU(lu) |
2217 | 9fdb10be | Thomas Thrainer | |
2218 | 9fdb10be | Thomas Thrainer | lu.my_node_uuids = list(self.cfg.GetAllNodesInfo().keys()) |
2219 | 9fdb10be | Thomas Thrainer | |
2220 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2221 | 9fdb10be | Thomas Thrainer | def testEmptyGroup(self, lu): |
2222 | 9fdb10be | Thomas Thrainer | lu.my_node_uuids = [] |
2223 | 9fdb10be | Thomas Thrainer | lu.HooksCallBack(constants.HOOKS_PHASE_POST, None, self.feedback_fn, None) |
2224 | 9fdb10be | Thomas Thrainer | |
2225 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2226 | 9fdb10be | Thomas Thrainer | def testFailedResult(self, lu): |
2227 | 9fdb10be | Thomas Thrainer | lu.HooksCallBack(constants.HOOKS_PHASE_POST, |
2228 | 9fdb10be | Thomas Thrainer | RpcResultsBuilder(use_node_names=True)
|
2229 | 9fdb10be | Thomas Thrainer | .AddFailedNode(self.master).Build(),
|
2230 | 9fdb10be | Thomas Thrainer | self.feedback_fn,
|
2231 | 9fdb10be | Thomas Thrainer | None)
|
2232 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("Communication failure in hooks execution") |
2233 | 9fdb10be | Thomas Thrainer | |
2234 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2235 | 9fdb10be | Thomas Thrainer | def testOfflineNode(self, lu): |
2236 | 9fdb10be | Thomas Thrainer | lu.HooksCallBack(constants.HOOKS_PHASE_POST, |
2237 | 9fdb10be | Thomas Thrainer | RpcResultsBuilder(use_node_names=True)
|
2238 | 9fdb10be | Thomas Thrainer | .AddOfflineNode(self.master).Build(),
|
2239 | 9fdb10be | Thomas Thrainer | self.feedback_fn,
|
2240 | 9fdb10be | Thomas Thrainer | None)
|
2241 | 9fdb10be | Thomas Thrainer | |
2242 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2243 | 9fdb10be | Thomas Thrainer | def testValidResult(self, lu): |
2244 | 9fdb10be | Thomas Thrainer | lu.HooksCallBack(constants.HOOKS_PHASE_POST, |
2245 | 9fdb10be | Thomas Thrainer | RpcResultsBuilder(use_node_names=True)
|
2246 | 9fdb10be | Thomas Thrainer | .AddSuccessfulNode(self.master,
|
2247 | 9fdb10be | Thomas Thrainer | [("mock_script",
|
2248 | 9fdb10be | Thomas Thrainer | constants.HKR_SUCCESS, |
2249 | 9fdb10be | Thomas Thrainer | "mock output")])
|
2250 | 9fdb10be | Thomas Thrainer | .Build(), |
2251 | 9fdb10be | Thomas Thrainer | self.feedback_fn,
|
2252 | 9fdb10be | Thomas Thrainer | None)
|
2253 | 9fdb10be | Thomas Thrainer | |
2254 | 9fdb10be | Thomas Thrainer | @withLockedLU
|
2255 | 9fdb10be | Thomas Thrainer | def testFailedScriptResult(self, lu): |
2256 | 9fdb10be | Thomas Thrainer | lu.HooksCallBack(constants.HOOKS_PHASE_POST, |
2257 | 9fdb10be | Thomas Thrainer | RpcResultsBuilder(use_node_names=True)
|
2258 | 9fdb10be | Thomas Thrainer | .AddSuccessfulNode(self.master,
|
2259 | 9fdb10be | Thomas Thrainer | [("mock_script",
|
2260 | 9fdb10be | Thomas Thrainer | constants.HKR_FAIL, |
2261 | 9fdb10be | Thomas Thrainer | "mock output")])
|
2262 | 9fdb10be | Thomas Thrainer | .Build(), |
2263 | 9fdb10be | Thomas Thrainer | self.feedback_fn,
|
2264 | 9fdb10be | Thomas Thrainer | None)
|
2265 | 9fdb10be | Thomas Thrainer | self.mcpu.assertLogContainsRegex("Script mock_script failed") |
2266 | 9fdb10be | Thomas Thrainer | |
2267 | 9fdb10be | Thomas Thrainer | |
2268 | 570b6322 | Thomas Thrainer | class TestLUClusterVerifyDisks(CmdlibTestCase): |
2269 | 570b6322 | Thomas Thrainer | def testVerifyDisks(self): |
2270 | 570b6322 | Thomas Thrainer | op = opcodes.OpClusterVerifyDisks() |
2271 | 570b6322 | Thomas Thrainer | result = self.ExecOpCode(op)
|
2272 | 570b6322 | Thomas Thrainer | |
2273 | 570b6322 | Thomas Thrainer | self.assertEqual(1, len(result["jobs"])) |
2274 | 570b6322 | Thomas Thrainer | |
2275 | 570b6322 | Thomas Thrainer | |
2276 | 19830e88 | Thomas Thrainer | if __name__ == "__main__": |
2277 | 19830e88 | Thomas Thrainer | testutils.GanetiTestProgram() |