Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion python/lib/sift_client/_tests/util/test_test_results_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
from datetime import datetime, timezone

import numpy as np
Expand All @@ -16,11 +17,46 @@
assign_value_to_measurement,
evaluate_measurement_bounds,
)
from sift_client.util.test_results.context_manager import NewStep
from sift_client.util.test_results.context_manager import NewStep, ReportContext

pytestmark = pytest.mark.integration


class TestLogReplay:
"""Test that the incremental replay subprocess creates real API objects."""

def test_replay_creates_report(self, sift_client):
unique_name = f"replay-test-{datetime.now(timezone.utc).isoformat()}"

with ReportContext(
sift_client,
name=unique_name,
test_case="test_replay_creates_report",
log_file=True,
) as rc:
with rc.new_step(name="Step A") as step_a:
with step_a.substep(name="Step A.1"):
pass
with rc.new_step(name="Step B"):
pass

# Wait to ensure the report creation has completed.
time.sleep(2)

reports = sift_client.test_results.list_(name=unique_name)
assert len(reports) >= 1, f"Expected report '{unique_name}' to be created by replay"
replay_report = reports[0]
assert replay_report.name == unique_name

steps = sift_client.test_results.list_steps(test_reports=[replay_report])
step_names = {s.name for s in steps}
assert "Step A" in step_names
assert "Step A.1" in step_names
assert "Step B" in step_names

sift_client.test_results.delete(test_report=replay_report)


class TestContextManager:
def test_link_run_to_report(self, report_context, nostromo_run):
report_context.report.update({"run_id": nostromo_run.id_})
Expand Down
3 changes: 3 additions & 0 deletions python/lib/sift_client/transport/grpc_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import asyncio
import atexit
import logging
import os
import threading
from typing import Any
from urllib.parse import urlparse
Expand Down Expand Up @@ -98,6 +99,8 @@ def __init__(self, config: GrpcConfig):
Args:
config: The gRPC client configuration.
"""
os.environ.setdefault("GRPC_ENABLE_FORK_SUPPORT", "0")

self._config = config
# map each asyncio loop to its async channel and stub dict
self._channels_async: dict[asyncio.AbstractEventLoop, Any] = {}
Expand Down
Loading