def test_flatpak(self, osbs, scratch):
        additional_params = {
            'flatpak':
            True,
            'module':
            TEST_MODULE_NAME + ":" + TEST_MODULE_STREAM + ":" +
            TEST_MODULE_VERSION
        }
        if scratch:
            additional_params['scratch'] = True
        params, build_json = self.get_orchestrator_build_request(
            osbs, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        args = plugin_value_get(plugins, 'prebuild_plugins',
                                'resolve_module_compose', 'args')

        odcs_url = "https://odcs.example.com/odcs/1"
        odcs_insecure = False
        pdc_url = "https://pdc.example.com/rest_api/v1"
        pdc_insecure = False

        match_args = {
            'module_name': TEST_MODULE_NAME,
            'module_stream': TEST_MODULE_STREAM,
            'module_version': TEST_MODULE_VERSION,
            "odcs_url": odcs_url,
            "odcs_insecure": odcs_insecure,
            "pdc_url": pdc_url,
            "pdc_insecure": pdc_insecure
        }
        assert match_args == args

        args = plugin_value_get(plugins, 'prebuild_plugins',
                                'flatpak_create_dockerfile', 'args')

        match_args = {
            "base_image": TEST_FLATPAK_BASE_IMAGE,
        }
        assert match_args == args

        args = plugin_value_get(plugins, 'buildstep_plugins',
                                'orchestrate_build', 'args')
        build_kwargs = args['build_kwargs']
        assert build_kwargs['flatpak'] is True
        assert build_kwargs['module'] == additional_params['module']

        config_kwargs = args['config_kwargs']
        assert config_kwargs['flatpak_base_image'] == TEST_FLATPAK_BASE_IMAGE
        assert config_kwargs['odcs_url'] == odcs_url
        assert config_kwargs['odcs_insecure'] == str(odcs_insecure)
        assert config_kwargs['pdc_url'] == pdc_url
        assert config_kwargs['pdc_insecure'] == str(pdc_insecure)
    def test_pulp_push(self, openshift):  # noqa:F811
        platform_descriptors = {'x86_64': {'enable_v1': True}}
        osbs_api = osbs_with_pulp(openshift, platform_descriptors=platform_descriptors)
        additional_params = {
            'base_image': 'fedora:latest',
        }
        _, build_json = self.get_worker_build_request(osbs_api, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        args = plugin_value_get(plugins, 'postbuild_plugins', 'pulp_push', 'args')

        build_conf = osbs_api.build_conf
        # Use first docker registry and strip off /v2
        pulp_registry_name = build_conf.get_pulp_registry()
        pulp_secret_path = '/'.join([SECRETS_PATH, build_conf.get_pulp_secret()])

        expected_args = {
            'pulp_registry_name': pulp_registry_name,
            'pulp_secret_path': pulp_secret_path,
            'load_exported_image': True,
            'dockpulp_loglevel': 'INFO',
            'publish': False
        }

        assert args == expected_args
Example #3
0
    def test_pull_base_image(self, osbs, build_type, scratch, base_image,
                             expect_plugin):
        phase = 'prebuild_plugins'
        plugin = 'pull_base_image'
        additional_params = {
            'base_image': base_image,
        }
        if scratch:
            additional_params['scratch'] = True

        (params, build_json) = self.get_build_request(build_type, osbs,
                                                      additional_params)
        plugins = get_plugins_from_build_json(build_json)

        if not expect_plugin:
            with pytest.raises(NoSuchPluginException):
                get_plugin(plugins, phase, plugin)
        else:
            args = plugin_value_get(plugins, phase, plugin, 'args')

            allowed_args = set([
                'parent_registry',
                'parent_registry_insecure',
            ])
            assert set(args.keys()) <= allowed_args
    def test_koji_import(self, osbs, scratch):
        additional_params = {
            'base_image': 'fedora:latest',
            'koji_upload_dir': 'upload',
        }
        if scratch:
            additional_params['scratch'] = True
        params, build_json = self.get_orchestrator_build_request(osbs, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        if scratch:
            with pytest.raises(NoSuchPluginException):
                get_plugin(plugins, 'exit_plugins', 'koji_import')
            return

        args = plugin_value_get(plugins, 'exit_plugins',
                                         'koji_import', 'args')

        match_args = {
            'koji_keytab': False,
            'kojihub': 'http://koji.example.com/kojihub',
            'url': '/',
            'use_auth': False,
            'verify_ssl': False
        }
        assert match_args == args
Example #5
0
    def test_add_filesystem_in_worker(self, osbs, base_image, scratch,
                                      expect_plugin):
        additional_params = {
            'base_image': base_image,
            'yum_repourls': ['https://example.com/my.repo'],
        }
        if scratch:
            additional_params['scratch'] = True
        params, build_json = self.get_worker_build_request(
            osbs, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        if not expect_plugin:
            with pytest.raises(NoSuchPluginException):
                get_plugin(plugins, 'prebuild_plugins', 'add_filesystem')
        else:
            args = plugin_value_get(plugins, 'prebuild_plugins',
                                    'add_filesystem', 'args')
            allowed_args = set([
                'koji_hub',
                'repos',
                'from_task_id',
            ])
            assert set(args.keys()) <= allowed_args
            assert 'koji_hub' in args
            assert args['repos'] == params['yum_repourls']
            assert args['from_task_id'] == params['filesystem_koji_task_id']
Example #6
0
    def test_koji_upload(self, osbs, scratch):
        additional_params = {
            'base_image': 'fedora:latest',
            'koji_upload_dir': 'upload',
        }
        if scratch:
            additional_params['scratch'] = True
        params, build_json = self.get_worker_build_request(
            osbs, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        if scratch:
            with pytest.raises(NoSuchPluginException):
                get_plugin(plugins, 'postbuild_plugins', 'koji_upload')
            return

        args = plugin_value_get(plugins, 'postbuild_plugins', 'koji_upload',
                                'args')

        match_args = {
            'blocksize': 10485760,
            'build_json_dir': 'inputs',
            'koji_keytab': False,
            'koji_principal': False,
            'koji_upload_dir': 'upload',
            'kojihub': 'http://koji.example.com/kojihub',
            'url': '/',
            'use_auth': False,
            'verify_ssl': False
        }
        assert match_args == args
Example #7
0
    def test_koji_import(self, osbs, scratch):
        additional_params = {
            'base_image': 'fedora:latest',
            'koji_upload_dir': 'upload',
        }
        if scratch:
            additional_params['scratch'] = True
        params, build_json = self.get_orchestrator_build_request(
            osbs, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        if scratch:
            with pytest.raises(NoSuchPluginException):
                get_plugin(plugins, 'exit_plugins', 'koji_import')
            return

        args = plugin_value_get(plugins, 'exit_plugins', 'koji_import', 'args')

        match_args = {
            'koji_keytab': False,
            'kojihub': 'http://koji.example.com/kojihub',
            'url': '/',
            'use_auth': False,
            'verify_ssl': False
        }
        assert match_args == args
    def test_koji_upload(self, osbs, scratch):
        additional_params = {
            'base_image': 'fedora:latest',
            'koji_upload_dir': 'upload',
        }
        if scratch:
            additional_params['scratch'] = True
        params, build_json = self.get_worker_build_request(osbs, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        if scratch:
            with pytest.raises(NoSuchPluginException):
                get_plugin(plugins, 'postbuild_plugins', 'koji_upload')
            return

        args = plugin_value_get(plugins, 'postbuild_plugins',
                                         'koji_upload', 'args')

        match_args = {
            'blocksize': 10485760,
            'build_json_dir': 'inputs',
            'koji_keytab': False,
            'koji_principal': False,
            'koji_upload_dir': 'upload',
            'kojihub': 'http://koji.example.com/kojihub',
            'url': '/',
            'use_auth': False,
            'verify_ssl': False,
            'platform': 'x86_64',
        }
        assert match_args == args
    def test_pull_base_image(self, osbs, build_type, scratch,
                             base_image, expect_plugin):
        phase = 'prebuild_plugins'
        plugin = 'pull_base_image'
        additional_params = {
            'base_image': base_image,
        }
        if scratch:
            additional_params['scratch'] = True

        (params, build_json) = self.get_build_request(build_type,
                                                      osbs,
                                                      additional_params)
        plugins = get_plugins_from_build_json(build_json)

        if not expect_plugin:
            with pytest.raises(NoSuchPluginException):
                get_plugin(plugins, phase, plugin)
        else:
            args = plugin_value_get(plugins, phase, plugin, 'args')

            allowed_args = set([
                'parent_registry',
                'parent_registry_insecure',
            ])
            assert set(args.keys()) <= allowed_args
Example #10
0
    def test_add_filesystem_in_worker(self, osbs, base_image, scratch,
                                      expect_plugin):
        additional_params = {
            'base_image': base_image,
            'yum_repourls': ['https://example.com/my.repo'],
        }
        if scratch:
            additional_params['scratch'] = True
        params, build_json = self.get_worker_build_request(osbs,
                                                           additional_params)
        plugins = get_plugins_from_build_json(build_json)

        if not expect_plugin:
            with pytest.raises(NoSuchPluginException):
                get_plugin(plugins, 'prebuild_plugins', 'add_filesystem')
        else:
            args = plugin_value_get(plugins, 'prebuild_plugins',
                                    'add_filesystem', 'args')
            allowed_args = set([
                'koji_hub',
                'repos',
                'from_task_id',
            ])
            assert set(args.keys()) <= allowed_args
            assert 'koji_hub' in args
            assert args['repos'] == params['yum_repourls']
            assert args['from_task_id'] == params['filesystem_koji_task_id']
Example #11
0
    def test_tag_from_config(self, osbs, params, build_type, has_plat_tag,
                             has_primary_tag):
        additional_params = {
            'base_image': 'fedora:latest',
        }
        additional_params.update(params)
        _, build_json = self.get_build_request(build_type, osbs,
                                               additional_params)
        plugins = get_plugins_from_build_json(build_json)

        args = plugin_value_get(plugins, 'postbuild_plugins',
                                'tag_from_config', 'args')

        assert set(args.keys()) == set(['tag_suffixes'])
        assert set(args['tag_suffixes'].keys()) == set(['unique', 'primary'])

        unique_tags = args['tag_suffixes']['unique']
        assert len(unique_tags) == 1
        unique_tag_suffix = ''
        if has_plat_tag:
            unique_tag_suffix = '-' + additional_params.get('platform')
        assert unique_tags[0].endswith(unique_tag_suffix)

        primary_tags = args['tag_suffixes']['primary']
        if has_primary_tag:
            assert set(primary_tags) == set(
                ['latest', '{version}', '{version}-{release}'])
Example #12
0
    def test_pulp_push(self, openshift):  # noqa:F811
        platform_descriptors = {'x86_64': {'enable_v1': True}}
        osbs_api = osbs_with_pulp(openshift,
                                  platform_descriptors=platform_descriptors)
        additional_params = {
            'base_image': 'fedora:latest',
        }
        _, build_json = self.get_worker_build_request(osbs_api,
                                                      additional_params)
        plugins = get_plugins_from_build_json(build_json)

        args = plugin_value_get(plugins, 'postbuild_plugins', 'pulp_push',
                                'args')

        build_conf = osbs_api.build_conf
        # Use first docker registry and strip off /v2
        pulp_registry_name = build_conf.get_pulp_registry()
        pulp_secret_path = '/'.join(
            [SECRETS_PATH, build_conf.get_pulp_secret()])

        expected_args = {
            'pulp_registry_name': pulp_registry_name,
            'pulp_secret_path': pulp_secret_path,
            'load_exported_image': True,
            'dockpulp_loglevel': 'INFO',
            'publish': False
        }

        assert args == expected_args
Example #13
0
    def test_pulp_sync(self, osbs_with_pulp):  # noqa:F811
        additional_params = {
            'base_image': 'fedora:latest',
        }
        _, build_json = self.get_orchestrator_build_request(
            osbs_with_pulp, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        args = plugin_value_get(plugins, 'postbuild_plugins', 'pulp_sync',
                                'args')

        build_conf = osbs_with_pulp.build_conf
        docker_registry = self.get_pulp_sync_registry(build_conf)
        pulp_registry_name = build_conf.get_pulp_registry()
        pulp_secret_path = '/'.join(
            [SECRETS_PATH, build_conf.get_pulp_secret()])
        expected_args = {
            'docker_registry': docker_registry,
            'pulp_registry_name': pulp_registry_name,
            'pulp_secret_path': pulp_secret_path,
            'dockpulp_loglevel': 'INFO',
            'publish': False
        }

        assert args == expected_args
    def test_group_manifests(self, openshift, group):
        platform_descriptors = {'x86_64': {'architecture': 'amd64'}}
        osbs_api = osbs_with_pulp(openshift,
                                  platform_descriptors=platform_descriptors,
                                  group_manifests=group)
        additional_params = {
            'base_image': 'fedora:latest',
        }
        _, build_json = self.get_orchestrator_build_request(
            osbs_api, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        args = plugin_value_get(plugins, 'postbuild_plugins',
                                'group_manifests', 'args')
        docker_registry = self.get_pulp_sync_registry(osbs_api.build_conf)

        expected_args = {
            'goarch': {
                'x86_64': 'amd64'
            },
            'group': group,
            'registries': {
                docker_registry: {
                    'insecure': True,
                    'version': 'v2'
                }
            }
        }
        assert args == expected_args
Example #15
0
    def test_check_and_set_rebuild(self, tmpdir, osbs, triggers):

        imagechange = [
            {
                "type": "ImageChange",
                "imageChange": {
                    "from": {
                        "kind": "ImageStreamTag",
                        "name": "{{BASE_IMAGE_STREAM}}"
                    }
                }
            }
        ]

        if triggers:
            orch_outer_temp = ORCHESTRATOR_INNER_TEMPLATE.format(
                arrangement_version=self.ARRANGEMENT_VERSION
            )
            for basename in [ORCHESTRATOR_OUTER_TEMPLATE, orch_outer_temp]:
                shutil.copy(os.path.join(INPUTS_PATH, basename),
                            os.path.join(str(tmpdir), basename))

            with open(os.path.join(str(tmpdir), ORCHESTRATOR_OUTER_TEMPLATE), 'r+') as orch_json:
                build_json = json.load(orch_json)
                build_json['spec']['triggers'] = imagechange

                orch_json.seek(0)
                json.dump(build_json, orch_json)
                orch_json.truncate()

            flexmock(osbs.os_conf, get_build_json_store=lambda: str(tmpdir))
            (flexmock(BuildRequest)
                .should_receive('adjust_for_repo_info')
                .and_return(True))

        additional_params = {
            'base_image': 'fedora:latest',
        }
        params, build_json = self.get_orchestrator_build_request(osbs, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        if not triggers:
            with pytest.raises(NoSuchPluginException):
                get_plugin(plugins, 'prebuild_plugins', 'check_and_set_rebuild')
            return

        args = plugin_value_get(plugins, 'prebuild_plugins',
                                         'check_and_set_rebuild', 'args')

        match_args = {
            "label_key": "is_autorebuild",
            "label_value": "true",
            "url": "/",
            "verify_ssl": False,
            'use_auth': False,
        }
        assert match_args == args
Example #16
0
    def test_check_and_set_rebuild(self, tmpdir, osbs, triggers):

        imagechange = [{
            "type": "ImageChange",
            "imageChange": {
                "from": {
                    "kind": "ImageStreamTag",
                    "name": "{{BASE_IMAGE_STREAM}}"
                }
            }
        }]

        if triggers:
            orch_outer_temp = ORCHESTRATOR_INNER_TEMPLATE.format(
                arrangement_version=self.ARRANGEMENT_VERSION)
            for basename in [ORCHESTRATOR_OUTER_TEMPLATE, orch_outer_temp]:
                shutil.copy(os.path.join(INPUTS_PATH, basename),
                            os.path.join(str(tmpdir), basename))

            with open(os.path.join(str(tmpdir), ORCHESTRATOR_OUTER_TEMPLATE),
                      'r+') as orch_json:
                build_json = json.load(orch_json)
                build_json['spec']['triggers'] = imagechange

                orch_json.seek(0)
                json.dump(build_json, orch_json)
                orch_json.truncate()

            flexmock(osbs.os_conf, get_build_json_store=lambda: str(tmpdir))
            (flexmock(BuildRequest).should_receive(
                'adjust_for_repo_info').and_return(True))

        additional_params = {
            'base_image': 'fedora:latest',
        }
        params, build_json = self.get_orchestrator_build_request(
            osbs, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        if not triggers:
            with pytest.raises(NoSuchPluginException):
                get_plugin(plugins, 'prebuild_plugins',
                           'check_and_set_rebuild')
            return

        args = plugin_value_get(plugins, 'prebuild_plugins',
                                'check_and_set_rebuild', 'args')

        match_args = {
            "label_key": "is_autorebuild",
            "label_value": "true",
            "url": "/",
            "verify_ssl": False,
            'use_auth': False,
        }
        assert match_args == args
Example #17
0
    def test_pulp_pull(self, osbs_with_pulp):  # noqa:F811
        additional_params = {
            'base_image': 'fedora:latest',
        }
        _, build_json = self.get_orchestrator_build_request(osbs_with_pulp, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        args = plugin_value_get(plugins, 'exit_plugins', 'pulp_pull', 'args')
        expected_args = {'insecure': True}
        assert args == expected_args
Example #18
0
    def test_pulp_pull(self, osbs_with_pulp):  # noqa:F811
        additional_params = {
            'base_image': 'fedora:latest',
        }
        _, build_json = self.get_orchestrator_build_request(
            osbs_with_pulp, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        args = plugin_value_get(plugins, 'exit_plugins', 'pulp_pull', 'args')
        expected_args = {'insecure': True}
        assert args == expected_args
Example #19
0
    def test_pulp_tag(self, osbs_with_pulp):  # noqa:F811
        additional_params = {
            'base_image': 'fedora:latest',
        }
        _, build_json = self.get_orchestrator_build_request(
            osbs_with_pulp, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        args = plugin_value_get(plugins, 'postbuild_plugins', 'pulp_tag',
                                'args')

        assert args == {}
Example #20
0
    def test_inject_parent_image(self, osbs, build_type):
        additional_params = {
            'base_image': 'foo',
            'koji_parent_build': 'fedora-26-9',
        }
        _, build_json = self.get_build_request(build_type, osbs, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        args = plugin_value_get(plugins, 'prebuild_plugins', 'inject_parent_image', 'args')
        expected_args = {
            'koji_parent_build': 'fedora-26-9',
            'koji_hub': osbs.build_conf.get_kojihub()
        }
        assert args == expected_args
Example #21
0
    def test_delete_from_registry(self, osbs_with_pulp, base_image, scratch):
        phase = 'exit_plugins'
        plugin = 'delete_from_registry'
        additional_params = {
            'base_image': base_image,
        }
        if scratch:
            additional_params['scratch'] = True

        _, build_json = self.get_orchestrator_build_request(osbs_with_pulp, additional_params)
        plugins = get_plugins_from_build_json(build_json)
        args = plugin_value_get(plugins, phase, plugin, 'args')

        docker_registry = self.get_pulp_sync_registry(osbs_with_pulp.build_conf)
        assert args == {'registries': {docker_registry: {'insecure': True}}}
Example #22
0
    def test_inject_parent_image(self, osbs, build_type):
        additional_params = {
            'base_image': 'foo',
            'koji_parent_build': 'fedora-26-9',
        }
        _, build_json = self.get_build_request(build_type, osbs,
                                               additional_params)
        plugins = get_plugins_from_build_json(build_json)

        args = plugin_value_get(plugins, 'prebuild_plugins',
                                'inject_parent_image', 'args')
        expected_args = {
            'koji_parent_build': 'fedora-26-9',
            'koji_hub': osbs.build_conf.get_kojihub()
        }
        assert args == expected_args
Example #23
0
    def test_delete_from_registry(self, osbs_with_pulp, base_image, scratch):
        phase = 'exit_plugins'
        plugin = 'delete_from_registry'
        additional_params = {
            'base_image': base_image,
        }
        if scratch:
            additional_params['scratch'] = True

        _, build_json = self.get_orchestrator_build_request(
            osbs_with_pulp, additional_params)
        plugins = get_plugins_from_build_json(build_json)
        args = plugin_value_get(plugins, phase, plugin, 'args')

        docker_registry = self.get_pulp_sync_registry(
            osbs_with_pulp.build_conf)
        assert args == {'registries': {docker_registry: {'insecure': True}}}
Example #24
0
    def test_delete_from_registry(self, osbs_with_pulp, base_image, scratch):
        phase = 'exit_plugins'
        plugin = 'delete_from_registry'
        additional_params = {
            'base_image': base_image,
        }
        if scratch:
            additional_params['scratch'] = True

        (params, build_json) = self.get_build_request('worker', osbs_with_pulp,
                                                      additional_params)
        plugins = get_plugins_from_build_json(build_json)
        args = plugin_value_get(plugins, phase, plugin, 'args')
        allowed_args = set([
            'registries',
        ])
        assert set(args.keys()) <= allowed_args
Example #25
0
    def test_delete_from_registry(self, osbs_with_pulp, base_image, scratch):
        phase = 'exit_plugins'
        plugin = 'delete_from_registry'
        additional_params = {
            'base_image': base_image,
        }
        if scratch:
            additional_params['scratch'] = True

        (params, build_json) = self.get_build_request('worker',
                                                      osbs_with_pulp,
                                                      additional_params)
        plugins = get_plugins_from_build_json(build_json)
        args = plugin_value_get(plugins, phase, plugin, 'args')
        allowed_args = set([
            'registries',
        ])
        assert set(args.keys()) <= allowed_args
Example #26
0
    def test_group_manifests(self, openshift, group):
        platform_descriptors = {'x86_64': {'architecture': 'amd64'}}
        osbs_api = osbs_with_pulp(openshift, platform_descriptors=platform_descriptors,
                                  group_manifests=group)
        additional_params = {
            'base_image': 'fedora:latest',
        }
        _, build_json = self.get_orchestrator_build_request(osbs_api, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        args = plugin_value_get(plugins, 'postbuild_plugins', 'group_manifests', 'args')
        docker_registry = self.get_pulp_sync_registry(osbs_api.build_conf)

        expected_args = {
            'goarch': {'x86_64': 'amd64'},
            'group': group,
            'registries': {docker_registry: {'insecure': True, 'version': 'v2'}}
        }
        assert args == expected_args
Example #27
0
    def test_fetch_worker_metadata(self, osbs, scratch):
        additional_params = {
            'base_image': 'fedora:latest',
        }
        if scratch:
            additional_params['scratch'] = True
        params, build_json = self.get_orchestrator_build_request(osbs, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        if scratch:
            with pytest.raises(NoSuchPluginException):
                get_plugin(plugins, 'postbuild_plugins', 'fetch_worker_metadata')
            return

        args = plugin_value_get(plugins, 'postbuild_plugins',
                                         'fetch_worker_metadata', 'args')

        match_args = {}
        assert match_args == args
Example #28
0
    def test_pulp_publish(self, osbs_with_pulp):  # noqa:F811
        additional_params = {
            'base_image': 'fedora:latest',
        }
        _, build_json = self.get_orchestrator_build_request(osbs_with_pulp, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        args = plugin_value_get(plugins, 'exit_plugins', 'pulp_publish', 'args')
        build_conf = osbs_with_pulp.build_conf
        pulp_registry_name = build_conf.get_pulp_registry()
        pulp_secret_path = '/'.join([SECRETS_PATH, build_conf.get_pulp_secret()])

        expected_args = {
            'pulp_registry_name': pulp_registry_name,
            'pulp_secret_path': pulp_secret_path,
            'dockpulp_loglevel': 'INFO',
        }

        assert args == expected_args
    def test_koji_upload(self, osbs, osbs_with_pulp, scratch, use_pulp):
        additional_params = {
            'base_image': 'fedora:latest',
            'koji_upload_dir': 'upload',
        }
        if scratch:
            additional_params['scratch'] = True

        if use_pulp:
            client = osbs_with_pulp
        else:
            client = osbs

        params, build_json = self.get_worker_build_request(
            client, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        if scratch:
            with pytest.raises(NoSuchPluginException):
                get_plugin(plugins, 'postbuild_plugins', 'koji_upload')
            return

        args = plugin_value_get(plugins, 'postbuild_plugins', 'koji_upload',
                                'args')

        match_args = {
            'blocksize': 10485760,
            'build_json_dir': 'inputs',
            'koji_keytab': False,
            'koji_principal': False,
            'koji_upload_dir': 'upload',
            'kojihub': 'http://koji.example.com/kojihub',
            'url': '/',
            'use_auth': False,
            'verify_ssl': False,
            'platform': 'x86_64',
        }

        if use_pulp:
            match_args['report_multiple_digests'] = True

        assert match_args == args
Example #30
0
    def test_import_image_renders(self, osbs):  # noqa:F811
        additional_params = {
            'base_image': 'fedora:latest',
        }
        params, build_json = self.get_orchestrator_build_request(
            osbs, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        args = plugin_value_get(plugins, 'postbuild_plugins', 'import_image',
                                'args')

        match_args = {
            "imagestream": "fedora23-something",
            "docker_image_repo": "registry.example.com/fedora23/something",
            "url": "/",
            "verify_ssl": False,
            "build_json_dir": "inputs",
            "use_auth": False
        }
        assert match_args == args
Example #31
0
    def test_fetch_worker_metadata(self, osbs, scratch):
        additional_params = {
            'base_image': 'fedora:latest',
        }
        if scratch:
            additional_params['scratch'] = True
        params, build_json = self.get_orchestrator_build_request(
            osbs, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        if scratch:
            with pytest.raises(NoSuchPluginException):
                get_plugin(plugins, 'postbuild_plugins',
                           'fetch_worker_metadata')
            return

        args = plugin_value_get(plugins, 'postbuild_plugins',
                                'fetch_worker_metadata', 'args')

        match_args = {}
        assert match_args == args
Example #32
0
    def test_koji_parent_in_orchestrator(self, osbs, base_image, scratch,
                                         expect_plugin):
        additional_params = {
            'base_image': base_image,
        }
        if scratch:
            additional_params['scratch'] = True
        params, build_json = self.get_orchestrator_build_request(osbs, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        if not expect_plugin:
            with pytest.raises(NoSuchPluginException):
                get_plugin(plugins, 'prebuild_plugins', 'koji_parent')
        else:
            args = plugin_value_get(plugins, 'prebuild_plugins',
                                    'koji_parent', 'args')
            allowed_args = set([
                'koji_hub',
            ])
            assert set(args.keys()) <= allowed_args
            assert 'koji_hub' in args
Example #33
0
    def test_group_manifests(self, openshift):  # noqa:F811
        platform_descriptors = {'x86_64': {'architecture': 'amd64'}}
        osbs_api = osbs_with_pulp(openshift,
                                  platform_descriptors=platform_descriptors)
        additional_params = {
            'base_image': 'fedora:latest',
        }
        _, build_json = self.get_orchestrator_build_request(
            osbs_api, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        args = plugin_value_get(plugins, 'postbuild_plugins',
                                'group_manifests', 'args')
        expected_args = {
            'goarch': {
                'x86_64': 'amd64'
            },
            'group': False,
            'pulp_registry_name': osbs_api.build_conf.get_pulp_registry()
        }
        assert args == expected_args
Example #34
0
    def test_koji_parent_in_orchestrator(self, osbs, base_image, scratch,
                                         expect_plugin):
        additional_params = {
            'base_image': base_image,
        }
        if scratch:
            additional_params['scratch'] = True
        params, build_json = self.get_orchestrator_build_request(
            osbs, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        if not expect_plugin:
            with pytest.raises(NoSuchPluginException):
                get_plugin(plugins, 'prebuild_plugins', 'koji_parent')
        else:
            args = plugin_value_get(plugins, 'prebuild_plugins', 'koji_parent',
                                    'args')
            allowed_args = set([
                'koji_hub',
            ])
            assert set(args.keys()) <= allowed_args
            assert 'koji_hub' in args
Example #35
0
    def test_tag_from_config(self, osbs, params, build_type, has_plat_tag, has_primary_tag):
        additional_params = {
            'base_image': 'fedora:latest',
        }
        additional_params.update(params)
        _, build_json = self.get_build_request(build_type, osbs, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        args = plugin_value_get(plugins, 'postbuild_plugins', 'tag_from_config', 'args')

        assert set(args.keys()) == set(['tag_suffixes'])
        assert set(args['tag_suffixes'].keys()) == set(['unique', 'primary'])

        unique_tags = args['tag_suffixes']['unique']
        assert len(unique_tags) == 1
        unique_tag_suffix = ''
        if has_plat_tag:
            unique_tag_suffix = '-' + additional_params.get('platform')
        assert unique_tags[0].endswith(unique_tag_suffix)

        primary_tags = args['tag_suffixes']['primary']
        if has_primary_tag:
            assert set(primary_tags) == set(['latest', '{version}', '{version}-{release}'])
    def test_resolve_composes(self, osbs):  # noqa:F811
        koji_target = 'koji-target'

        # These are hard coded by osbs fixture
        koji_hub = 'http://koji.example.com/kojihub'
        odcs_url = 'https://odcs.example.com/odcs/1'

        additional_params = {
            'base_image': 'fedora:latest',
            'target': koji_target,
        }
        _, build_json = self.get_orchestrator_build_request(
            osbs, additional_params)
        plugins = get_plugins_from_build_json(build_json)

        args = plugin_value_get(plugins, 'prebuild_plugins',
                                'resolve_composes', 'args')

        assert args == {
            'koji_hub': koji_hub,
            'koji_target': koji_target,
            'odcs_url': odcs_url,
            'odcs_insecure': False,
        }