-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathgateway_config_fixture_test.py
More file actions
72 lines (55 loc) · 2.54 KB
/
Copy pathgateway_config_fixture_test.py
File metadata and controls
72 lines (55 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
"""Schema-only checks for E2E gateway fixtures; these do not start a runtime."""
from __future__ import annotations
import tomllib
from pathlib import Path
import pytest
import yaml
REPO_ROOT = Path(__file__).resolve().parents[2]
FIXTURE_DIR = REPO_ROOT / "e2e/configs/gateway"
TEST_GUEST_ROLE_PATH = (
REPO_ROOT
/ "nix/test-guest/provisioners/roles/gateway-podman/tasks/development-gateway.yml"
)
@pytest.mark.parametrize(
("fixture_name", "driver"),
[("docker.toml", "docker"), ("podman.toml", "podman")],
)
def test_e2e_gateway_fixtures_use_schema_v2_scalar_driver(
fixture_name: str, driver: str
) -> None:
config = tomllib.loads((FIXTURE_DIR / fixture_name).read_text(encoding="utf-8"))
gateway = config["openshell"]["gateway"]
assert config["openshell"]["version"] == 2
assert gateway["compute_driver"] == driver
assert "compute_drivers" not in gateway
assert "sandbox_namespace" not in gateway
def test_podman_test_guest_producer_uses_schema_v2() -> None:
tasks = yaml.safe_load(TEST_GUEST_ROLE_PATH.read_text(encoding="utf-8"))
producer = next(
task
for task in tasks
if task.get("name") == "Write development Podman gateway configuration"
)
content = producer["ansible.builtin.copy"]["content"]
config = tomllib.loads(content)
gateway = config["openshell"]["gateway"]
assert config["openshell"]["version"] == 2
assert gateway["compute_driver"] == "podman"
assert "compute_drivers" not in gateway
assert "ttl_secs" not in gateway["gateway_jwt"]
assert "podman" in config["openshell"]["drivers"]
def test_docker_e2e_gateway_fixture_uses_canonical_policy_and_label() -> None:
config = tomllib.loads((FIXTURE_DIR / "docker.toml").read_text(encoding="utf-8"))
docker = config["openshell"]["drivers"]["docker"]
assert docker["image_pull_policy"] == "if_not_present"
assert docker["sandbox_label"] == "openshell-e2e"
assert "sandbox_namespace" not in docker
def test_podman_e2e_gateway_fixture_uses_canonical_policy_and_callbacks() -> None:
config = tomllib.loads((FIXTURE_DIR / "podman.toml").read_text(encoding="utf-8"))
podman = config["openshell"]["drivers"]["podman"]
assert podman["image_pull_policy"] == "if_not_present"
assert podman["health_check_interval_secs"] == 10
assert podman["ssh_socket_path"] == "/run/openshell/ssh.sock"
assert "sandbox_namespace" not in podman