Repository: apache/airflow
File: helm-tests/tests/helm_tests/other/test_hpa.py (Python)

Code before:
            "scaleDown": {
                "stabilizationWindowSeconds": 300,
                "policies": [{"type": "Percent", "value": 100, "periodSeconds": 15}],
            }
        }
        docs = render_chart(
            values={
                "workers": {
                    "hpa": {
                        "enabled": True,
                        "behavior": expected_behavior,
                    },
                },
                "executor": executor,
            },
            show_only=["templates/workers/worker-hpa.yaml"],
        )
        assert jmespath.search("spec.behavior", docs[0]) == expected_behavior

    @pytest.mark.parametrize(
        ("workers_persistence_values", "kind"),
        [
            ({"celery": {"persistence": {"enabled": True}}}, "StatefulSet"),
            ({"celery": {"persistence": {"enabled": False}}}, "Deployment"),
            ({"persistence": {"enabled": True}, "celery": {"persistence": {"enabled": None}}}, "StatefulSet"),
            ({"persistence": {"enabled": False}, "celery": {"persistence": {"enabled": None}}}, "Deployment"),
            ({"persistence": {"enabled": True}}, "StatefulSet"),
            ({"persistence": {"enabled": False}}, "StatefulSet"),
        ],
    )
    def test_persistence(self, workers_persistence_values, kind):
        """If worker persistence is enabled, scaleTargetRef should be StatefulSet else Deployment."""
        docs = render_chart(
            values={
                "workers": {"hpa": {"enabled": True}, **workers_persistence_values},
                "executor": "CeleryExecutor",
            },
            show_only=["templates/workers/worker-hpa.yaml"],
        )
        assert jmespath.search("spec.scaleTargetRef.kind", docs[0]) == kind


Review comment (bug):
Why are you removing these tests? Are they broken or not meaningful?
If disabled because of fix complexity this should keep a note at least.

Code after:
            "scaleDown": {
                "stabilizationWindowSeconds": 300,
                "policies": [{"type": "Percent", "value": 100, "periodSeconds": 15}],
            }
        }
        docs = render_chart(
            values={
                "workers": {
                    "hpa": {
                        "enabled": True,
                        "behavior": expected_behavior,
                    },
                },
                "executor": executor,
            },
            show_only=["templates/workers/worker-hpa.yaml"],
        )
        assert jmespath.search("spec.behavior", docs[0]) == expected_behavior

    @pytest.mark.parametrize(
        ("workers_persistence_values", "kind"),
        [
            ({"celery": {"persistence": {"enabled": True}}}, "StatefulSet"),
            ({"celery": {"persistence": {"enabled": False}}}, "Deployment"),
            ({"persistence": {"enabled": True}}, "StatefulSet"),
            ({"persistence": {"enabled": False}}, "Deployment"),
        ],
    )
    def test_persistence(self, workers_persistence_values, kind):
        """If worker persistence is enabled, scaleTargetRef should be StatefulSet else Deployment."""
        docs = render_chart(
            values={
                "workers": {"hpa": {"enabled": True}, **workers_persistence_values},
                "executor": "CeleryExecutor",
            },
            show_only=["templates/workers/worker-hpa.yaml"],
        )
        assert jmespath.search("spec.scaleTargetRef.kind", docs[0]) == kind