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(batch-exports): remove workflow deadline from time-skipping tests (#73641)

Raúl Negrón-Otero6b284f965cfc
diff --git a/products/batch_exports/backend/tests/temporal/destinations/postgres/test_workflow.py b/products/batch_exports/backend/tests/temporal/destinations/postgres/test_workflow.py
index 58960bc80940..7a1bed3646bd 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/postgres/test_workflow.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/postgres/test_workflow.py
@@ -31,7 +31,10 @@ from products.batch_exports.backend.tests.temporal.destinations.postgres.utils i
TEST_MODELS,
assert_clickhouse_records_in_postgres,
)
-from products.batch_exports.backend.tests.temporal.utils.workflow import mocked_start_batch_export_run
+from products.batch_exports.backend.tests.temporal.utils.workflow import (
+ WORKFLOW_REAL_TIME_LIMIT_SECONDS,
+ mocked_start_batch_export_run,
+)
pytestmark = [
pytest.mark.asyncio,
@@ -109,13 +112,15 @@ async def test_postgres_export_workflow(
workflow_runner=UnsandboxedWorkflowRunner(),
):
with override_settings(BATCH_EXPORT_POSTGRES_UPLOAD_CHUNK_SIZE_BYTES=5 * 1024**2):
- await activity_environment.client.execute_workflow(
- PostgresBatchExportWorkflow.run,
- inputs,
- id=workflow_id,
- task_queue=settings.BATCH_EXPORTS_TASK_QUEUE,
- retry_policy=RetryPolicy(maximum_attempts=1),
- execution_timeout=dt.timedelta(seconds=10),
+ await asyncio.wait_for(
+ activity_environment.client.execute_workflow(
+ PostgresBatchExportWorkflow.run,
+ inputs,
+ id=workflow_id,
+ task_queue=settings.BATCH_EXPORTS_TASK_QUEUE,
+ retry_policy=RetryPolicy(maximum_attempts=1),
+ ),
+ timeout=WORKFLOW_REAL_TIME_LIMIT_SECONDS,
)
runs = await afetch_batch_export_runs(batch_export_id=postgres_batch_export.id)
@@ -203,13 +208,15 @@ async def test_postgres_export_workflow_with_integration(
workflow_runner=UnsandboxedWorkflowRunner(),
):
with override_settings(BATCH_EXPORT_POSTGRES_UPLOAD_CHUNK_SIZE_BYTES=5 * 1024**2):
- await activity_environment.client.execute_workflow(
- PostgresBatchExportWorkflow.run,
- inputs,
- id=workflow_id,
- task_queue=settings.BATCH_EXPORTS_TASK_QUEUE,
- retry_policy=RetryPolicy(maximum_attempts=1),
- execution_timeout=dt.timedelta(seconds=10),
+ await asyncio.wait_for(
+ activity_environment.client.execute_workflow(
+ PostgresBatchExportWorkflow.run,
+ inputs,
+ id=workflow_id,
+ task_queue=settings.BATCH_EXPORTS_TASK_QUEUE,
+ retry_policy=RetryPolicy(maximum_attempts=1),
+ ),
+ timeout=WORKFLOW_REAL_TIME_LIMIT_SECONDS,
)
runs = await afetch_batch_export_runs(batch_export_id=postgres_batch_export.id)
@@ -289,13 +296,15 @@ async def test_postgres_export_workflow_without_events(
workflow_runner=UnsandboxedWorkflowRunner(),
):
with override_settings(BATCH_EXPORT_POSTGRES_UPLOAD_CHUNK_SIZE_BYTES=5 * 1024**2):
- await activity_environment.client.execute_workflow(
- PostgresBatchExportWorkflow.run,
- inputs,
- id=workflow_id,
- task_queue=settings.BATCH_EXPORTS_TASK_QUEUE,
- retry_policy=RetryPolicy(maximum_attempts=1),
- execution_timeout=dt.timedelta(seconds=10),
+ await asyncio.wait_for(
+ activity_environment.client.execute_workflow(
+ PostgresBatchExportWorkflow.run,
+ inputs,
+ id=workflow_id,
+ task_queue=settings.BATCH_EXPORTS_TASK_QUEUE,
+ retry_policy=RetryPolicy(maximum_attempts=1),
+ ),
+ timeout=WORKFLOW_REAL_TIME_LIMIT_SECONDS,
)
runs = await afetch_batch_export_runs(batch_export_id=postgres_batch_export.id)
diff --git a/products/batch_exports/backend/tests/temporal/destinations/snowflake/test_workflow.py b/products/batch_exports/backend/tests/temporal/destinations/snowflake/test_workflow.py
index d9736fabd0da..a19b798908f2 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/snowflake/test_workflow.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/snowflake/test_workflow.py
@@ -37,7 +37,10 @@ from products.batch_exports.backend.tests.temporal.destinations.snowflake.utils
TEST_TIME,
FakeSnowflakeConnection,
)
-from products.batch_exports.backend.tests.temporal.utils.workflow import mocked_start_batch_export_run
+from products.batch_exports.backend.tests.temporal.utils.workflow import (
+ WORKFLOW_REAL_TIME_LIMIT_SECONDS,
+ mocked_start_batch_export_run,
+)
pytestmark = [
pytest.mark.asyncio,
@@ -76,13 +79,15 @@ async def _run_workflow(
workflow_runner=UnsandboxedWorkflowRunner(),
),
):
- await activity_environment.client.execute_workflow(
- SnowflakeBatchExportWorkflow.run,
- inputs,
- id=workflow_id,
- execution_timeout=dt.timedelta(seconds=10),
- task_queue=settings.BATCH_EXPORTS_TASK_QUEUE,
- retry_policy=RetryPolicy(maximum_attempts=1),
+ await asyncio.wait_for(
+ activity_environment.client.execute_workflow(
+ SnowflakeBatchExportWorkflow.run,
+ inputs,
+ id=workflow_id,
+ task_queue=settings.BATCH_EXPORTS_TASK_QUEUE,
+ retry_policy=RetryPolicy(maximum_attempts=1),
+ ),
+ timeout=WORKFLOW_REAL_TIME_LIMIT_SECONDS,
)
runs = await afetch_batch_export_runs(batch_export_id=snowflake_batch_export.id)
diff --git a/products/batch_exports/backend/tests/temporal/utils/workflow.py b/products/batch_exports/backend/tests/temporal/utils/workflow.py
index dff6dc7957af..eda6598ba82f 100644
--- a/products/batch_exports/backend/tests/temporal/utils/workflow.py
+++ b/products/batch_exports/backend/tests/temporal/utils/workflow.py
@@ -12,6 +12,12 @@ from products.batch_exports.backend.models.batch_export import BatchExportRun
from products.batch_exports.backend.service import create_batch_export_run
from products.batch_exports.backend.temporal.batch_exports import StartBatchExportRunInputs
+# Guards against a workflow that never settles. Deliberately real time, not a Temporal
+# `execution_timeout`: the time-skipping environment charges both real activity time and fast-forwarded
+# retry backoffs against a workflow deadline, so it expires for reasons unrelated to the behavior under
+# test and reports `TimeoutError` in place of the error being asserted on.
+WORKFLOW_REAL_TIME_LIMIT_SECONDS = 60
+
@activity.defn(name="start_batch_export_run")
async def mocked_start_batch_export_run(inputs: StartBatchExportRunInputs) -> str: