Skip to content

Commit

Permalink
allow isolated flatpaks
Browse files Browse the repository at this point in the history
* CLOUDBLD-7764

Signed-off-by: Robert Cerven <[email protected]>
  • Loading branch information
rcerven committed Nov 11, 2021
1 parent 707ad3c commit eaced95
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 29 deletions.
8 changes: 0 additions & 8 deletions osbs/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,14 +744,6 @@ def _do_create_prod_build(self,
if missing_params:
raise OsbsException('required parameter {} missing'.format(", ".join(missing_params)))

if flatpak:
if isolated:
# Flatpak builds from a particular stream autogenerate the release
# as <module_version>.<n>; it doesn't make sense to make a fix
# from specific one of these autogenerated version. What an isolated
# fix for module requires will have to be determined from experience.
raise ValueError("Flatpak build cannot be isolated")

if not git_branch:
raise OsbsValidationException("required argument 'git_branch' can't be None")

Expand Down
2 changes: 1 addition & 1 deletion osbs/build/plugins_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def render_bump_release(self):
# For flatpak, we want a name-version-release of
# <name>-<stream>-<module_build_version>.<n>, where the .<n> makes
# sure that the build is unique in Koji
if self.user_params.flatpak:
if self.user_params.flatpak and not self.user_params.isolated:
self.pt.set_plugin_arg(phase, plugin, 'append', True)

def render_check_and_set_platforms(self):
Expand Down
14 changes: 11 additions & 3 deletions tests/build_/test_plugins_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ def check_plugin_presence(self, build_type, plugins, invited_plugins, uninvited_
with pytest.raises(NoSuchPluginException):
get_plugin(plugins, phase, plugin)

@pytest.mark.parametrize(('release', 'isolated'),
[(None, False),
('1.0', True)])
@pytest.mark.parametrize('build_type', (BUILD_TYPE_ORCHESTRATOR, BUILD_TYPE_WORKER))
@pytest.mark.parametrize(('compose_ids', 'signing_intent'),
[(None, None),
Expand All @@ -299,13 +302,15 @@ def check_plugin_presence(self, build_type, plugins, invited_plugins, uninvited_
([], 'release'),
([42], None),
([42, 2], None)])
def test_render_flatpak(self, compose_ids, signing_intent, build_type):
def test_render_flatpak(self, release, isolated, compose_ids, signing_intent, build_type):
extra_args = {
'flatpak': True,
'isolated': isolated,
'compose_ids': compose_ids,
'signing_intent': signing_intent,
'base_image': TEST_FLATPAK_BASE_IMAGE,
'build_type': build_type,
'release': release,
}

user_params = get_sample_user_params(extra_args=extra_args)
Expand Down Expand Up @@ -343,8 +348,11 @@ def test_render_flatpak(self, compose_ids, signing_intent, build_type):
plugin = get_plugin(plugins, "prebuild_plugins", "bump_release")
assert plugin

args = plugin['args']
assert args['append'] is True
if isolated:
assert 'args' not in plugin
else:
args = plugin['args']
assert args['append'] is True
else:
plugin = get_plugin(plugins, "prebuild_plugins", "koji")
assert plugin
Expand Down
43 changes: 26 additions & 17 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2601,15 +2601,15 @@ def __init__(self, isolated):
self.git_branch = TEST_GIT_BRANCH
self.koji_parent_build = None
self.flatpak = True
self.signing_intent = 'release'
self.signing_intent = None
self.compose_ids = [1, 2]
self.skip_build = False
self.operator_csv_modifications_url = None

expected_kwargs = {
'platform': None,
'scratch': None,
'isolated': False,
'isolated': isolated,
'platforms': 'platforms',
'release': None,
'flatpak': True,
Expand All @@ -2623,38 +2623,47 @@ def __init__(self, isolated):
'yum_repourls': None,
'dependency_replacements': None,
'koji_parent_build': None,
'signing_intent': 'release',
'signing_intent': None,
'compose_ids': [1, 2],
'skip_build': False,
'operator_csv_modifications_url': None,
}

(flexmock(utils)
.should_receive('get_repo_info')
.with_args(TEST_GIT_URI, TEST_GIT_REF, git_branch=TEST_GIT_BRANCH, depth=None)
.and_return(self.mock_repo_info(mock_config=MockConfiguration(modules=TEST_MODULES))))
.with_args(None, None, git_branch=TEST_GIT_BRANCH, depth=None)
.and_return(self.mock_repo_info(mock_config=MockConfiguration(modules=TEST_MODULES,
is_flatpak=True))))

args = MockArgs(isolated)
# Some of the command line arguments are pulled through the config
# object, so add them there as well.
osbs.build_conf.args = args
flexmock(osbs.build_conf, get_git_branch=lambda: TEST_GIT_BRANCH)

if not isolated:
# and_raise is called to prevent cmd_build to continue
# as we only want to check if arguments are correct
(flexmock(osbs)
.should_call("create_orchestrator_build")
.once()
.with_args(**expected_kwargs))

exc_msg = "stop for test"
# and_raise is called to prevent cmd_build to continue
# as we only want to check if arguments are correct
if isolated:
(flexmock(osbs)
.should_receive("create_orchestrator_build")
.should_receive("_create_isolated_build")
.once()
.with_args(**expected_kwargs)
.and_raise(CustomTestException))
with pytest.raises(CustomTestException):
cmd_build(args, osbs)
.and_raise(CustomTestException(exc_msg)))
else:
with pytest.raises(OsbsException) as exc_info:
cmd_build(args, osbs)
assert isinstance(exc_info.value.cause, ValueError)
assert "Flatpak build cannot be isolated" in exc_info.value.message
(flexmock(osbs)
.should_receive("_create_build_config_and_build")
.once()
.and_raise(CustomTestException(exc_msg)))

with pytest.raises(OsbsException) as exc:
cmd_build(args, osbs)

assert exc_msg in str(exc.value)

@pytest.mark.parametrize('isolated', [True, False])
def test_operator_csv_modifications_url_cli(self, osbs, isolated):
Expand Down

0 comments on commit eaced95

Please sign in to comment.