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(tests): stop unrunnable tests reading as broken in trunk (#101213)

Georges-Antoine Assi310d58205c9b
diff --git a/posthog/test/test_gzip_middleware.py b/posthog/test/test_gzip_middleware.py
index 131dd34b824c..3ddf1f866808 100644
--- a/posthog/test/test_gzip_middleware.py
+++ b/posthog/test/test_gzip_middleware.py
@@ -1,6 +1,5 @@
from posthog.test.base import APIBaseTest
from pytest import raises
-from unittest import skip
from rest_framework import status
@@ -21,15 +20,6 @@ class TestGzipMiddleware(APIBaseTest):
contentEncoding = response.headers.get("Content-Encoding", None)
self.assertEqual(contentEncoding, None)
- @skip("fails in CI, but covered by test in test_clickhouse_session_recording")
- def test_compresses_when_on_allow_list(self) -> None:
- with self.settings(GZIP_RESPONSE_ALLOW_LIST=["something-else", "/home"]):
- response = self._get_path("/home")
- self.assertEqual(response.status_code, status.HTTP_200_OK)
-
- contentEncoding = response.headers.get("Content-Encoding", None)
- self.assertEqual(contentEncoding, "gzip")
-
def test_no_compression_for_unsuccessful_requests_to_paths_on_the_allow_list(self) -> None:
with self.settings(GZIP_RESPONSE_ALLOW_LIST=["something-else", "snapshots$"]):
response = self._get_path(f"/api/projects/{self.team.pk}/session_recordings/blah/snapshots")
diff --git a/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_api.py b/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_api.py
index a292dcb02cb8..7fcfc84ff3d2 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_api.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_api.py
@@ -38,13 +38,17 @@ from products.batch_exports.backend.models.batch_export import (
BatchExportSource,
)
from products.batch_exports.backend.temporal import ACTIVITIES, WORKFLOWS
+from products.batch_exports.backend.tests.temporal.destinations.s3.utils import has_valid_credentials
pytestmark = [
pytest.mark.asyncio,
pytest.mark.django_db,
]
+requires_aws_credentials = pytest.mark.requires_vendor_credentials(check=has_valid_credentials)
+
+@requires_aws_credentials
async def test_can_generate_s3_pre_signed_url(s3_client, s3_bucket, aws_role_arn):
"""Test we can generate a S3 pre signed URL for some test data."""
key = f"batch-exports/{str(uuid.uuid4())}"
@@ -265,7 +269,6 @@ async def test_file_download_retrieve_returns_empty_when_no_data_exported(
assert data["files"] == []
[email protected]("override_file_download_settings")
@pytest.mark.django_db(transaction=True)
async def test_file_download_download_fails_when_not_completed(
async_client: AsyncClient, temporal_client, team, user, data_interval_start, data_interval_end, generate_test_data
@@ -297,6 +300,7 @@ async def test_file_download_download_fails_when_not_completed(
assert b"still in progress" in response.content
+@requires_aws_credentials
@pytest.mark.usefixtures("override_file_download_settings")
@pytest.mark.django_db(transaction=True)
async def test_file_download_download(
@@ -497,6 +501,7 @@ async def test_file_download_list_returns_run_ids_and_statuses(
]
+@requires_aws_credentials
@pytest.mark.usefixtures("override_file_download_settings")
@pytest.mark.django_db(transaction=True)
async def test_file_download_end_to_end(
@@ -812,6 +817,7 @@ class TestFileDownloadHogQL:
assert batch_export_model.hogql_query == hogql_query
assert mock_start_file_download_export.call_args.kwargs["max_size_mb"] == DEFAULT_MAX_SIZE_MB
+ @requires_aws_credentials
@pytest.mark.usefixtures("override_file_download_settings", "enable_hogql_flag")
@pytest.mark.django_db(transaction=True)
async def test_end_to_end(self, async_client: AsyncClient, temporal_client, team, user, hogql_export_test_events):
diff --git a/products/tasks/backend/temporal/process_task/tests/test_workflow.py b/products/tasks/backend/temporal/process_task/tests/test_workflow.py
index 58ab6d5002fb..b957f57f7fe0 100644
--- a/products/tasks/backend/temporal/process_task/tests/test_workflow.py
+++ b/products/tasks/backend/temporal/process_task/tests/test_workflow.py
@@ -206,9 +206,18 @@ class TestProcessTaskWorkflow:
).encode()
server = Path(__file__).with_name("workflow_api.py").read_bytes()
+ def task_api_is_already_serving(sandbox: SandboxBase) -> bool:
+ result = sandbox.execute(
+ "curl --fail --silent --max-time 2 http://127.0.0.1:8765/health",
+ timeout_seconds=30,
+ )
+ return result.exit_code == 0
+
def prepare_api(sandbox: SandboxBase) -> None:
# The remote agent cannot read this process's test database. Serve its
# task context inside the sandbox, without sending a prompt to an LLM.
+ if task_api_is_already_serving(sandbox):
+ return
for path, content in [("/tmp/workflow-api.json", payload), ("/tmp/workflow_api.py", server)]:
result = sandbox.write_file(path, content)
assert result.exit_code == 0, result.stderr