From 4060a4244ba2399892e1cbb8860eb90e826c01e4 Mon Sep 17 00:00:00 2001 From: Jan Grulich Date: Wed, 3 Jun 2026 16:08:04 +0200 Subject: [PATCH] Mount testing-jiras into agent containers for e2e mock repos Symlinks to host paths don't work inside podman containers because bind mounts don't follow symlinks pointing outside the mounted tree. Mount the testing-jiras directory directly via TESTING_JIRAS_DIR and pass MOCK_REPOS_DIR to agent containers so fixture configs are found. Pass BACKPORT_MOCK_REPOS_DIR to the backport test service separately, since the backport test reads that variable instead of MOCK_REPOS_DIR. Guard against empty env var values in both test suites so they fall back to DEFAULT_FIXTURES_DIR instead of loading from an empty path. Assisted-by: Claude --- compose.yaml | 3 +++ .../tests/e2e/backport_agent/test_backport.py | 6 ++--- ymir/agents/tests/e2e/mock_repos/README.md | 23 +++++++++++++++---- ymir/agents/tests/e2e/test_triage.py | 2 +- ymir/tools/privileged/tests/data/README.md | 5 ++-- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/compose.yaml b/compose.yaml index 25543915..f65dd307 100644 --- a/compose.yaml +++ b/compose.yaml @@ -6,6 +6,7 @@ x-beeai-env: &beeai-env REDIS_URL: redis://valkey:6379/0 COLLECTOR_ENDPOINT: http://otel-collector:4318/v1/traces GIT_REPO_BASEPATH: /git-repos + MOCK_REPOS_DIR: ${MOCK_REPOS_DIR:-} MAX_RETRIES: 3 DRY_RUN: ${DRY_RUN:-false} JIRA_DRY_RUN: ${JIRA_DRY_RUN:-false} @@ -28,6 +29,7 @@ x-beeai-agent: &beeai-agent - ./ymir/tools:/home/beeai/ymir/tools:ro,z - ./ymir/common:/home/beeai/ymir/common:ro,z - git-repos:/git-repos:rw,U + - ${TESTING_JIRAS_DIR:-./ymir/agents/tests/e2e/mock_repos}:/testing-jiras:ro,z - .secrets/rhel-config.json:/home/beeai/rhel-config.json:ro,z,U - .secrets/jotnar-vertex-dev.json:/home/beeai/jotnar-vertex-dev.json:ro,z,U restart: unless-stopped @@ -212,6 +214,7 @@ services: <<: *beeai-agent-c10s environment: <<: *beeai-env + BACKPORT_MOCK_REPOS_DIR: ${BACKPORT_MOCK_REPOS_DIR:-} command: ["pytest", "ymir/agents/tests/e2e/backport_agent/test_backport.py", "-o", "asyncio_default_test_loop_scope=session"] profiles: ["e2e-test"] diff --git a/ymir/agents/tests/e2e/backport_agent/test_backport.py b/ymir/agents/tests/e2e/backport_agent/test_backport.py index 75858175..b56e30cc 100644 --- a/ymir/agents/tests/e2e/backport_agent/test_backport.py +++ b/ymir/agents/tests/e2e/backport_agent/test_backport.py @@ -89,7 +89,7 @@ def _load_test_cases(fixtures_dir: str | Path) -> list[BackportAgentTestCase]: return cases -test_cases = _load_test_cases(os.getenv("BACKPORT_MOCK_REPOS_DIR", str(DEFAULT_FIXTURES_DIR))) +test_cases = _load_test_cases(os.getenv("BACKPORT_MOCK_REPOS_DIR") or str(DEFAULT_FIXTURES_DIR)) @pytest.fixture(scope="session", autouse=True) @@ -116,7 +116,7 @@ def mock_centos_stream_repos(): Yields: Control to the test session after repos are prepared. """ - fixtures_dir = os.getenv("BACKPORT_MOCK_REPOS_DIR", str(DEFAULT_FIXTURES_DIR)) + fixtures_dir = os.getenv("BACKPORT_MOCK_REPOS_DIR") or str(DEFAULT_FIXTURES_DIR) configs = load_all_fixture_configs(fixtures_dir) if SHARED_BARE_REPOS_DIR.exists(): @@ -151,7 +151,7 @@ def _load_reference_patch(test_case: "BackportAgentTestCase") -> str | None: ref_patch_rel = test_case.expected.get("reference_patch") if not ref_patch_rel: return None - fixtures_dir = Path(os.getenv("BACKPORT_MOCK_REPOS_DIR", str(DEFAULT_FIXTURES_DIR))) + fixtures_dir = Path(os.getenv("BACKPORT_MOCK_REPOS_DIR") or str(DEFAULT_FIXTURES_DIR)) ref_patch_path = fixtures_dir / ref_patch_rel if ref_patch_path.is_file(): return ref_patch_path.read_text() diff --git a/ymir/agents/tests/e2e/mock_repos/README.md b/ymir/agents/tests/e2e/mock_repos/README.md index 415dfcca..d71de72c 100644 --- a/ymir/agents/tests/e2e/mock_repos/README.md +++ b/ymir/agents/tests/e2e/mock_repos/README.md @@ -4,12 +4,25 @@ This directory contains mock repo fixture files organized by agent type. The fixtures come from `git@gitlab.cee.redhat.com:jotnar-project/testing-jiras.git` if you have access. -Clone the repository and symlink its `mock_data/` subdirectories here: +Clone the repository and either: -```bash -ln -s /path/to/testing-jiras/mock_data/triage ymir/agents/tests/e2e/mock_repos/triage -ln -s /path/to/testing-jiras/mock_data/backport ymir/agents/tests/e2e/mock_repos/backport -``` +- **Run via compose (recommended):** set `TESTING_JIRAS_DIR` in your local `.env` to point + at the cloned repository root so compose mounts it into the container: + ``` + TESTING_JIRAS_DIR=/path/to/testing-jiras + MOCK_REPOS_DIR=/testing-jiras/mock_data/triage + BACKPORT_MOCK_REPOS_DIR=/testing-jiras/mock_data/backport + ``` + +- **Run directly on host:** symlink the `mock_data/` subdirectories here: + ```bash + ln -s /path/to/testing-jiras/mock_data/triage ymir/agents/tests/e2e/mock_repos/triage + ln -s /path/to/testing-jiras/mock_data/backport ymir/agents/tests/e2e/mock_repos/backport + ``` + +> **Note:** Symlinks only work when running tests on the host. Podman bind +> mounts do not follow symlinks pointing outside the mounted tree, so +> containerized e2e tests require the compose-based approach. ## Expected layout diff --git a/ymir/agents/tests/e2e/test_triage.py b/ymir/agents/tests/e2e/test_triage.py index d6fa1baa..8fb4fdba 100644 --- a/ymir/agents/tests/e2e/test_triage.py +++ b/ymir/agents/tests/e2e/test_triage.py @@ -175,7 +175,7 @@ def mock_centos_stream_repos(tmp_path_factory): Yields: Control to the test session after repos are prepared. """ - fixtures_dir = os.getenv("MOCK_REPOS_DIR", str(DEFAULT_FIXTURES_DIR)) + fixtures_dir = os.getenv("MOCK_REPOS_DIR") or str(DEFAULT_FIXTURES_DIR) configs = load_all_fixture_configs(fixtures_dir) if git_repo_basepath := os.getenv("GIT_REPO_BASEPATH"): diff --git a/ymir/tools/privileged/tests/data/README.md b/ymir/tools/privileged/tests/data/README.md index dc43936a..9ee05f39 100644 --- a/ymir/tools/privileged/tests/data/README.md +++ b/ymir/tools/privileged/tests/data/README.md @@ -4,9 +4,10 @@ This directory is meant to contain Jira mock files from Clone the repository and either: -- **Run via compose (recommended):** set `JIRA_MOCK_FILES_HOST` in your local `.env` to point - at the cloned `jiras/` directory so compose mounts it directly into the container: +- **Run via compose (recommended):** set `TESTING_JIRAS_DIR` and `JIRA_MOCK_FILES_HOST` in + your local `.env` to point at the cloned repository: ``` + TESTING_JIRAS_DIR=/path/to/testing-jiras JIRA_MOCK_FILES_HOST=/path/to/testing-jiras/jiras ```