sg-c0de commented on code in PR #63514: URL: https://github.com/apache/airflow/pull/63514#discussion_r3044893938
########## helm-tests/tests/helm_tests/airflow_core/test_worker_image.py: ########## @@ -0,0 +1,693 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +from __future__ import annotations + +import jmespath +import pytest +import yaml +from chart_utils.helm_template_generator import CHART_DIR, render_chart + + +def _get_default_airflow_image() -> tuple[str, str]: + """Read the default airflow image and tag from chart/values.yaml.""" + values = yaml.safe_load((CHART_DIR / "values.yaml").read_text()) + repo = values["defaultAirflowRepository"] + tag = values["defaultAirflowTag"] + return f"{repo}:{tag}", tag + + +DEFAULT_AIRFLOW_IMAGE, DEFAULT_AIRFLOW_TAG = _get_default_airflow_image() + + +def _all_airflow_images(doc): + """Extract all airflow images from a rendered worker deployment/statefulset.""" + init_images = jmespath.search("spec.template.spec.initContainers[*].image", doc) or [] + container_images = jmespath.search("spec.template.spec.containers[*].image", doc) or [] + # Filter out git-sync sidecar images (they don't use airflow_worker_image) + all_images = init_images + container_images + return [img for img in all_images if "git-sync" not in img] + + +def _all_airflow_pull_policies(doc): + """Extract all imagePullPolicy values from airflow containers.""" + init_policies = jmespath.search("spec.template.spec.initContainers[*].imagePullPolicy", doc) or [] + container_policies = jmespath.search("spec.template.spec.containers[*].imagePullPolicy", doc) or [] + return init_policies + container_policies Review Comment: Removed this helpers and to make more straightforward tests -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
