Skip to content

Commit

Permalink
Merge 8f387b1 into c5188da
Browse files Browse the repository at this point in the history
  • Loading branch information
midnightercz committed Feb 26, 2020
2 parents c5188da + 8f387b1 commit d35637f
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 16 deletions.
23 changes: 18 additions & 5 deletions pubtools/iib/iib_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
}


def push_items_from_build(build_details, state):
def push_items_from_build(build_details, state, pulp_repository):
ret = []
operators = build_details.operators
bundles = (
Expand All @@ -103,7 +103,16 @@ def push_items_from_build(build_details, state):
)

for operator, bundle in zip(operators, bundles):
item = {"state": state, "origin": bundle, "filename": operator}
item = {
"state": state,
"origin": bundle,
"filename": operator,
"file_path": bundle,
"repo": pulp_repository,
"build": None,
"signing_key": None,
"checksums": None,
}
ret.append(item)
return ret

Expand Down Expand Up @@ -144,13 +153,15 @@ def _iib_op_main(args, operation=None, items_final_state="PUSHED"):
)

LOG.debug("Updating push items")
push_items = push_items_from_build(build_details, "PENDING")
push_items = push_items_from_build(build_details, "PENDING", args.pulp_repository)
pc.update_push_items(push_items)

build_details = iib_c.wait_for_build(build_details)
if build_details.state == "error":
LOG.error("IIB operation failed")
push_items = push_items_from_build(build_details, "NOTPUSHED")
push_items = push_items_from_build(
build_details, "NOTPUSHED", args.pulp_repository
)
pc.update_push_items(push_items)
sys.exit(1)

Expand Down Expand Up @@ -185,7 +196,9 @@ def _iib_op_main(args, operation=None, items_final_state="PUSHED"):
) as entry_func:
entry_func()

push_items = push_items_from_build(build_details, items_final_state)
push_items = push_items_from_build(
build_details, items_final_state, args.pulp_repository
)
pc.update_push_items(push_items)
return build_details

Expand Down
91 changes: 80 additions & 11 deletions tests/test_iib_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ def fixture_pushcollector():
pushcollector.Collector.set_default_backend("pubtools-ibb-test")
yield fake_collector

# with mock.patch("pushcollector.Collector.update_push_items") as mocked_update_push_items:
# yield mocked_update_push_items


@pytest.fixture
def fixture_iib_krb_auth():
Expand Down Expand Up @@ -152,8 +149,26 @@ def test_add_bundles_cli(
assert fixture_pulplib_repo_sync.mock_calls[0].args[0].feed == "index_image"

assert fixture_pushcollector.items == [
{"state": "PENDING", "origin": "bundle1", "filename": "operator-bundle1"},
{"state": "PUSHED", "origin": "bundle1", "filename": "operator-bundle1"},
{
"state": "PENDING",
"origin": "bundle1",
"filename": "operator-bundle1",
"file_path": "bundle1",
"repo": "redhat-operators",
"build": None,
"signing_key": None,
"checksums": None,
},
{
"state": "PUSHED",
"origin": "bundle1",
"filename": "operator-bundle1",
"file_path": "bundle1",
"repo": "redhat-operators",
"build": None,
"signing_key": None,
"checksums": None,
},
]


Expand Down Expand Up @@ -191,8 +206,26 @@ def test_add_bundles_cli_error(
pass

assert fixture_pushcollector.items == [
{"state": "PENDING", "origin": "bundle1", "filename": "operator-bundle1"},
{"state": "NOTPUSHED", "origin": "bundle1", "filename": "operator-bundle1"},
{
"state": "PENDING",
"origin": "bundle1",
"filename": "operator-bundle1",
"file_path": "bundle1",
"repo": "redhat-operators",
"build": None,
"signing_key": None,
"checksums": None,
},
{
"state": "NOTPUSHED",
"origin": "bundle1",
"filename": "operator-bundle1",
"file_path": "bundle1",
"repo": "redhat-operators",
"build": None,
"signing_key": None,
"checksums": None,
},
]


Expand Down Expand Up @@ -271,8 +304,26 @@ def test_remove_operators_cli(
assert fixture_pulplib_repo_sync.mock_calls[0].args[0].feed == "index_image"

assert fixture_pushcollector.items == [
{"state": "PENDING", "origin": "", "filename": "operator-op1"},
{"state": "DELETED", "origin": "", "filename": "operator-op1"},
{
"state": "PENDING",
"origin": "",
"filename": "operator-op1",
"file_path": "",
"repo": "redhat-operators",
"build": None,
"signing_key": None,
"checksums": None,
},
{
"state": "DELETED",
"origin": "",
"filename": "operator-op1",
"file_path": "",
"repo": "redhat-operators",
"build": None,
"signing_key": None,
"checksums": None,
},
]


Expand Down Expand Up @@ -312,8 +363,26 @@ def test_remove_operators_cli_error(
pass

assert fixture_pushcollector.items == [
{"state": "PENDING", "origin": "", "filename": "operator-op1"},
{"state": "NOTPUSHED", "origin": "", "filename": "operator-op1"},
{
"state": "PENDING",
"origin": "",
"filename": "operator-op1",
"file_path": "",
"repo": "redhat-operators",
"build": None,
"signing_key": None,
"checksums": None,
},
{
"state": "NOTPUSHED",
"origin": "",
"filename": "operator-op1",
"file_path": "",
"repo": "redhat-operators",
"build": None,
"signing_key": None,
"checksums": None,
},
]


Expand Down

0 comments on commit d35637f

Please sign in to comment.