Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make binary image argument optional [CLODDST-2762] #14

Merged
merged 1 commit into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pubtools/iib/iib_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
("--binary-image",): {
"group": "IIB service",
"help": "<hostname>/<namespace>/<image>:<tag> of binary image",
"required": True,
"required": False,
"type": str,
},
("--arch",): {
Expand Down Expand Up @@ -220,6 +220,9 @@ def _iib_op_main(args, operation=None, items_final_state="PUSHED"):
if args.iib_legacy_org:
extra_args["organization"] = args.iib_legacy_org

if args.binary_image:
extra_args["binary_image"] = args.binary_image

if args.overwrite_from_index:
extra_args["overwrite_from_index"] = args.overwrite_from_index

Expand All @@ -228,7 +231,6 @@ def _iib_op_main(args, operation=None, items_final_state="PUSHED"):

build_details = bundle_op(
args.index_image,
args.binary_image,
args.bundle if operation == "add_bundles" else args.operator,
args.arch,
**extra_args
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
six
setuptools
pyrsistent<=0.16.0; python_version == '2.7'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this one is not used. Is it a dependency of something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a pushcollector dependency. It seems that new version was released which is not Python 2 compatible, which causes the Python 2 tests initialization to fail. This line constraints the version for Python 2 tests.

pushcollector
pubtools-pulp
iiblib>=0.9.0
Expand Down
6 changes: 3 additions & 3 deletions tests/fake_task_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ def _gen_task_id(self):
def setup_task(
self,
index,
binary,
map_or_op,
arches,
binary_image="binary-image",
state_seq=("in_progress", "finished"),
op_type="add",
):
Expand All @@ -28,8 +28,8 @@ def setup_task(
"from_index": index,
"from_index_resolved": index + "-resolved",
"bundles": map_or_op,
"binary_image": binary,
"binary_image_resolved": binary + "-resolved",
"binary_image": binary_image,
"binary_image_resolved": binary_image + "-resolved",
"index_image": "index_image",
"arches": arches,
}
Expand Down
64 changes: 40 additions & 24 deletions tests/test_iib_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,21 @@ def setup_entry_point_py(entry_tuple, environ_vars):
@pytest.fixture
def fixture_iib_client():
with mock.patch("iiblib.iibclient.IIBClient") as iibc_patched:
iibc_patched.return_value.add_bundles.side_effect = lambda *args, **kwargs: IIBBuildDetailsModel.from_dict(
fake_tm.setup_task(*args, **kwargs)
iibc_patched.return_value.add_bundles.side_effect = (
lambda *args, **kwargs: IIBBuildDetailsModel.from_dict(
fake_tm.setup_task(*args, **kwargs)
)
)
iibc_patched.return_value.remove_operators.side_effect = lambda *args, **kwargs: IIBBuildDetailsModel.from_dict(
fake_tm.setup_task(*args, **kwargs)
iibc_patched.return_value.remove_operators.side_effect = (
lambda *args, **kwargs: IIBBuildDetailsModel.from_dict(
fake_tm.setup_task(*args, **kwargs)
)
)
iibc_patched.return_value.get_build.side_effect = fake_tm.get_task
iibc_patched.return_value.wait_for_build.side_effect = lambda build_details: IIBBuildDetailsModel.from_dict(
fake_tm.get_task(build_details.id)
iibc_patched.return_value.wait_for_build.side_effect = (
lambda build_details: IIBBuildDetailsModel.from_dict(
fake_tm.get_task(build_details.id)
)
)
yield iibc_patched

Expand Down Expand Up @@ -157,11 +163,11 @@ def add_bundles_mock_calls_tester(
):
fixture_iib_client.return_value.add_bundles.assert_called_once_with(
"index-image",
"binary-image",
["bundle1"],
["arch"],
cnr_token="cnr_token",
organization="legacy-org",
binary_image="binary-image",
overwrite_from_index=True,
overwrite_from_index_token="overwrite_from_index_token",
)
Expand All @@ -181,11 +187,11 @@ def add_bundles_mock_calls_tester_not_called(
):
fixture_iib_client.return_value.add_bundles.assert_called_once_with(
"index-image",
"binary-image",
["bundle1"],
["arch"],
cnr_token="cnr_token",
organization="legacy-org",
binary_image="binary-image",
overwrite_from_index=True,
overwrite_from_index_token="overwrite_from_index_token",
)
Expand All @@ -207,9 +213,9 @@ def remove_operators_mock_calls_tester_not_called(
)
fixture_iib_client.return_value.remove_operators.assert_called_once_with(
"index-image",
"binary-image",
["1"],
["arch"],
binary_image="binary-image",
overwrite_from_index=True,
overwrite_from_index_token="overwrite_from_index_token",
)
Expand All @@ -228,9 +234,9 @@ def remove_operators_mock_calls_tester(
)
fixture_iib_client.return_value.remove_operators.assert_called_once_with(
"index-image",
"binary-image",
["1"],
["arch"],
binary_image="binary-image",
overwrite_from_index=True,
overwrite_from_index_token="overwrite_from_index_token",
)
Expand Down Expand Up @@ -309,10 +315,14 @@ def test_add_bundles_cli_error(
repo = fixture_container_image_repo
fixture_pulp_client.return_value.search_repository.return_value = [repo]
fixture_pulp_client.return_value.get_repository.return_value = repo
fixture_iib_client.return_value.add_bundles.side_effect = lambda *args, **kwargs: IIBBuildDetailsModel.from_dict(
fake_tm.setup_task(
*args,
**dict(list(kwargs.items()) + [("state_seq", ("in_progress", "failed"))])
fixture_iib_client.return_value.add_bundles.side_effect = (
lambda *args, **kwargs: IIBBuildDetailsModel.from_dict(
fake_tm.setup_task(
*args,
**dict(
list(kwargs.items()) + [("state_seq", ("in_progress", "failed"))]
)
)
)
)

Expand Down Expand Up @@ -369,10 +379,10 @@ def test_add_bundles_py(
)
fixture_iib_client.return_value.add_bundles.assert_called_once_with(
"index-image",
"binary-image",
["bundle1"],
["arch"],
cnr_token="cnr_token",
binary_image="binary-image",
overwrite_from_index=True,
overwrite_from_index_token="overwrite_from_index_token",
)
Expand Down Expand Up @@ -416,10 +426,10 @@ def test_add_bundles_py_multiple_bundles(
)
fixture_iib_client.return_value.add_bundles.assert_called_once_with(
"index-image",
"binary-image",
["bundle1", "bundle2"],
["arch"],
cnr_token="cnr_token",
binary_image="binary-image",
overwrite_from_index=True,
overwrite_from_index_token="overwrite_from_index_token",
)
Expand Down Expand Up @@ -461,8 +471,12 @@ def test_remove_operators_cli(
repo = fixture_container_image_repo
fixture_pulp_client.return_value.search_repository.return_value = [repo]
fixture_pulp_client.return_value.get_repository.return_value = repo
fixture_iib_client.return_value.remove_operators.side_effect = lambda *args, **kwargs: IIBBuildDetailsModel.from_dict(
fake_tm.setup_task(*args, **dict(list(kwargs.items()) + [("op_type", "rm")]))
fixture_iib_client.return_value.remove_operators.side_effect = (
lambda *args, **kwargs: IIBBuildDetailsModel.from_dict(
fake_tm.setup_task(
*args, **dict(list(kwargs.items()) + [("op_type", "rm")])
)
)
)
with setup_entry_point_cli(
("pubtools_iib", "console_scripts", "pubtools-iib-remove-operators"),
Expand Down Expand Up @@ -497,12 +511,14 @@ def test_remove_operators_cli_error(
repo = fixture_container_image_repo
fixture_pulp_client.return_value.search_repository.return_value = [repo]
fixture_pulp_client.return_value.get_repository.return_value = repo
fixture_iib_client.return_value.remove_operators.side_effect = lambda *args, **kwargs: IIBBuildDetailsModel.from_dict(
fake_tm.setup_task(
*args,
**dict(
list(kwargs.items())
+ [("state_seq", ("in_progress", "failed")), ("op_type", "rm")]
fixture_iib_client.return_value.remove_operators.side_effect = (
lambda *args, **kwargs: IIBBuildDetailsModel.from_dict(
fake_tm.setup_task(
*args,
**dict(
list(kwargs.items())
+ [("state_seq", ("in_progress", "failed")), ("op_type", "rm")]
)
)
)
)
Expand Down
6 changes: 3 additions & 3 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def _gen_task_id(self):
def setup_task(
self,
index,
binary,
map_or_op,
arches,
binary_image="binary-image",
cnr_token=None,
organization=None,
overwrite_from_index=False,
Expand All @@ -34,8 +34,8 @@ def setup_task(
"state_history": [],
"from_index": index,
"from_index_resolved": index + "-resolved",
"binary_image": binary,
"binary_image_resolved": binary + "-resolved",
"binary_image": binary_image,
"binary_image_resolved": binary_image + "-resolved",
"bundle_mapping": {},
"index_image": "feed.com/index/image:tag",
"arches": arches,
Expand Down