Skip to content

Commit c1cbec7

Browse files
committed
Avoid race condition on unit-tests
Use ordered diff for `get_bundles_latest_version` when raising to avoid race condition failures such as: https://github.com/release-engineering/iib/actions/runs/20110179089/job/57705081674?pr=1276 Signed-off-by: Jonathan Gangi <jgangi@redhat.com>
1 parent e98e9e4 commit c1cbec7

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

iib/workers/tasks/build_merge_index_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ def parse_version(version):
625625
# Validate the bundles and bundle_images lenght
626626
if len(bundle_version_names) != len(bundles):
627627
uniq_verions = [x[2] for x in bundle_version_names]
628-
diff = set(bundles) - set(uniq_verions)
628+
diff = sorted(set(bundles) - set(uniq_verions))
629629
raise IIBError(f"Failed to retrieve bundles by semver, missing bundle images: {diff}")
630630

631631
# Retrieve the latest version of all bundle packages.

tests/test_workers/test_tasks/test_build_merge_index_image.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: GPL-3.0-or-later
22
import json
33
import os
4+
import re
45
import stat
56
from unittest import mock
67

@@ -1085,7 +1086,7 @@ def test_get_bundles_latest_version(bundle_images, expected):
10851086
'version': '1.2.34',
10861087
},
10871088
],
1088-
set(["operator2@sha256:1000"]),
1089+
["operator2@sha256:1000"],
10891090
),
10901091
(
10911092
[
@@ -1110,16 +1111,14 @@ def test_get_bundles_latest_version(bundle_images, expected):
11101111
'version': '3.0.0',
11111112
},
11121113
],
1113-
set(
1114-
[
1115-
"missing-operator@sha256:1234",
1116-
"missing-operator@sha256:0001",
1117-
]
1118-
),
1114+
[
1115+
"missing-operator@sha256:0001",
1116+
"missing-operator@sha256:1234",
1117+
],
11191118
),
11201119
],
11211120
)
11221121
def test_get_bundles_latest_version_missing_bundles(bundles, bundle_images, diff_bundles):
11231122
err = f"Failed to retrieve bundles by semver, missing bundle images: {diff_bundles}"
1124-
with pytest.raises(IIBError, match=err):
1123+
with pytest.raises(IIBError, match=re.escape(err)):
11251124
build_merge_index_image.get_bundles_latest_version(bundles, bundle_images)

0 commit comments

Comments
 (0)