Revision 7ccb3074
b/test/ganeti.hooks_unittest.py | ||
---|---|---|
34 | 34 |
from ganeti import backend |
35 | 35 |
from ganeti import constants |
36 | 36 |
from ganeti import cmdlib |
37 |
from ganeti import rpc |
|
37 | 38 |
from ganeti.constants import HKR_SUCCESS, HKR_FAIL, HKR_SKIP |
38 | 39 |
|
39 | 40 |
from mocks import FakeConfig, FakeProc, FakeContext |
... | ... | |
197 | 198 |
def _call_nodes_false(node_list, hpath, phase, env): |
198 | 199 |
"""Fake call_hooks_runner function. |
199 | 200 |
|
200 |
Returns:
|
|
201 |
- list of False values with the same len as the node_list argument
|
|
201 |
@rtype: dict of node -> L{rpc.RpcResult} with an rpc error
|
|
202 |
@return: rpc failure from all nodes
|
|
202 | 203 |
|
203 | 204 |
""" |
204 |
return [False for node_name in node_list] |
|
205 |
return dict([(node, rpc.RpcResult('error', failed=True, |
|
206 |
node=node, call='FakeError')) for node in node_list]) |
|
205 | 207 |
|
206 | 208 |
@staticmethod |
207 | 209 |
def _call_script_fail(node_list, hpath, phase, env): |
208 | 210 |
"""Fake call_hooks_runner function. |
209 | 211 |
|
210 |
Returns:
|
|
211 |
- list of False values with the same len as the node_list argument
|
|
212 |
@rtype: dict of node -> L{rpc.RpcResult} with a failed script result
|
|
213 |
@return: script execution failure from all nodes
|
|
212 | 214 |
|
213 | 215 |
""" |
214 |
return dict([(node_name, [("unittest", constants.HKR_FAIL, "error")])
|
|
215 |
for node_name in node_list])
|
|
216 |
return dict([(node, rpc.RpcResult([("utest", constants.HKR_FAIL, "err")],
|
|
217 |
node=node, call='FakeScriptFail')) for node in node_list])
|
|
216 | 218 |
|
217 | 219 |
@staticmethod |
218 | 220 |
def _call_script_succeed(node_list, hpath, phase, env): |
219 | 221 |
"""Fake call_hooks_runner function. |
220 | 222 |
|
221 |
Returns:
|
|
222 |
- list of False values with the same len as the node_list argument
|
|
223 |
@rtype: dict of node -> L{rpc.RpcResult} with a successful script result
|
|
224 |
@return: script execution from all nodes
|
|
223 | 225 |
|
224 | 226 |
""" |
225 |
return dict([(node_name, [("unittest", constants.HKR_SUCCESS, "ok")])
|
|
226 |
for node_name in node_list])
|
|
227 |
return dict([(node, rpc.RpcResult([("utest", constants.HKR_SUCCESS, "ok")],
|
|
228 |
node=node, call='FakeScriptOk')) for node in node_list])
|
|
227 | 229 |
|
228 | 230 |
def setUp(self): |
229 | 231 |
self.op = opcodes.OpCode() |
Also available in: Unified diff