code: 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)
  
      compose_file_path = (
          SOURCE_ROOT
          / "docs"
          / "apache-airflow"
          / "howto"
          / "docker-compose"
          / "docker-compose.yaml"
      )
      copyfile(compose_file_path, tmp_dir / "docker-compose.yaml")
  
      # Create required directories for docker compose quick start howto
      for subdir in ("dags", "logs", "plugins"):
          (tmp_dir / subdir).mkdir()
  
      dot_env_file = tmp_dir / ".env"
      dot_env_file.write_text(f"AIRFLOW_UID={os.getuid()}\n")
      print(" .env file content ".center(72, "="))
      print(dot_env_file.read_text())
  
      # check if docker-compose is available
      compose_command = ["docker", "compose"]
      success = run_command([*compose_command, "version"], check=False)
      if not success:
          print(
              "ERROR: `docker compose` not available. Make sure compose plugin is installed"
          )
          sys.exit(1)
      compose_command.extend(["--project-name", "quick-start"])
      run_command([*compose_command, "config"])
      run_command(
          [*compose_command, "down", "--volumes", "--remove-orphans"]
      )
      run_command([*compose_command, "up", "-d", "--wait"])
      api_request(
          "PATCH", path=f"dags/{DAG_ID}", json={"is_paused": False}
      )
      api_request(
          "POST",
          path=f"dags/{DAG_ID}/dagRuns",
          json={"dag_run_id": DAG_RUN_ID},
      )
      try:
          wait_for_terminal_dag_state(
              dag_id=DAG_ID, dag_run_id=DAG_RUN_ID
          )
          dag_state = api_request(
              "GET", f"dags/{DAG_ID}/dagRuns/{DAG_RUN_ID}"
          ).get("state")
          assert dag_state == "success"
      except Exception:
          print("HTTP: GET health")
          pprint(api_request("GET", "health"))
          print(f"HTTP: GET dags/{DAG_ID}/dagRuns")
          pprint(api_request("GET", f"dags/{DAG_ID}/dagRuns"))
          print(
              f"HTTP: GET dags/{DAG_ID}/dagRuns/{DAG_RUN_ID}/taskInstances"
          )
          pprint(
              api_request(
                  "GET",
                  f"dags/{DAG_ID}/dagRuns/{DAG_RUN_ID}/taskInstances",
              )
          )
          print(f"Current working directory: {os.getcwd()}")
          run_command(["docker", "version"])
          run_command([*compose_command, "version"])
          run_command(["docker", "ps"])
          run_command([*compose_command, "logs"])
          ps_output = run_command(
              [*compose_command, "ps", "--format", "json"],
              return_output=True,
          )
          container_names = [
              container["Name"] for container in json.loads(ps_output)
          ]
          for container in container_names:
              print(f"Health check for {container}")
              result = run_command(
                  [
                      "docker",
                      "inspect",
                      "--format",
                      "{{json .State}}",
                      container,
                  ],
                  return_output=True,
              )
              pprint(json.loads(result))
          raise
      finally:
          if not os.environ.get("SKIP_DOCKER_COMPOSE_DELETION"):
              run_command([*compose_command, "down", "--volumes"])
              print("Docker compose instance deleted")
          else:
              print("Skipping docker-compose deletion")
              print()
              print(
                  "You can run inspect your docker-compose by running commands starting with:"
              )
              print(
                  " ".join(
                      [shlex.quote(arg) for arg in compose_command]
                  )
              )
  
file_path: airflow/docker_tests/test_docker_compose_quick_start.py
imports: from __future__ import annotations
  import json
  import os
  import shlex
  import subprocess
  import sys
  from pprint import pprint
  from shutil import copyfile
  from time import monotonic, sleep
  import requests
  from docker_tests.command_utils import run_command
  from docker_tests.constants import SOURCE_ROOT
  from docker_tests.docker_tests_utils import docker_image
label_desc: Use image node_id 4 for calling a global function with example usage: test_trigger_dag_and_wait_for_result(tmp_path_factory, monkeypatch) without return types