Skip to content

Commit

Permalink
Merge pull request #217 from rcmadhankumar/fix-184
Browse files Browse the repository at this point in the history
extra pod create args added
  • Loading branch information
dcermak authored Jul 24, 2024
2 parents a872ff9 + 4083f4b commit 70de2e0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 4 additions & 2 deletions pytest_container/pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ def launch_pod(self) -> None:
"""
runtime = get_selected_runtime()
create_cmd = [runtime.runner_binary, "pod", "create"] + (
["--name", self.pod_name] if self.pod_name else []
create_cmd = (
[runtime.runner_binary, "pod", "create"]
+ (["--name", self.pod_name] if self.pod_name else [])
+ self.extra_pod_create_args
)

if self.pod.forwarded_ports:
Expand Down
14 changes: 12 additions & 2 deletions tests/test_pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,26 @@


def test_pod_launcher(
container_runtime: OciRuntimeBase, pytestconfig: pytest.Config
tmp_path: Path,
container_runtime: OciRuntimeBase,
pytestconfig: pytest.Config,
) -> None:
if container_runtime != PodmanRuntime():
pytest.skip("pods only work with podman")

with PodLauncher(pod=TEST_POD, rootdir=pytestconfig.rootpath) as launcher:
pidfile_path = str(tmp_path / "pidfile")
with PodLauncher(
pod=TEST_POD,
rootdir=pytestconfig.rootpath,
extra_pod_create_args=["--pod-id-file", pidfile_path],
) as launcher:
launcher.launch_pod()
pod_data = launcher.pod_data
assert pod_data.pod_id and pod_data.infra_container_id

with open(pidfile_path, encoding="utf-8") as pyproject:
assert pod_data.pod_id == pyproject.read()

assert (
len(pod_data.forwarded_ports) == 2
and pod_data.forwarded_ports[0].container_port == 80
Expand Down

0 comments on commit 70de2e0

Please sign in to comment.