def test_history_not_supported(self): self.config.runner.pcmk.can_fence_history_manage( stderr="not supported", name="runner.pcmk.can_fence_history_manage", instead="runner.pcmk.can_fence_history_manage", ) self.env_assist.assert_raise_library_error( lambda: stonith.history_cleanup(self.env_assist.get_env()), [fixture.error(report_codes.FENCE_HISTORY_NOT_SUPPORTED, )], expected_in_processor=False)
def test_history_not_supported(self): self.config.fs.open( settings.crm_mon_schema, mock.mock_open(read_data=crm_mon_rng_without_history)(), name="fs.open.crm_mon_rng", instead="fs.open.crm_mon_rng" ) self.env_assist.assert_raise_library_error( lambda: stonith.history_cleanup(self.env_assist.get_env()), [ fixture.error( report_codes.FENCE_HISTORY_NOT_SUPPORTED, ) ], expected_in_processor=False )
def test_error(self): stdout = "some output\n" stderr = "some error\n" self.config.runner.pcmk.fence_history_cleanup(stdout=stdout, stderr=stderr, returncode=1, node="*") self.env_assist.assert_raise_library_error( lambda: stonith.history_cleanup(self.env_assist.get_env()), [ fixture.error( report_codes.FENCE_HISTORY_COMMAND_ERROR, command_label="cleanup", reason=(stderr + stdout).strip(), ) ], expected_in_processor=False)
def test_history_not_supported(self): self.config.fs.open( settings.crm_mon_schema, mock.mock_open(read_data=crm_mon_rng_without_history)(), name="fs.open.crm_mon_rng", instead="fs.open.crm_mon_rng" ) self.env_assist.assert_raise_library_error( lambda: stonith.history_cleanup(self.env_assist.get_env()), [ fixture.error( report_codes.FENCE_HISTORY_NOT_SUPPORTED, ) ], expected_in_processor=False )
def test_error(self): stdout = "some output\n" stderr = "some error\n" self.config.runner.pcmk.fence_history_cleanup( stdout=stdout, stderr=stderr, returncode=1, node="*" ) self.env_assist.assert_raise_library_error( lambda: stonith.history_cleanup(self.env_assist.get_env()), [ fixture.error( report_codes.FENCE_HISTORY_COMMAND_ERROR, command_label="cleanup", reason=(stderr + stdout).strip(), ) ], expected_in_processor=False )
def test_success_one_node(self): node = "rh80-node2" msg = f"cleaning up fencing-history for node {node}\n" self.config.runner.pcmk.fence_history_cleanup(stdout=msg, node=node) output = stonith.history_cleanup(self.env_assist.get_env(), node) self.assertEqual(output, msg.strip())
def test_success_all_nodes(self): msg = "cleaning up fencing-history for node *\n" self.config.runner.pcmk.fence_history_cleanup(stdout=msg, node="*") output = stonith.history_cleanup(self.env_assist.get_env()) self.assertEqual(output, msg.strip())
def test_success_one_node(self): node = "rh80-node2" msg = f"cleaning up fencing-history for node {node}\n" self.config.runner.pcmk.fence_history_cleanup(stdout=msg, node=node) output = stonith.history_cleanup(self.env_assist.get_env(), node) self.assertEqual(output, msg.strip())
def test_success_all_nodes(self): msg = "cleaning up fencing-history for node *\n" self.config.runner.pcmk.fence_history_cleanup(stdout=msg, node="*") output = stonith.history_cleanup(self.env_assist.get_env()) self.assertEqual(output, msg.strip())