Exemplo n.º 1
0
    def setUp(self):
        super(MistralRunnerPolicyTest, self).setUp()

        # Start with a clean database for each test.
        self._establish_connection_and_re_create_db()

        # Register runners.
        runnersregistrar.register_runners()

        actions_registrar = actionsregistrar.ActionsRegistrar(
            use_pack_cache=False,
            fail_on_failure=True
        )

        for pack in PACKS:
            actions_registrar.register_from_pack(pack)

        # Register policies required for the tests.
        policiesregistrar.register_policy_types(st2common)

        policies_registrar = policiesregistrar.PolicyRegistrar(
            use_pack_cache=False,
            fail_on_failure=True
        )

        for pack in PACKS:
            policies_registrar.register_from_pack(pack)
Exemplo n.º 2
0
    def setUpClass(cls):
        super(MistralRunnerCallbackTest, cls).setUpClass()

        # Override the retry configuration here otherwise st2tests.config.parse_args
        # in DbTestCase.setUpClass will reset these overrides.
        cfg.CONF.set_override('retry_exp_msec', 100, group='mistral')
        cfg.CONF.set_override('retry_exp_max_msec', 200, group='mistral')
        cfg.CONF.set_override('retry_stop_max_msec', 200, group='mistral')
        cfg.CONF.set_override('api_url', 'http://0.0.0.0:9101', group='auth')

        # Register runners.
        runnersregistrar.register_runners()

        # Register test pack(s).
        actions_registrar = actionsregistrar.ActionsRegistrar(
            use_pack_cache=False, fail_on_failure=True)

        for pack in PACKS:
            actions_registrar.register_from_pack(pack)

        # Get an instance of the callback module and reference to mistral status map
        cls.callback_module = loader.register_callback_module(
            MISTRAL_RUNNER_NAME)
        cls.callback_class = cls.callback_module.get_instance()
        cls.status_map = cls.callback_module.STATUS_MAP
Exemplo n.º 3
0
    def test_register_action_with_no_params(self):
        registrar = actions_registrar.ActionsRegistrar()
        loader = fixtures_loader.FixturesLoader()
        action_file = loader.get_fixture_file_path_abs(
            'generic', 'actions', 'action-with-no-parameters.yaml')

        self.assertEqual(registrar._register_action('dummy', action_file),
                         None)
Exemplo n.º 4
0
    def test_register_action_with_no_params(self):
        registrar = actions_registrar.ActionsRegistrar()
        loader = fixtures_loader.FixturesLoader()
        action_file = loader.get_fixture_file_path_abs(
            "generic", "actions", "action-with-no-parameters.yaml")

        self.assertEqual(registrar._register_action("dummy", action_file),
                         False)
Exemplo n.º 5
0
    def test_register_action_invalid_parameter_type_attribute(self):
        registrar = actions_registrar.ActionsRegistrar()
        loader = fixtures_loader.FixturesLoader()
        action_file = loader.get_fixture_file_path_abs(
            'generic', 'actions', 'action_invalid_param_type.yaml')

        expected_msg = '\'list\' is not valid under any of the given schema'
        self.assertRaisesRegexp(jsonschema.ValidationError, expected_msg,
                                registrar._register_action, 'dummy',
                                action_file)
Exemplo n.º 6
0
 def test_invalid_params_schema(self):
     registrar = actions_registrar.ActionsRegistrar()
     loader = fixtures_loader.FixturesLoader()
     action_file = loader.get_fixture_file_path_abs(
         'generic', 'actions', 'action-invalid-schema-params.yaml')
     try:
         registrar._register_action('generic', action_file)
         self.fail('Invalid action schema. Should have failed.')
     except jsonschema.ValidationError:
         pass
Exemplo n.º 7
0
    def setUpClass(cls):
        super(OrquestaRunnerTest, cls).setUpClass()

        # Register runners.
        runnersregistrar.register_runners()

        # Register test pack(s).
        actions_registrar = actionsregistrar.ActionsRegistrar(
            use_pack_cache=False, fail_on_failure=True)

        for pack in PACKS:
            actions_registrar.register_from_pack(pack)
Exemplo n.º 8
0
    def test_register_action_invalid_parameter_name(self):
        registrar = actions_registrar.ActionsRegistrar()
        loader = fixtures_loader.FixturesLoader()
        action_file = loader.get_fixture_file_path_abs(
            'generic', 'actions', 'action_invalid_parameter_name.yaml')

        expected_msg = (
            'Parameter name "action-name" is invalid. Valid characters for '
            'parameter name are')
        self.assertRaisesRegexp(jsonschema.ValidationError, expected_msg,
                                registrar._register_action, 'generic',
                                action_file)
Exemplo n.º 9
0
    def setUpClass(cls):
        super(WorkflowExecutionWriteConflictTest, cls).setUpClass()

        # Register runners.
        runnersregistrar.register_runners()

        # Register test pack(s).
        actions_registrar = actionsregistrar.ActionsRegistrar(
            use_pack_cache=False, fail_on_failure=True)

        for pack in PACKS:
            actions_registrar.register_from_pack(pack)
    def setUpClass(cls):
        super(WorkflowServiceIdentifyOrphansTest, cls).setUpClass()

        # Register runners.
        runnersregistrar.register_runners()

        # Register test pack(s).
        actions_registrar = actionsregistrar.ActionsRegistrar(
            use_pack_cache=False, fail_on_failure=True)

        for pack in PACKS:
            actions_registrar.register_from_pack(pack)
