Skip to content

feat: Add container execution backend (Docker/Podman)#22

Open
germainh512 wants to merge 1 commit intogvsoc:mainfrom
germainh512:feature/container-support
Open

feat: Add container execution backend (Docker/Podman)#22
germainh512 wants to merge 1 commit intogvsoc:mainfrom
germainh512:feature/container-support

Conversation

@germainh512
Copy link

Summary

Add support for running gvtest tests inside containers (Docker/Podman) while operating on the host filesystem via transparent bind mounts. This enables multi-project test suites where each project requires its own containerized environment, while keeping test artifacts directly accessible on the host.

Motivation

When integrating test suites from different projects, each may require its own set of toolchains, SDKs, and dependencies. Containers provide isolated environments, but traditionally require copying artifacts in and out. This feature lets gvtest orchestrate tests across multiple containers transparently — the container sees the same filesystem paths as the host, so build outputs, logs, and binaries are directly usable from either side.

Usage

Container config can be set at three levels (highest priority first):

1. In testset.cfg (programmatic)

def testset_build(testset):
    testset.set_container(
        image='ghcr.io/org/image:tag',
        setup='pip install -e .',
    )
    test = testset.new_test('build')
    test.add_command(Shell('build', 'make all'))

2. In gvtest.yaml (declarative, zero code changes)

container:
  image: ghcr.io/org/image:tag
  runtime: docker   # or podman
  setup: pip install -e .
  env:
    MY_VAR: value
  volumes:
    /extra/data: /extra/data
  options:
    - --gpus
    - all

3. Inherited from parent testsets

Child testsets inherit the container config from their parent unless they override it.

Key Design Decisions

  • Transparent mounts: The test working directory is bind-mounted at the same absolute path inside the container (-v /path:/path), so all paths work identically on both sides
  • Single docker run per test: All Shell commands within a test execute in one container invocation
  • Works with pytest integration: Both test discovery (--collect-only) and batch execution run inside the container when configured; JUnit XML is written to the workdir (visible on both sides)
  • Docker and Podman support: Configurable via runtime field
  • Leaf-wins config precedence: In the gvtest.yaml hierarchy, the most specific (leaf-most) container config fully overrides parent configs (no merging)

Changes

File Change
python/gvtest/container.py NewContainerConfig class with build_run_cmd(), from_dict(), validate()
python/gvtest/config.py Parse and resolve container from gvtest.yaml hierarchy
python/gvtest/tests.py Wrap Shell commands in docker run when container is configured
python/gvtest/pytest_integration.py Container-aware discovery and batch execution
python/gvtest/testset_impl.py set_container() and get_container() with parent inheritance
python/gvtest/testsuite.py Abstract interface for container support
python/gvtest/runner.py Auto-apply container config from gvtest.yaml on testset import
python/gvtest/__init__.py Export ContainerConfig
tests/test_container.py New — 20 unit tests

Testing

  • All 156 tests pass (136 existing + 20 new)
  • No regressions in existing functionality

Add support for running tests inside containers (Docker/Podman)
while operating on the host filesystem via transparent bind mounts.

Container config can be set at three levels (in priority order):
1. Testset-level: testset.set_container(image='...', setup='...')
2. gvtest.yaml: container section in hierarchical config
3. Inherited from parent testsets

Key design decisions:
- Transparent mounts: the container sees the same absolute paths
  as the host, so build artifacts are directly accessible from
  either side without any copy step
- Single 'docker run' per test: all commands in a test execute
  in one container invocation
- Works with both regular Shell tests and pytest integration
- Supports Docker and Podman via 'runtime' config
- JUnit XML for pytest batches is written to the test workdir
  (visible in both host and container)

New files:
- python/gvtest/container.py: ContainerConfig class
- tests/test_container.py: 20 unit tests

Modified files:
- config.py: Parse 'container' from gvtest.yaml hierarchy
- tests.py: Wrap Shell commands in docker run when configured
- pytest_integration.py: Container-aware discovery and batch execution
- testset_impl.py: set_container() and get_container() methods
- testsuite.py: Abstract interface for container support
- runner.py: Auto-apply container config from gvtest.yaml
- __init__.py: Export ContainerConfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant