Ejemplo n.º 1
0
    def filter_commands(self,
                        include_group=None,
                        exclude_group=None,
                        include_command=None,
                        exclude_command=None):
        """Perform command selection and exclusion.

        See random_chaos() for the description of the parameters.
        """
        all_groups = ChaosMonkey.get_all_groups()
        all_commands = ChaosMonkey.get_all_commands()
        self.chaos_monkey.reset_command_selection()

        # If any groups and any commands are not included, assume the intent
        #  is to include all groups and all commands.
        if not include_group and not include_command:
            self.chaos_monkey.include_group('all')
        if include_group:
            include_group = self._validate(include_group, all_groups)
            self.chaos_monkey.include_group(include_group)
        if exclude_group:
            exclude_group = self._validate(exclude_group, all_groups)
            self.chaos_monkey.exclude_group(exclude_group)
        if include_command:
            include_command = self._validate(include_command, all_commands)
            self.chaos_monkey.include_command(include_command)
        if exclude_command:
            exclude_command = self._validate(exclude_command, all_commands)
            self.chaos_monkey.exclude_command(exclude_command)
Ejemplo n.º 2
0
    def filter_commands(self, include_group=None, exclude_group=None,
                        include_command=None, exclude_command=None):
        """Perform command selection and exclusion.

        See random_chaos() for the description of the parameters.
        """
        all_groups = ChaosMonkey.get_all_groups()
        all_commands = ChaosMonkey.get_all_commands()
        self.chaos_monkey.reset_command_selection()

        # If any groups and any commands are not included, assume the intent
        #  is to include all groups and all commands.
        if not include_group and not include_command:
            self.chaos_monkey.include_group('all')
        if include_group:
            include_group = self._validate(include_group, all_groups)
            self.chaos_monkey.include_group(include_group)
        if exclude_group:
            exclude_group = self._validate(exclude_group, all_groups)
            self.chaos_monkey.exclude_group(exclude_group)
        if include_command:
            include_command = self._validate(
                include_command, all_commands)
            self.chaos_monkey.include_command(include_command)
        if exclude_command:
            exclude_command = self._validate(
                exclude_command, all_commands)
            self.chaos_monkey.exclude_command(exclude_command)
Ejemplo n.º 3
0
 def test_list_all_commands(self):
     cmd = Runner.list_all_commands()
     self.assertItemsEqual(cmd.keys(), ChaosMonkey.get_all_groups())
     all_commands = []
     for commands in cmd.values():
         for command in commands:
             all_commands.extend(command)
     self._assert_from_list(ChaosMonkey.get_all_commands(), all_commands)
Ejemplo n.º 4
0
 def test_get_all_commands(self):
     all_commands = ChaosMonkey.get_all_commands()
     self.assertItemsEqual(all_commands, self._get_all_command_strings())
Ejemplo n.º 5
0
 def test_display_all_commands(self):
     cmd = display_all_commands()
     self._assert_from_list(ChaosMonkey.get_all_groups(), cmd)
     self._assert_from_list(ChaosMonkey.get_all_commands(), cmd)
Ejemplo n.º 6
0
 def test_validate_incorrect_command(self):
     commands = "deny-all,monogd,deny-api-server"
     all_commands = ChaosMonkey.get_all_commands()
     with self.assertRaisesRegexp(
             BadRequest, "Invalid value given on command line: monogd"):
         Runner._validate(commands, all_commands)
Ejemplo n.º 7
0
 def test_validate_commands(self):
     commands = "deny-all,{},deny-api-server".format(Kill.jujud_cmd)
     all_commands = ChaosMonkey.get_all_commands()
     commands = Runner._validate(commands, all_commands)
     self.assertItemsEqual(
         commands, ['deny-all', Kill.jujud_cmd, 'deny-api-server'])
Ejemplo n.º 8
0
 def test_validate_command(self):
     commands = "deny-all"
     all_commands = ChaosMonkey.get_all_commands()
     commands = Runner._validate(commands, all_commands)
     self.assertItemsEqual(commands, ['deny-all'])