Exemplo n.º 1
0
 def test_should_raise_error_when_rebooting_artefact(self):
     try:
         reboot(uris=["artefact://not-a-host"])
     except BaseException as e:
         self.assertEqual(str(e), "Cannot reboot artefact://not-a-host")
     else:
         self.fail("No exception raised while trying to reboot an artefact")
Exemplo n.º 2
0
 def test_should_raise_error_when_rebooting_artefact(self):
     try:
         reboot(uris=["artefact://not-a-host"])
     except BaseException as e:
         self.assertEqual(str(e), "Cannot reboot artefact://not-a-host")
     else:
         self.fail("No exception raised while trying to reboot an artefact")
Exemplo n.º 3
0
    def test_should_stop_services_then_reboot_then_start_services(self,
                                                                  dump_plan,
                                                                  state_reboot,
                                                                  state_metalogic):
        components = create_component_pool_for_one_host(add_services=True)
        state_reboot.return_value = components
        state_metalogic.return_value = state_reboot.return_value

        reboot(uris=["host://foobar42"])

        dump_plan_calls = dump_plan.call_args_list
        self.assertEqual(len(dump_plan_calls), 1, "More than one plan for reboot was serialized! (potential overwrite)")
        dump_plan_call = dump_plan_calls[0]
        dump_plan_call_name, dump_plan_args = dump_plan_call[0]
        actual_reboot_plan = dump_plan_args

        # Careful, there's no missing comma here (string concatenation)
        expected_actions = [
            Action("update", "host://foobar42", "state", "rebooted",
                   kwargs={"reboot_required": True, "upgrade_packages": False},
                   preconditions=[
                       TargetState("service://foobar42/bazservice", "state", "down"),
                       TargetState("service://foobar42/barservice", "state", "down")]),
            Action("start", "service://foobar42/barservice", "state", "up",
                   preconditions=[
                       TargetState("host://foobar42", "state", "rebooted")]),
            Action("start", "service://foobar42/bazservice", "state", "up",
                   preconditions=[
                       TargetState("host://foobar42", "state", "rebooted")]),
            Action("stop", "service://foobar42/barservice", "state", "down"),
            Action("stop", "service://foobar42/bazservice", "state", "down")
        ]

        assert_actual_plan_matches_expected_actions(self, expected_actions, actual_reboot_plan)
Exemplo n.º 4
0
    def test_should_stop_services_then_reboot_then_start_services(
            self, dump_plan, state_reboot, state_metalogic):
        components = create_component_pool_for_one_host(add_services=True)
        state_reboot.return_value = components
        state_metalogic.return_value = state_reboot.return_value

        reboot(uris=["host://foobar42"])

        dump_plan_calls = dump_plan.call_args_list
        self.assertEqual(
            len(dump_plan_calls), 1,
            "More than one plan for reboot was serialized! (potential overwrite)"
        )
        dump_plan_call = dump_plan_calls[0]
        dump_plan_call_name, dump_plan_args = dump_plan_call[0]
        actual_reboot_plan = dump_plan_args

        # Careful, there's no missing comma here (string concatenation)
        expected_actions = [
            Action("update",
                   "host://foobar42",
                   "state",
                   "rebooted",
                   kwargs={
                       "reboot_required": True,
                       "upgrade_packages": False
                   },
                   preconditions=[
                       TargetState("service://foobar42/bazservice", "state",
                                   "down"),
                       TargetState("service://foobar42/barservice", "state",
                                   "down")
                   ]),
            Action("start",
                   "service://foobar42/barservice",
                   "state",
                   "up",
                   preconditions=[
                       TargetState("host://foobar42", "state", "rebooted")
                   ]),
            Action("start",
                   "service://foobar42/bazservice",
                   "state",
                   "up",
                   preconditions=[
                       TargetState("host://foobar42", "state", "rebooted")
                   ]),
            Action("stop", "service://foobar42/barservice", "state", "down"),
            Action("stop", "service://foobar42/bazservice", "state", "down")
        ]

        assert_actual_plan_matches_expected_actions(self, expected_actions,
                                                    actual_reboot_plan)