def test_fence_agent_on_off(self): from chroma_agent.fence_chroma import main as agent_main # These options aren't likely to be used for STONITH, but they # should still work for manual invocation. agent_main(['-o', 'off', '-n', self.fake_node_hostname]) agent_main(['-o', 'on', '-n', self.fake_node_hostname]) self.assertRanAllCommands()
def test_standby_node_not_fenced(self): self.reset_command_capture() self.add_command(('cibadmin', '--query', '--local')) # a node in standby should not be fenced self.fake_node_attributes = self.fake_node_attributes.copy() self.fake_node_attributes['standby'] = "on" from chroma_agent.fence_chroma import main as agent_main agent_args = ('-o', 'off', '-n', self.fake_node_hostname) agent_main(agent_args) self.assertRanAllCommandsInOrder()
def test_standby_node_not_fenced(self): self.reset_command_capture() self.add_command(("cibadmin", "--query", "--local")) # a node in standby should not be fenced self.fake_node_attributes = self.fake_node_attributes.copy() self.fake_node_attributes["standby"] = "on" from chroma_agent.fence_chroma import main as agent_main agent_args = ("-o", "off", "-n", self.fake_node_hostname) agent_main(agent_args) self.assertRanAllCommandsInOrder()
def test_fence_agent_reboot(self): from chroma_agent.fence_chroma import main as agent_main # Normal use, stonithd feeds commands via stdin self.stdin_lines = ["nodename=%s" % self.fake_node_hostname, "action=reboot", "port=%s" % self.fake_node_hostname] agent_main() self.assertRanAllCommands() self.reset_command_capture_logs() # Command-line should work too agent_main(['-o', 'reboot', '-n', self.fake_node_hostname]) self.assertRanAllCommands()
def test_fence_agent_monitor(self): patcher = mock.patch("sys.exit") exit = patcher.start() # Kind of a silly test, but we just want to make sure that our # agent's monitor option doesn't barf. from chroma_agent.fence_chroma import main as agent_main agent_main(["-o", "monitor", "-n", self.fake_node_hostname]) exit.assert_called_with(0) # Make sure running with args from stdin works... self.stdin_lines = ["nodename=%s" % self.fake_node_hostname, "action=monitor"] agent_main() exit.assert_called_with(0) # Apparently stonithd sometimes(?) uses option instead of action... self.stdin_lines = ["nodename=%s" % self.fake_node_hostname, "option=monitor"] agent_main() exit.assert_called_with(0)