Exemplo n.º 11
0
    def setUpClass(cls):
        super(WorkflowInspectionControllerTest, cls).setUpClass()
        st2tests.WorkflowTestCase.setUpClass()

        # Register runners.
        runnersregistrar.register_runners()

        # Register test pack(s).
        actions_registrar = actionsregistrar.ActionsRegistrar(
            use_pack_cache=False, fail_on_failure=True)

        for pack in PACKS:
            actions_registrar.register_from_pack(pack)
Exemplo n.º 12
0
    def setUpClass(cls):
        super(MistralRunnerTest, cls).setUpClass()

        cfg.CONF.set_override('api_url', 'http://0.0.0.0:9101', group='auth')

        # Register runners.
        runnersregistrar.register_runners()

        # Register test pack(s).
        actions_registrar = actionsregistrar.ActionsRegistrar(
            use_pack_cache=False, fail_on_failure=True)

        for pack in PACKS:
            actions_registrar.register_from_pack(pack)
Exemplo n.º 13
0
 def test_pack_name_missing(self):
     registrar = actions_registrar.ActionsRegistrar()
     loader = fixtures_loader.FixturesLoader()
     action_file = loader.get_fixture_file_path_abs(
         "generic", "actions", "action_3_pack_missing.yaml")
     registrar._register_action("dummy", action_file)
     action_name = None
     with open(action_file, "r") as fd:
         content = yaml.safe_load(fd)
         action_name = str(content["name"])
         action_db = Action.get_by_name(action_name)
         expected_msg = "Content pack must be set to dummy"
         self.assertEqual(action_db.pack, "dummy", expected_msg)
         Action.delete(action_db)
Exemplo n.º 14
0
 def test_pack_name_missing(self):
     registrar = actions_registrar.ActionsRegistrar()
     loader = fixtures_loader.FixturesLoader()
     action_file = loader.get_fixture_file_path_abs(
         'generic', 'actions', 'action_3_pack_missing.yaml')
     registrar._register_action('dummy', action_file)
     action_name = None
     with open(action_file, 'r') as fd:
         content = yaml.safe_load(fd)
         action_name = str(content['name'])
         action_db = Action.get_by_name(action_name)
         expected_msg = 'Content pack must be set to dummy'
         self.assertEqual(action_db.pack, 'dummy', expected_msg)
         Action.delete(action_db)
Exemplo n.º 15
0
    def test_register_action_invalid_parameter_type_attribute(self):
        registrar = actions_registrar.ActionsRegistrar()
        loader = fixtures_loader.FixturesLoader()
        action_file = loader.get_fixture_file_path_abs(
            "generic", "actions", "action_invalid_param_type.yaml")

        expected_msg = "'list' is not valid under any of the given schema"
        self.assertRaisesRegexp(
            jsonschema.ValidationError,
            expected_msg,
            registrar._register_action,
            "dummy",
            action_file,
        )
Exemplo n.º 16
0
    def setUpClass(cls):
        super(OrquestaRunnerTest, cls).setUpClass()

        # Register runners and policy types.
        runnersregistrar.register_runners()
        policiesregistrar.register_policy_types(st2common)

        # Register test pack(s).
        registrar_options = {'use_pack_cache': False, 'fail_on_failure': True}
        actions_registrar = actionsregistrar.ActionsRegistrar(**registrar_options)
        policies_registrar = policiesregistrar.PolicyRegistrar(**registrar_options)

        for pack in PACKS:
            actions_registrar.register_from_pack(pack)
            policies_registrar.register_from_pack(pack)
Exemplo n.º 17
0
 def test_action_update(self):
     registrar = actions_registrar.ActionsRegistrar()
     loader = fixtures_loader.FixturesLoader()
     action_file = loader.get_fixture_file_path_abs("generic", "actions",
                                                    "action1.yaml")
     registrar._register_action("wolfpack", action_file)
     # try registering again. this should not throw errors.
     registrar._register_action("wolfpack", action_file)
     action_name = None
     with open(action_file, "r") as fd:
         content = yaml.safe_load(fd)
         action_name = str(content["name"])
         action_db = Action.get_by_name(action_name)
         expected_msg = "Content pack must be set to wolfpack"
         self.assertEqual(action_db.pack, "wolfpack", expected_msg)
         Action.delete(action_db)
Exemplo n.º 18
0
 def test_action_update(self):
     registrar = actions_registrar.ActionsRegistrar()
     loader = fixtures_loader.FixturesLoader()
     action_file = loader.get_fixture_file_path_abs('generic', 'actions',
                                                    'action1.yaml')
     registrar._register_action('wolfpack', action_file)
     # try registering again. this should not throw errors.
     registrar._register_action('wolfpack', action_file)
     action_name = None
     with open(action_file, 'r') as fd:
         content = yaml.safe_load(fd)
         action_name = str(content['name'])
         action_db = Action.get_by_name(action_name)
         expected_msg = 'Content pack must be set to wolfpack'
         self.assertEqual(action_db.pack, 'wolfpack', expected_msg)
         Action.delete(action_db)
Exemplo n.º 19
0
    def setUpClass(cls):
        super(MistralRunnerCancelTest, cls).setUpClass()

        # Override the retry configuration here otherwise st2tests.config.parse_args
        # in DbTestCase.setUpClass will reset these overrides.
        cfg.CONF.set_override('retry_exp_msec', 100, group='mistral')
        cfg.CONF.set_override('retry_exp_max_msec', 200, group='mistral')
        cfg.CONF.set_override('retry_stop_max_msec', 200, group='mistral')
        cfg.CONF.set_override('api_url', 'http://0.0.0.0:9101', group='auth')

        # Register runners.
        runnersregistrar.register_runners()

        # Register test pack(s).
        actions_registrar = actionsregistrar.ActionsRegistrar(
            use_pack_cache=False, fail_on_failure=True)

        for pack in PACKS:
            actions_registrar.register_from_pack(pack)