Skip to content

Commit b3f2392

Browse files
authored
Fix integration tests failing on fbc catalog changes (#727)
Signed-off-by: Maurizio Porrato <[email protected]>
1 parent 0554405 commit b3f2392

File tree

6 files changed

+42
-37
lines changed

6 files changed

+42
-37
lines changed

ansible/roles/operator-pipeline/templates/openshift/pipelines/operator-hosted-pipeline.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,6 @@ spec:
401401
value: "$(params.pipeline_image)"
402402
- name: operator_path
403403
value: "$(tasks.detect-changes.results.operator_path)"
404-
- name: catalog_operator_path
405-
value: "$(tasks.detect-changes.results.affected_catalog_operators)"
406404
workspaces:
407405
- name: source
408406
workspace: repository
@@ -529,8 +527,6 @@ spec:
529527
value: "$(params.pipeline_image)"
530528
- name: operator_path
531529
value: "$(tasks.detect-changes.results.operator_path)"
532-
- name: catalog_operator_path
533-
value: "$(tasks.detect-changes.results.affected_catalog_operators)"
534530
- name: cert_project_required
535531
value: "$(params.cert_project_required)"
536532
workspaces:

ansible/roles/operator-pipeline/templates/openshift/pipelines/operator-release-pipeline.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,6 @@ spec:
226226
value: "$(params.pipeline_image)"
227227
- name: operator_path
228228
value: "$(tasks.detect-changes.results.operator_path)"
229-
- name: catalog_operator_path
230-
value: "$(tasks.detect-changes.results.affected_catalog_operators)"
231229
workspaces:
232230
- name: source
233231
workspace: repository
@@ -281,8 +279,6 @@ spec:
281279
value: "$(params.pipeline_image)"
282280
- name: operator_path
283281
value: "$(tasks.detect-changes.results.operator_path)"
284-
- name: catalog_operator_path
285-
value: "$(tasks.detect-changes.results.affected_catalog_operators)"
286282
- name: cert_project_required
287283
value: "$(params.cert_project_required)"
288284
workspaces:

ansible/roles/operator-pipeline/templates/openshift/tasks/cert-project-check.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ spec:
88
- name: pipeline_image
99
- name: operator_path
1010
description: path indicating the location of the certified operator within the repository
11-
- name: catalog_operator_path
12-
description: path indicating the location of the catalog operator within the repository
1311
default: ""
1412
- name: cert_project_required
1513
description: A flag determines whether a cert project ID needs to be present
@@ -35,11 +33,7 @@ spec:
3533
fi
3634
if [ "$(params.operator_path)" != "" ]; then
3735
PKG_PATH="$(params.operator_path)"
38-
elif [ "$(params.catalog_operator_path)" != "" ]; then
39-
OPERATOR_NAME=$(echo $(params.catalog_operator_path) | cut -d ',' -f 1 | cut -d '/' -f 2)
40-
PKG_PATH=operators/$OPERATOR_NAME
41-
else
42-
echo "Bundle path is missing."
36+
echo "Operator path is missing."
4337
exit 1
4438
fi
4539

ansible/roles/operator-pipeline/templates/openshift/tasks/read-config.yaml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ spec:
1414
description: |
1515
Path to an operator within the git repository where the config is expected.
1616
17-
- name: catalog_operator_path
18-
description: path indicating the location of the catalog operator within the repository
19-
default: ""
20-
2117
results:
2218
- name: upgrade-graph-mode
2319
description: "A graph update mode that defines how channel graphs are updated"
@@ -38,11 +34,8 @@ spec:
3834
3935
if [ "$(params.operator_path)" != "" ]; then
4036
PKG_PATH="$(params.operator_path)"
41-
elif [ "$(params.catalog_operator_path)" != "" ]; then
42-
OPERATOR_NAME=$(echo $(params.catalog_operator_path) | cut -d ',' -f 1 | cut -d '/' -f 2)
43-
PKG_PATH=operators/$OPERATOR_NAME
4437
else
45-
echo "Bundle path is missing."
38+
echo "Operator path is missing."
4639
exit 1
4740
fi
4841

operator-pipeline-images/operatorcert/parsed_file.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,24 @@ def enrich_result(result: dict[str, Any]) -> None:
187187
Args:
188188
result: Dictionary with the detected changes
189189
"""
190-
if len(added_bundles := result.get("added_bundles", [])) == 1:
191-
operator_name, bundle_version = added_bundles[0].split("/")
192-
elif len(affected_operators := result.get("affected_operators", [])) == 1:
193-
# no bundle was added (i.e.: only ci.yaml was added/modified/deleted)
190+
191+
operator_name = ""
192+
bundle_version = ""
193+
194+
affected_operators = result.get("affected_operators", [])
195+
affected_bundles = result.get("affected_bundles", [])
196+
affected_catalog_operators = result.get("affected_catalog_operators", [])
197+
198+
if affected_operators:
194199
operator_name = affected_operators[0]
195-
bundle_version = ""
196-
else:
197-
operator_name = ""
198-
bundle_version = ""
200+
201+
if affected_bundles:
202+
_, bundle_version = affected_bundles[0].split("/")
203+
204+
if affected_catalog_operators and operator_name == "":
205+
# Even if the change affects only files in catalogs/ we still need to know
206+
# what operator is affected by the change when accessing info in the operator's ci.yaml
207+
operator_name = affected_catalog_operators[0][1]
199208

200209
result["operator_name"] = operator_name
201210
result["bundle_version"] = bundle_version

operator-pipeline-images/tests/entrypoints/test_detect_changed_operators.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -732,11 +732,11 @@ def test_ParserRules_validate_removal_fbc_fail(
732732
[
733733
pytest.param(
734734
{
735-
"added_bundles": ["operator-e2e/0.0.101"],
735+
"affected_bundles": ["operator-e2e/0.0.101"],
736736
"affected_operators": ["operator-e2e"],
737737
},
738738
{
739-
"added_bundles": ["operator-e2e/0.0.101"],
739+
"affected_bundles": ["operator-e2e/0.0.101"],
740740
"affected_operators": ["operator-e2e"],
741741
"operator_name": "operator-e2e",
742742
"bundle_version": "0.0.101",
@@ -747,11 +747,11 @@ def test_ParserRules_validate_removal_fbc_fail(
747747
),
748748
pytest.param(
749749
{
750-
"added_bundles": [],
750+
"affected_bundles": [],
751751
"affected_operators": ["operator-e2e"],
752752
},
753753
{
754-
"added_bundles": [],
754+
"affected_bundles": [],
755755
"affected_operators": ["operator-e2e"],
756756
"operator_name": "operator-e2e",
757757
"bundle_version": "",
@@ -762,11 +762,11 @@ def test_ParserRules_validate_removal_fbc_fail(
762762
),
763763
pytest.param(
764764
{
765-
"added_bundles": [],
765+
"affected_bundles": [],
766766
"affected_operators": [],
767767
},
768768
{
769-
"added_bundles": [],
769+
"affected_bundles": [],
770770
"affected_operators": [],
771771
"operator_name": "",
772772
"bundle_version": "",
@@ -775,6 +775,23 @@ def test_ParserRules_validate_removal_fbc_fail(
775775
},
776776
id="No bundle added or operator affected",
777777
),
778+
pytest.param(
779+
{
780+
"affected_bundles": [],
781+
"affected_operators": [],
782+
"affected_catalog_operators": [("v4.16", "operator-e2e")],
783+
},
784+
{
785+
"affected_bundles": [],
786+
"affected_operators": [],
787+
"affected_catalog_operators": [("v4.16", "operator-e2e")],
788+
"operator_name": "operator-e2e",
789+
"bundle_version": "",
790+
"operator_path": "operators/operator-e2e",
791+
"bundle_path": "",
792+
},
793+
id="Catalog operator affected",
794+
),
778795
],
779796
)
780797
def test__update_result(result: dict[str, Any], expected: dict[str, Any]) -> None:

0 commit comments

Comments
 (0)