Example #1
0
 def test_wait(self):
     resource.resource_enable_cmd(
         self.lib,
         ["R1", "R2"],
         dict_to_modifiers(dict(wait="10")),
     )
     self.resource.enable.assert_called_once_with(["R1", "R2"], "10")
Example #2
0
 def test_no_strict(self):
     resource.resource_safe_disable_cmd(
         self.lib, ["R1", "R2"], dict_to_modifiers({"no-strict": True}))
     self.resource.disable_safe.assert_called_once_with(["R1", "R2"], False,
                                                        False)
     self.resource.disable.assert_not_called()
     self.resource.disable_simulate.assert_not_called()
Example #3
0
 def test_force(self, mock_warn):
     resource.resource_safe_disable_cmd(self.lib, ["R1", "R2"],
                                        dict_to_modifiers({"force": True}))
     self.resource.disable.assert_called_once_with(["R1", "R2"], False)
     self.resource.disable_safe.assert_not_called()
     self.resource.disable_simulate.assert_not_called()
     mock_warn.assert_called_once_with(self.force_warning)
Example #4
0
 def test_more_resources(self):
     resource.resource_safe_disable_cmd(self.lib, ["R1", "R2"],
                                        dict_to_modifiers({}))
     self.resource.disable_safe.assert_called_once_with(["R1", "R2"], True,
                                                        False)
     self.resource.disable.assert_not_called()
     self.resource.disable_simulate.assert_not_called()
Example #5
0
 def test_wait(self):
     resource.resource_safe_disable_cmd(self.lib, ["R1", "R2"],
                                        dict_to_modifiers(dict(wait="10")))
     self.resource.disable_safe.assert_called_once_with(["R1", "R2"], True,
                                                        "10")
     self.resource.disable.assert_not_called()
     self.resource.disable_simulate.assert_not_called()
Example #6
0
 def test_no_args(self, mock_deprecation):
     with self.assertRaises(CmdLineInputError) as cm:
         resource.resource_move(self.lib, [], dict_to_modifiers({}))
     self.assertEqual(cm.exception.message,
                      "must specify a resource to move")
     self.resource.move_autoclean.assert_not_called()
     mock_deprecation.assert_not_called()
Example #7
0
 def test_wait(self):
     resource.resource_disable_cmd(self.lib, ["R1", "R2"],
                                   dict_to_modifiers(dict(wait="10")))
     self.report_processor.suppress_reports_of_severity.assert_not_called()
     self.resource.disable.assert_called_once_with(["R1", "R2"], "10")
     self.resource.disable_safe.assert_not_called()
     self.resource.disable_simulate.assert_not_called()
Example #8
0
 def test_lib_call_full(self):
     booth_cmd.config_destroy(
         self.lib, [], dict_to_modifiers(dict(name="my_booth", force=True)))
     self.lib.booth.config_destroy.assert_called_once_with(
         ignore_config_load_problems=True,
         instance_name="my_booth",
     )
Example #9
0
 def test_no_args(self):
     with self.assertRaises(CmdLineInputError) as cm:
         resource.resource_unmanage_cmd(self.lib, [],
                                        dict_to_modifiers(dict()))
     self.assertEqual(cm.exception.message,
                      "You must specify resource(s) to unmanage")
     self.resource.unmanage.assert_not_called()
Example #10
0
 def test_one_resource(self):
     resource.resource_disable_cmd(
         self.lib, ["R1"], dict_to_modifiers(dict())
     )
     self.resource.disable.assert_called_once_with(["R1"], False)
     self.resource.disable_safe.assert_not_called()
     self.resource.disable_simulate.assert_not_called()
Example #11
0
 def test_lib_call_minimal(self):
     booth_cmd.config_ticket_remove(self.lib, ["ticketA"],
                                    dict_to_modifiers(dict()))
     self.lib.booth.config_ticket_remove.assert_called_once_with(
         "ticketA",
         instance_name=None,
     )
Example #12
0
 def test_success_node(self):
     resource.resource_unmove_unban(
         self.lib, ["resource", "node"], dict_to_modifiers(dict())
     )
     self.resource.unmove_unban.assert_called_once_with(
         "resource", node="node", master=False, expired=False, wait=False
     )
Example #13
0
 def test_success_lifetime_unchanged(self):
     self.cli_command(
         self.lib, ["resource", "lifetime=T1h"], dict_to_modifiers(dict())
     )
     self.lib_command.assert_called_once_with(
         "resource", lifetime="T1h", master=False, node=None, wait=False
     )
Example #14
0
 def test_no_resources(self):
     with self.assertRaises(CmdLineInputError) as cm:
         resource.resource_group_add_cmd(
             self.lib, ["G"], dict_to_modifiers(dict())
         )
     self.assertIsNone(cm.exception.message)
     self.resource.group_add.assert_not_called()
Example #15
0
 def test_more_resources(self):
     resource.resource_unmanage_cmd(
         self.lib, ["R1", "R2"], dict_to_modifiers(dict())
     )
     self.resource.unmanage.assert_called_once_with(
         ["R1", "R2"], with_monitor=False
     )
Example #16
0
 def test_no_args(self):
     with self.assertRaises(CmdLineInputError) as cm:
         resource.resource_unmove_unban(self.lib, [],
                                        dict_to_modifiers(dict()))
     self.assertEqual(cm.exception.message,
                      "must specify a resource to clear")
     self.resource.unmove_unban.assert_not_called()
Example #17
0
 def test_success_node(self):
     self.cli_command(self.lib, ["resource", "node"], dict_to_modifiers({}))
     self.lib_command.assert_called_once_with("resource",
                                              lifetime=None,
                                              master=False,
                                              node="node",
                                              wait=False)
