Esempio n. 1
0
    def testNoHooksLU(self):
        self.lu = FakeNoHooksLU(FakeProc(), self.op, FakeContext(), None)
        self.assertRaises(AssertionError, self.lu.BuildHooksEnv)
        self.assertRaises(AssertionError, self.lu.BuildHooksNodes)

        hm = hooksmaster.HooksMaster.BuildFromLu(self._HooksRpc, self.lu)
        self.assertEqual(hm.pre_env, {})
        self.assertRaises(IndexError, self._rpcs.pop)

        hm.RunPhase(constants.HOOKS_PHASE_PRE)
        self.assertRaises(IndexError, self._rpcs.pop)

        hm.RunPhase(constants.HOOKS_PHASE_POST)
        self.assertRaises(IndexError, self._rpcs.pop)

        hm.RunConfigUpdate()

        (node_list, hpath, phase, env) = self._rpcs.pop(0)
        self.assertEqual(set(node_list),
                         set([self.lu.cfg.GetMasterNodeName()]))
        self.assertEqual(hpath, constants.HOOKS_NAME_CFGUPDATE)
        self.assertEqual(phase, constants.HOOKS_PHASE_POST)
        self.assertFalse(
            compat.any(key.startswith("GANETI_POST") for key in env))
        self._CheckEnv(env, constants.HOOKS_PHASE_POST,
                       constants.HOOKS_NAME_CFGUPDATE)
        self.assertRaises(IndexError, self._rpcs.pop)

        assert isinstance(self.lu, FakeNoHooksLU), "LU was replaced"
Esempio n. 2
0
 def setUp(self):
     self.op = opcodes.OpCode()
     self.context = FakeContext()
     # WARNING: here we pass None as RpcRunner instance since we know
     # our usage via HooksMaster will not use lu.rpc
     self.lu = FakeLU(FakeProc(), self.op, self.context, FakeConfig(), None,
                      (123, "/foo/bar"), None)
Esempio n. 3
0
    def setUp(self):
        self._rpcs = []

        self.op = opcodes.OpTestDummy(result=False, messages=[], fail=False)
        self.lu = FakeEnvWithCustomPostHookNodesLU(FakeProc(), self.op,
                                                   FakeContext(), FakeConfig(),
                                                   None, (123, "/foo/bar"),
                                                   None)
Esempio n. 4
0
    def setUp(self):
        self._rpcs = []

        self.op = opcodes.OpTestDummy(result=False, messages=[], fail=False)
        self.lu = FakeEnvLU(FakeProc(), self.op, FakeContext(), None)