From b6fe51bd035bf1aa84bb3161c132f06db239c61b Mon Sep 17 00:00:00 2001 From: Pankaj Singh <98807258+pankajastro@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:27:54 +0530 Subject: [PATCH] Fix integration test and bug in load balancer wait logic (#85) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I noticed that sometimes dag.test() does not raise an exception even when an Airflow task fails, leading to silent failures in CI jobs without any notification. To address this, I’ve added an explicit assertion to check that the DAG run state is "success" when dag.test() does not raise an exception. Added the tool.pytest.ini_options section in pyproject.toml, including the minversion option and custom markers. Fixed bug in the sleep logic while waiting for the load balancer to become ready Failed detected CI: https://github.com/astronomer/astro-provider-ray/actions/runs/11560564529/job/32177695161?pr=85 closes: astronomer/oss-integrations-private#22 --- pyproject.toml | 5 +++++ ray_provider/hooks/ray.py | 1 + tests/test_dag_example.py | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c558224..005fac4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -91,6 +91,11 @@ test-cov = 'sh scripts/test/unit_cov.sh' test-integration = 'sh scripts/test/integration_test.sh' static-check = "pre-commit run --all-files" +[tool.pytest.ini_options] +filterwarnings = ["ignore::DeprecationWarning"] +minversion = "6.0" +markers = ["integration"] + ###################################### # DOCS ###################################### diff --git a/ray_provider/hooks/ray.py b/ray_provider/hooks/ray.py index 7ca6e3f..2000ecf 100644 --- a/ray_provider/hooks/ray.py +++ b/ray_provider/hooks/ray.py @@ -339,6 +339,7 @@ def _wait_for_load_balancer( if not lb_details: self.log.info("LoadBalancer details not available yet.") + time.sleep(retry_interval) continue working_address = self._check_load_balancer_readiness(lb_details) diff --git a/tests/test_dag_example.py b/tests/test_dag_example.py index b6990b4..f265425 100644 --- a/tests/test_dag_example.py +++ b/tests/test_dag_example.py @@ -64,6 +64,7 @@ def test_dag_runs(setup_airflow_db, dag_id, dag, fileloc): return try: - dag.test() + dr = dag.test() + assert dr.state == "success" except Exception as e: pytest.fail(f"Error running DAG {dag_id}: {e}")