From b7d568cf95d73df5338124694d0847bfcd97a6e4 Mon Sep 17 00:00:00 2001 From: Yashvardhan Nanavati Date: Sun, 11 Feb 2024 23:32:15 -0500 Subject: [PATCH] [CVP-3985] add all targeted channels data to parsed_operator_data.yml --- Dockerfiles/ci/run_tests.py | 29 +++++++++++++++++++ .../templates/parsed_operator_data.yml.j2 | 6 ++++ 2 files changed, 35 insertions(+) diff --git a/Dockerfiles/ci/run_tests.py b/Dockerfiles/ci/run_tests.py index df610704..666873c6 100755 --- a/Dockerfiles/ci/run_tests.py +++ b/Dockerfiles/ci/run_tests.py @@ -406,6 +406,35 @@ def test_extract_operator_bundle_with_skiprange_and_skips_without_replaces(self) self.assertIn('olm_skips:\n', parsed_output) self.assertIn('- "local-storage-operator.v4.15.0-202312121223"\n', parsed_output) + + def test_all_target_channels_parsing(self): + operator_work_dir = "{}/test_all_target_channels_parsing".format(self.test_dir) + work_dir = operator_work_dir + operator_dir = "{}/test-operator".format(operator_work_dir) + operator_bundle_dir = "{}/operator-bundle".format(operator_work_dir) + bundle_image = "quay.io/cvpops/test-operator:parse-channel" + exec_cmd = "ansible-playbook -vvv -i localhost, --connection local \ + operator-test-playbooks/extract-operator-bundle.yml \ + -e 'operator_dir={operator_dir}' \ + -e 'bundle_image={bundle_image}' \ + -e 'operator_work_dir={operator_work_dir}' \ + -e 'operator_bundle_dir={operator_bundle_dir}' \ + -e 'work_dir={work_dir}'".format(operator_dir=operator_dir, + operator_work_dir=operator_work_dir, + operator_bundle_dir=operator_bundle_dir, + bundle_image=bundle_image, + work_dir=work_dir) + playbook_command = subprocess.run(exec_cmd, shell=True) + + print(playbook_command.returncode) + self.assertTrue(playbook_command.returncode == 0) + self.assertTrue(path.exists("{}/parsed_operator_data.yml".format(work_dir))) + with open("{}/parsed_operator_data.yml".format(work_dir), "r") as fd: + parsed_output = fd.read() + print(parsed_output) + self.assertNotIn('olm_replaces', parsed_output) + self.assertIn('target_channels:\n - "4.10"', parsed_output) + if __name__ == '__main__': unittest.main() diff --git a/roles/parse_operator_bundle/templates/parsed_operator_data.yml.j2 b/roles/parse_operator_bundle/templates/parsed_operator_data.yml.j2 index 573fb10c..49b71b8d 100644 --- a/roles/parse_operator_bundle/templates/parsed_operator_data.yml.j2 +++ b/roles/parse_operator_bundle/templates/parsed_operator_data.yml.j2 @@ -72,3 +72,9 @@ operator_feature_token_auth_azure: "{{ operator_feature_token_auth_azure }}" {% if operator_feature_token_auth_gcp is defined %} operator_feature_token_auth_gcp: "{{ operator_feature_token_auth_gcp }}" {% endif %} +{% if channels is defined %} +target_channels: +{% for channel in channels %} + - "{{ channel }}" +{% endfor %} +{% endif %}