: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(warehouse_sources): remove slow one-time backfill migration tests (#73840)
Frank Hamand61b1cf30b2e1
diff --git a/products/warehouse_sources/backend/tests/test_migration_0028.py b/products/warehouse_sources/backend/tests/test_migration_0028.pydeleted file mode 100644index a07bc1c35b05..000000000000--- a/products/warehouse_sources/backend/tests/test_migration_0028.py+++ /dev/null@@ -1,54 +0,0 @@-from typing import Any--from posthog.test.base import NonAtomicTestMigrations---class BackfillDirectQueryEnabledMigrationTest(NonAtomicTestMigrations):- """0028 defaults every row to True. The backfill must opt existing synced (warehouse) sources out so- the direct-connect capability gate only lights up sources a user explicitly enables; direct sources- keep True.-- NonAtomic: setUp's MigrationExecutor spends minutes CPU-bound building migration project state.- Under the atomic TestCase wrapper the connection sits idle in transaction for that whole stretch,- tripping the CI/dev Postgres idle_in_transaction_session_timeout (300s), which kills the session- mid-test with "the connection is closed".- """-- migrate_from = "0028_externaldatasource_direct_query_enabled"- migrate_to = "0029_backfill_externaldatasource_direct_query_enabled"-- @property- def app(self) -> str:- return "warehouse_sources"-- def setUpBeforeMigration(self, apps: Any) -> None:- Organization = apps.get_model("posthog", "Organization")- Project = apps.get_model("posthog", "Project")- Team = apps.get_model("posthog", "Team")- ExternalDataSource = apps.get_model("warehouse_sources", "ExternalDataSource")- self.ExternalDataSource = ExternalDataSource-- org = Organization.objects.create(name="Org")- project = Project.objects.create(id=999_999, organization=org, name="Proj")- team = Team.objects.create(organization=org, project=project, name="Team")-- def make(access_method: str) -> str:- return ExternalDataSource.objects.create(- team=team,- source_id="src",- connection_id="conn",- status="Completed",- source_type="Postgres",- access_method=access_method,- ).id-- self.warehouse_id = make("warehouse")- self.direct_id = make("direct")-- def test_warehouse_source_is_disabled(self) -> None:- source = self.ExternalDataSource.objects.get(id=self.warehouse_id)- assert source.direct_query_enabled is False-- def test_direct_source_stays_enabled(self) -> None:- source = self.ExternalDataSource.objects.get(id=self.direct_id)- assert source.direct_query_enabled is Truediff --git a/products/warehouse_sources/backend/tests/test_migration_0052.py b/products/warehouse_sources/backend/tests/test_migration_0052.pydeleted file mode 100644index f8d0d841be0c..000000000000--- a/products/warehouse_sources/backend/tests/test_migration_0052.py+++ /dev/null@@ -1,79 +0,0 @@-from typing import Any--from posthog.test.base import NonAtomicTestMigrations---class BackfillGoogleAdsIncrementalLookbackMigrationTest(NonAtomicTestMigrations):- """0051 backfills a default incremental lookback onto existing Google Ads incremental stats- schemas, which were created before the source set one and so re-fetch only the newest day,- freezing every prior day at its first-imported, not-yet-final value. It must touch only Google- Ads incremental schemas with no lookback yet — never full_refresh, never other sources, never a- soft-deleted row, and never an explicit user value (including 0, which means "no overlap").- """-- # NonAtomic: setUp rewinds from the current schema down to migrate_from, which crosses the- # concurrent (atomic = False) index migrations later in the app — reversing a CREATE INDEX- # CONCURRENTLY can't run inside TestMigrations' wrapping transaction.- migrate_from = "0051_warehousecolumnstatistics"- migrate_to = "0052_backfill_google_ads_incremental_lookback"-- DEFAULT = 30 * 24 * 60 * 60-- @property- def app(self) -> str:- return "warehouse_sources"-- def setUpBeforeMigration(self, apps: Any) -> None:- Organization = apps.get_model("posthog", "Organization")- Project = apps.get_model("posthog", "Project")- Team = apps.get_model("posthog", "Team")- ExternalDataSource = apps.get_model("warehouse_sources", "ExternalDataSource")- ExternalDataSchema = apps.get_model("warehouse_sources", "ExternalDataSchema")- self.ExternalDataSchema = ExternalDataSchema-- org = Organization.objects.create(name="Org")- project = Project.objects.create(id=987_654, organization=org, name="Proj")- team = Team.objects.create(organization=org, project=project, name="Team")-- google = ExternalDataSource.objects.create(- team=team, source_id="g", connection_id="cg", status="Completed", source_type="GoogleAds"- )- postgres = ExternalDataSource.objects.create(- team=team, source_id="p", connection_id="cp", status="Completed", source_type="Postgres"- )-- incremental = {"incremental_field": "segments.date", "incremental_field_type": "date"}-- def make(source, name, sync_type, config, deleted=False) -> str:- return ExternalDataSchema.objects.create(- team=team, source=source, name=name, sync_type=sync_type, sync_type_config=config, deleted=deleted- ).id-- self.needs_backfill_id = make(google, "campaign_stats", "incremental", {**incremental})- self.explicit_value_id = make(- google, "ad_stats", "incremental", {**incremental, "incremental_field_lookback_seconds": 86_400}- )- self.explicit_zero_id = make(- google, "keyword_stats", "incremental", {**incremental, "incremental_field_lookback_seconds": 0}- )- self.full_refresh_id = make(google, "campaign", "full_refresh", {})- self.other_source_id = make(- postgres, "users", "incremental", {"incremental_field": "updated_at", "incremental_field_type": "timestamp"}- )- self.deleted_id = make(google, "video_stats", "incremental", {**incremental}, deleted=True)-- def _config(self, schema_id: str) -> dict:- return self.ExternalDataSchema.objects.get(id=schema_id).sync_type_config-- def test_backfills_only_google_ads_incremental_schemas_missing_a_lookback(self) -> None:- # The broken case the migration fixes: a Google Ads incremental schema with no lookback.- assert self._config(self.needs_backfill_id)["incremental_field_lookback_seconds"] == self.DEFAULT-- # An explicit user value is preserved — including 0, which means "no overlap re-read".- assert self._config(self.explicit_value_id)["incremental_field_lookback_seconds"] == 86_400- assert self._config(self.explicit_zero_id)["incremental_field_lookback_seconds"] == 0-- # Untouched: full_refresh (lookback is a no-op there), other source types, soft-deleted rows.- assert "incremental_field_lookback_seconds" not in self._config(self.full_refresh_id)- assert "incremental_field_lookback_seconds" not in self._config(self.other_source_id)- assert "incremental_field_lookback_seconds" not in self._config(self.deleted_id)