Skip to content

Commit cc70786

Browse files
committed
fix: env pollution in iris test, extract shared helper, update docstring
- Use monkeypatch instead of os.environ mutation in test_marin_on_iris - Move _make_controller_only_config to conftest.py as shared helper - Update stale docstring in test_iris_integration.py
1 parent 97efed4 commit cc70786

5 files changed

Lines changed: 33 additions & 32 deletions

File tree

lib/iris/tests/conftest.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,38 @@
77
import os
88
import subprocess
99
import sys
10+
from pathlib import Path
1011
import threading
1112
import time
1213
import traceback
1314
import warnings
1415

1516
import pytest
17+
from iris.cluster.config import load_config, make_local_config
18+
from iris.rpc import config_pb2
1619
from iris.test_util import SentinelFile
1720
from iris.time_utils import Deadline, Duration
1821

22+
IRIS_ROOT = Path(__file__).resolve().parents[1]
23+
DEFAULT_CONFIG = IRIS_ROOT / "examples" / "test.yaml"
24+
25+
26+
def _make_controller_only_config() -> config_pb2.IrisClusterConfig:
27+
"""Build a local config with no auto-scaled workers."""
28+
config = load_config(DEFAULT_CONFIG)
29+
config.scale_groups.clear()
30+
sg = config.scale_groups["placeholder"]
31+
sg.name = "placeholder"
32+
sg.num_vms = 1
33+
sg.min_slices = 0
34+
sg.max_slices = 0
35+
sg.resources.cpu_millicores = 1000
36+
sg.resources.memory_bytes = 1 * 1024**3
37+
sg.resources.disk_bytes = 10 * 1024**3
38+
sg.resources.device_type = config_pb2.ACCELERATOR_TYPE_CPU
39+
sg.slice_template.local.SetInParent()
40+
return make_local_config(config)
41+
1942

2043
def _docker_image_exists(tag: str) -> bool:
2144
try:

lib/iris/tests/test_auth.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,18 @@
22
# SPDX-License-Identifier: Apache-2.0
33
"""Auth tests for Iris controller with static token authentication."""
44

5-
from pathlib import Path
6-
75
import pytest
8-
from iris.cluster.config import load_config, make_local_config
96
from iris.cluster.local_cluster import LocalCluster
107
from iris.cluster.types import Entrypoint, ResourceSpec
11-
from iris.rpc import cluster_pb2, config_pb2
8+
from iris.rpc import cluster_pb2
129
from iris.rpc.cluster_connect import ControllerServiceClientSync
1310

14-
IRIS_ROOT = Path(__file__).resolve().parents[1]
15-
DEFAULT_CONFIG = IRIS_ROOT / "examples" / "test.yaml"
11+
from .conftest import _make_controller_only_config
1612

1713
_AUTH_TOKEN = "e2e-test-token"
1814
_AUTH_USER = "test-user"
1915

2016

21-
def _make_controller_only_config() -> config_pb2.IrisClusterConfig:
22-
"""Build a local config with no auto-scaled workers."""
23-
config = load_config(DEFAULT_CONFIG)
24-
config.scale_groups.clear()
25-
sg = config.scale_groups["placeholder"]
26-
sg.name = "placeholder"
27-
sg.num_vms = 1
28-
sg.min_slices = 0
29-
sg.max_slices = 0
30-
sg.resources.cpu_millicores = 1000
31-
sg.resources.memory_bytes = 1 * 1024**3
32-
sg.resources.disk_bytes = 10 * 1024**3
33-
sg.resources.device_type = config_pb2.ACCELERATOR_TYPE_CPU
34-
sg.slice_template.local.SetInParent()
35-
return make_local_config(config)
36-
37-
3817
def _login_for_jwt(url: str, identity_token: str) -> str:
3918
"""Exchange a raw identity token for a JWT via the Login RPC."""
4019
client = ControllerServiceClientSync(address=url, timeout_ms=10000)

lib/iris/tests/test_gpu_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from iris.rpc.cluster_connect import ControllerServiceClientSync
1717
from iris.time_utils import Duration
1818

19-
from .test_auth import _make_controller_only_config
19+
from .conftest import _make_controller_only_config
2020

2121
_NVIDIA_SMI_H100_8X = "\n".join(["NVIDIA H100 80GB HBM3, 81559"] * 8)
2222

tests/integration/iris/test_iris_integration.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
"""Iris integration tests exercising job lifecycle, scheduling, and cluster features.
55
6-
These tests replace the "cloud smoke test" and run against either a local in-process
7-
cluster (default) or an existing controller via --controller-url. No dashboard
8-
screenshots are taken here; those remain in lib/iris/tests/e2e/test_smoke.py.
6+
These tests run against an existing controller specified via --controller-url.
7+
No dashboard screenshots are taken here; those remain in lib/iris/tests/e2e/test_smoke.py.
98
"""
109

1110
import logging

tests/integration/iris/test_marin_on_iris.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828

2929

3030
@pytest.mark.timeout(600)
31-
def test_marin_pipeline_on_iris(integration_cluster):
31+
def test_marin_pipeline_on_iris(integration_cluster, monkeypatch):
3232
"""Run the full marin data pipeline dispatched through Iris."""
3333
prefix = tempfile.mkdtemp(prefix="iris-marin-itest-")
3434
try:
35-
os.environ["MARIN_PREFIX"] = prefix
36-
os.environ.setdefault("WANDB_MODE", "disabled")
37-
os.environ.setdefault("WANDB_API_KEY", "")
38-
os.environ.setdefault("JAX_TRACEBACK_FILTERING", "off")
35+
monkeypatch.setenv("MARIN_PREFIX", prefix)
36+
monkeypatch.setenv("WANDB_MODE", "disabled")
37+
monkeypatch.setenv("WANDB_API_KEY", "")
38+
monkeypatch.setenv("JAX_TRACEBACK_FILTERING", "off")
3939

4040
iris_client = FrayIrisClient(
4141
controller_address=integration_cluster.url,

0 commit comments

Comments
 (0)