You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "uranusjr (via GitHub)" <gi...@apache.org> on 2023/02/21 06:08:23 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #29616: Refactor docker-compose quick start test

uranusjr commented on code in PR #29616:
URL: https://github.com/apache/airflow/pull/29616#discussion_r1112580793


##########
docker_tests/test_docker_compose_quick_start.py:
##########
@@ -114,53 +104,60 @@ def wait_for_terminal_dag_state(dag_id, dag_run_id):
             break
 
 
-def test_trigger_dag_and_wait_for_result():
+def test_trigger_dag_and_wait_for_result(tmp_path_factory, monkeypatch):
+    """Simple test which reproduce setup docker-compose environment and trigger example dag."""
+    tmp_dir = tmp_path_factory.mktemp("airflow-quick-start")
+    monkeypatch.chdir(tmp_dir)
+    monkeypatch.setenv("AIRFLOW_IMAGE_NAME", docker_image)
+    monkeypatch.setenv("COMPOSE_PROJECT_NAME", "quick-start")
+
     compose_file_path = (
         SOURCE_ROOT / "docs" / "apache-airflow" / "howto" / "docker-compose" / "docker-compose.yaml"
     )
+    copyfile(compose_file_path, tmp_dir / "docker-compose.yaml")
 
-    with tempfile.TemporaryDirectory() as tmp_dir, tmp_chdir(tmp_dir), mock.patch.dict(
-        "os.environ", AIRFLOW_IMAGE_NAME=docker_image
-    ):
-        copyfile(str(compose_file_path), f"{tmp_dir}/docker-compose.yaml")
-        os.mkdir(f"{tmp_dir}/dags")
-        os.mkdir(f"{tmp_dir}/logs")
-        os.mkdir(f"{tmp_dir}/plugins")
-        (Path(tmp_dir) / ".env").write_text(f"AIRFLOW_UID={subprocess.check_output(['id', '-u']).decode()}\n")
-        print(".emv=", (Path(tmp_dir) / ".env").read_text())
-        copyfile(
-            str(SOURCE_ROOT / "airflow" / "example_dags" / "example_bash_operator.py"),
-            f"{tmp_dir}/dags/example_bash_operator.py",
-        )
+    # Create required directories for docker compose quick start howto
+    for subdir in ("dags", "logs", "plugins"):
+        (tmp_dir / subdir).mkdir()
+
+    dot_env_file = Path(tmp_dir) / ".env"

Review Comment:
   ```suggestion
       dot_env_file = Path(tmp_dir, ".env")
   ```



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org