Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(alerts): stop temporal tests waiting in real time (#119645)

Raúl Negrón-Otero174f07f1e1dd
diff --git a/products/alerts/backend/test/test_platform_evaluate_workflow.py b/products/alerts/backend/test/test_platform_evaluate_workflow.py
index 4c93d1a4b2a7..579488ab3d5d 100644
--- a/products/alerts/backend/test/test_platform_evaluate_workflow.py
+++ b/products/alerts/backend/test/test_platform_evaluate_workflow.py
@@ -48,7 +48,7 @@ async def test_a_check_that_fails_does_not_stop_the_batch_recording_the_rest(env
@activity.defn(name="plan_platform_insight_round_activity")
async def plan(inputs: InsightBatchPlanInputs) -> list[str]:
- return list(ADMITTED)
+ return [configuration_id for configuration_id in ADMITTED if configuration_id not in inputs.exclude]
@activity.defn(name="evaluate_platform_insight_check_activity")
async def evaluate(inputs: InsightCheckInputs) -> SourceBatchEvaluation | None:
@@ -117,7 +117,7 @@ async def test_a_batch_over_the_payload_budget_records_in_chunks_and_starts_one_
@activity.defn(name="plan_platform_insight_round_activity")
async def plan(inputs: InsightBatchPlanInputs) -> list[str]:
- return list(ADMITTED)
+ return [configuration_id for configuration_id in ADMITTED if configuration_id not in inputs.exclude]
@activity.defn(name="evaluate_platform_insight_check_activity")
async def evaluate(inputs: InsightCheckInputs) -> SourceBatchEvaluation | None:
diff --git a/products/alerts_platform/backend/tests/test_temporal_workflows.py b/products/alerts_platform/backend/tests/test_temporal_workflows.py
index b87d2f77cc34..eda758f55949 100644
--- a/products/alerts_platform/backend/tests/test_temporal_workflows.py
+++ b/products/alerts_platform/backend/tests/test_temporal_workflows.py
@@ -86,11 +86,15 @@ def sdk_metrics() -> MetricBuffer:
return MetricBuffer(10000)
-@pytest_asyncio.fixture(scope="module")
-async def environment(
- sdk_metrics: MetricBuffer, span_exporter: InMemorySpanExporter
-) -> AsyncIterator[WorkflowEnvironment]:
- runtime = Runtime(telemetry=TelemetryConfig(metrics=sdk_metrics))
[email protected](scope="module")
+def runtime(sdk_metrics: MetricBuffer) -> Runtime:
+ return Runtime(telemetry=TelemetryConfig(metrics=sdk_metrics))
+
+
+# One server per test: once a parent closes with an abandoned child, the time-skipping test server
+# stops skipping time, and every later test on that server waits out its timers in real time.
+@pytest_asyncio.fixture
+async def environment(runtime: Runtime, span_exporter: InMemorySpanExporter) -> AsyncIterator[WorkflowEnvironment]:
async with await WorkflowEnvironment.start_time_skipping(
runtime=runtime, plugins=[OpenTelemetryPlugin(add_temporal_spans=True)]
) as env: