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.

fix(cohorts): de-flake performed_event_regularly variable counts test (#62700)

Raúl Negrón-Oteroe97b08d54bbe
diff --git a/ee/clickhouse/queries/test/test_cohort_query.py b/ee/clickhouse/queries/test/test_cohort_query.py
index f06f85368fa0..74f7ff6556fd 100644
--- a/ee/clickhouse/queries/test/test_cohort_query.py
+++ b/ee/clickhouse/queries/test/test_cohort_query.py
@@ -1086,6 +1086,12 @@ class TestCohortQuery(ClickhouseTestMixin, BaseTest):
assert sorted([p1.uuid, p2.uuid]) == sorted([r[0] for r in res])
def test_performed_event_regularly_with_variable_event_counts_in_each_period(self):
+ # Pin to midnight so events at now-12h stay on yesterday: the cohort date range ends
+ # at "-1d", so when CI runs after noon UTC those events land on today and get excluded
+ with freeze_time(datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)):
+ self._assert_performed_event_regularly_with_variable_event_counts()
+
+ def _assert_performed_event_regularly_with_variable_event_counts(self):
p1 = _create_person(
team_id=self.team.pk,
distinct_ids=["p1"],