Beispiel #1
0
    def _assert_adjacent(self, adjacent, after):
        agent_name = "test_simple"
        original_cib = ("<resources><group id='my-group'>" +
                        self._dummy("dummy1") + self._dummy("dummy2") +
                        "</group></resources>")
        expected_cib = ("<resources><group id='my-group'>" +
                        self._dummy("dummy1") + expected_cib_simple +
                        self._dummy("dummy2") + "</group></resources>")

        (self.config.runner.pcmk.load_agent(
            agent_name=f"stonith:{agent_name}",
            agent_filename="stonith_agent_fence_simple.xml",
        ).runner.cib.load(resources=original_cib).runner.pcmk.
         load_fenced_metadata().env.push_cib(resources=expected_cib))

        stonith.create_in_group(
            self.env_assist.get_env(),
            "stonith-test",
            agent_name,
            "my-group",
            operations=[],
            meta_attributes={},
            instance_attributes={
                "must-set": "value",
                "must-set-new": "B",
            },
            adjacent_resource_id=adjacent,
            put_after_adjacent=after,
        )
Beispiel #2
0
 def test_minimal_success(self):
     self.config.env.push_cib(resources=self.expected_cib)
     stonith.create_in_group(self.env_assist.get_env(),
                             self.instance_name,
                             self.agent_name,
                             "my-group",
                             operations=[],
                             meta_attributes={},
                             instance_attributes={"must-set": "value"})
Beispiel #3
0
    def test_group_not_valid(self):
        agent_name = "test_simple"

        (self.config.runner.pcmk.load_agent(
            agent_name=f"stonith:{agent_name}",
            agent_filename="stonith_agent_fence_simple.xml",
        ).runner.cib.load().runner.pcmk.load_fenced_metadata())

        self.env_assist.assert_raise_library_error(
            lambda: stonith.create_in_group(
                self.env_assist.get_env(),
                "stonith-test",
                agent_name,
                "0-group",
                operations=[],
                meta_attributes={},
                instance_attributes={
                    "must-set": "value",
                    "must-set-new": "B",
                },
            ),
            [
                fixture.error(
                    report_codes.INVALID_ID_BAD_CHAR,
                    id="0-group",
                    id_description="group name",
                    is_first_char=True,
                    invalid_character="0",
                )
            ],
            expected_in_processor=False,
        )
Beispiel #4
0
    def _assert_adjacent(self, adjacent, after):
        agent_name = "test_simple"
        original_cib = (
            "<resources><group id='my-group'>"
            +
            self._dummy("dummy1")
            +
            self._dummy("dummy2")
            +
            "</group></resources>"
        )
        expected_cib = (
            "<resources><group id='my-group'>"
            +
            self._dummy("dummy1")
            +
            expected_cib_simple
            +
            self._dummy("dummy2")
            +
            "</group></resources>"
        )

        (self.config
            .runner.pcmk.load_agent(
                agent_name=f"stonith:{agent_name}",
                agent_filename="stonith_agent_fence_simple.xml"
            )
            .runner.cib.load(resources=original_cib)
            .runner.pcmk.load_fenced_metadata()
            .env.push_cib(resources=expected_cib)
        )

        stonith.create_in_group(
            self.env_assist.get_env(),
            "stonith-test",
            agent_name,
            "my-group",
            operations=[],
            meta_attributes={},
            instance_attributes={
                "must-set": "value",
                "must-set-new": "B",
            },
            adjacent_resource_id=adjacent,
            put_after_adjacent=after,
        )
Beispiel #5
0
 def test_minimal_wait_ok_run_ok(self):
     (self.config.runner.pcmk.can_wait(
         before="runner.cib.load").env.push_cib(
             resources=self.expected_cib,
             wait=self.timeout).runner.pcmk.load_state(
                 resources=self.expected_status))
     stonith.create_in_group(self.env_assist.get_env(),
                             self.instance_name,
                             self.agent_name,
                             "my-group",
                             operations=[],
                             meta_attributes={},
                             instance_attributes={"must-set": "value"},
                             wait=self.timeout)
     self.env_assist.assert_reports([
         fixture.info(
             report_codes.RESOURCE_RUNNING_ON_NODES,
             roles_with_nodes={"Started": ["node1"]},
             resource_id=self.instance_name,
         ),
     ])
Beispiel #6
0
    def test_group_not_valid(self):
        agent_name = "test_simple"

        (self.config
            .runner.pcmk.load_agent(
                agent_name=f"stonith:{agent_name}",
                agent_filename="stonith_agent_fence_simple.xml"
            )
            .runner.cib.load()
            .runner.pcmk.load_fenced_metadata()
        )

        self.env_assist.assert_raise_library_error(
            lambda: stonith.create_in_group(
                self.env_assist.get_env(),
                "stonith-test",
                agent_name,
                "0-group",
                operations=[],
                meta_attributes={},
                instance_attributes={
                    "must-set": "value",
                    "must-set-new": "B",
                }
            ),
            [
                fixture.error(
                    report_codes.INVALID_ID,
                    id="0-group",
                    id_description="group name",
                    is_first_char=True,
                    invalid_character="0",
                )
            ],
            expected_in_processor=False
        )