Example #18
0
    def assert_failcount_output(
        self,
        lib_failures,
        expected_output,
        resource_id=None,
        node=None,
        operation=None,
        interval=None,
        full=False,
    ):
        self.get_failcounts.return_value = lib_failures
        argv = []
        if resource_id:
            argv.append(resource_id)
        if node:
            argv.append(f"node={node}")
        if operation:
            argv.append(f"operation={operation}")
        if interval:
            argv.append(f"interval={interval}")

        resource.resource_failcount_show(self.lib, argv,
                                         dict_to_modifiers(dict(full=full)))
        self.print_mock.assert_called_once()
        ac(
            self.print_mock.call_args[0][0],
            expected_output,
        )
Example #19
0
 def test_lib_call_minimal(self):
     booth_cmd.ticket_revoke(self.lib, ["ticketA"], dict_to_modifiers({}))
     self.lib.booth.ticket_revoke.assert_called_once_with(
         "ticketA",
         instance_name=None,
         site_ip=None,
     )
Example #20
0
 def test_one_resource(self):
     resource.resource_disable_common(self.lib, ["R1"],
                                      dict_to_modifiers({}))
     self.resource.disable.assert_called_once_with(["R1"], False)
     self.report_processor.suppress_reports_of_severity.assert_not_called()
     self.resource.disable_safe.assert_not_called()
     self.resource.disable_simulate.assert_not_called()
Example #21
0
 def test_lib_call_full(self):
     booth_cmd.ticket_revoke(self.lib, ["ticketA", "1.2.3.4"],
                             dict_to_modifiers(dict(name="my_booth")))
     self.lib.booth.ticket_revoke.assert_called_once_with(
         "ticketA",
         instance_name="my_booth",
         site_ip="1.2.3.4",
     )
Example #22
0
 def test_lib_call_minimal(self):
     booth_cmd.create_in_cluster(self.lib, ["ip", "1.2.3.4"],
                                 dict_to_modifiers(dict()))
     self.lib.booth.create_in_cluster.assert_called_once_with(
         "1.2.3.4",
         instance_name=None,
         allow_absent_resource_agent=False,
     )
Example #23
0
 def test_safe_no_strict(self):
     resource.resource_disable_cmd(self.lib, ["R1", "R2"],
                                   dict_to_modifiers({"no-strict": True}))
     self.resource.disable_safe.assert_called_once_with(["R1", "R2"], False,
                                                        False)
     self.report_processor.suppress_reports_of_severity.assert_not_called()
     self.resource.disable.assert_not_called()
     self.resource.disable_simulate.assert_not_called()
Example #24
0
 def test_monitor(self):
     resource.resource_unmanage_cmd(
         self.lib,
         ["R1", "R2"],
         dict_to_modifiers(dict(monitor=True)),
     )
     self.resource.unmanage.assert_called_once_with(["R1", "R2"],
                                                    with_monitor=True)
Example #25
0
 def test_success(self, mock_deprecation):
     resource.resource_move(self.lib, ["resource"], dict_to_modifiers({}))
     self.resource.move_autoclean.assert_called_once_with("resource",
                                                          node=None,
                                                          master=False,
                                                          wait_timeout=-1,
                                                          strict=False)
     mock_deprecation.assert_not_called()
Example #26
0
 def test_success_all_options(self):
     resource.resource_unmove_unban(
         self.lib,
         ["resource", "node"],
         dict_to_modifiers(dict(master=True, expired=True, wait="10")),
     )
     self.resource.unmove_unban.assert_called_once_with(
         "resource", node="node", master=True, expired=True, wait="10"
     )
Example #27
0
 def test_too_many_args(self):
     with self.assertRaises(CmdLineInputError) as cm:
         resource.resource_unmove_unban(
             self.lib,
             ["resource", "arg1", "arg2"],
             dict_to_modifiers(dict()),
         )
     self.assertIsNone(cm.exception.message)
     self.resource.unmove_unban.assert_not_called()
Example #28
0
 def test_success_all_options(self):
     self.cli_command(
         self.lib,
         ["resource", "lifetime=1h", "node"],
         dict_to_modifiers(dict(master=True, wait="10")),
     )
     self.lib_command.assert_called_once_with(
         "resource", lifetime="P1h", master=True, node="node", wait="10"
     )
Example #29
0
 def test_succes_node_lifetime(self):
     self.cli_command(
         self.lib,
         ["resource", "node", "lifetime=1h"],
         dict_to_modifiers(dict()),
     )
     self.lib_command.assert_called_once_with(
         "resource", lifetime="P1h", master=False, node="node", wait=False
     )
Example #30
0
 def test_lifetime_twice(self):
     with self.assertRaises(CmdLineInputError) as cm:
         self.cli_command(
             self.lib,
             ["resource", "lifetime=1h", "lifetime=2h"],
             dict_to_modifiers(dict()),
         )
     self.assertIsNone(cm.exception.message)
     self.lib_command.assert_not_called()
Example #31
0
 def call_cmd(self, argv, modifiers=None):
     cluster.link_remove(self.lib, argv, dict_to_modifiers(modifiers or {}))
Example #32
0
 def call_cmd(self, argv, modifiers=None):
     cluster.node_add(self.lib, argv, dict_to_modifiers(modifiers or {}))
Example #33
0
 def call_cmd_without_cluster_name(self, argv, modifiers=None):
     cluster.cluster_setup(
         self.lib, argv, dict_to_modifiers(modifiers or {})
     )