From e93b9bde684c3cc90cfbc3dda25b3a516084fd00 Mon Sep 17 00:00:00 2001 From: Kevin Longe <273747162+kvlonge@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:04:25 +0000 Subject: [PATCH] test(location): rebuild past the changed-build order skew before replanning The served-location replan test failed intermittently in CI: after a rebuild and its sync, the location reported daily_orders, order_count and orders as changed instead of nothing. `--changed` compares a relation with each of its executions within 5 s of its newest, so a rebuild that starts within 5 s of the previous build still reports that build's edit and its consumers' inputs as unknown. Locally the rebuild started 5.6 s after the first build; a faster runner started it inside the window. With the window widened to 10 s the test failed every time with exactly the CI report. The test now starts the rebuild at least the order skew after the first build returned. The publication tests share one ORDER_SKEW_SECONDS instead of each defining it. --- .../sqlbuild/compiler/compiled_project/publication/helpers.py | 3 +++ .../compiler/compiled_project/publication/test_changed.py | 2 +- .../compiled_project/publication/test_plan_preview.py | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/integration/src/sqlbuild/compiler/compiled_project/publication/helpers.py b/tests/integration/src/sqlbuild/compiler/compiled_project/publication/helpers.py index a2ed27e6c1..69dd5117fc 100644 --- a/tests/integration/src/sqlbuild/compiler/compiled_project/publication/helpers.py +++ b/tests/integration/src/sqlbuild/compiler/compiled_project/publication/helpers.py @@ -1556,6 +1556,9 @@ def tagged_model(name: str, tags: str) -> str: ) +# `--changed` compares a relation with each of its executions this close to its newest, so a +# rebuild sooner than this after a build still reports that build's edits and inputs. +ORDER_SKEW_SECONDS: float = 5.2 CHANGED_FIXTURE: Path = Path("benchmarks/duckshop/edge_cases/changed_builds") CHANGED_JOB: str = ( 'name = "changed_orders_job"\n' diff --git a/tests/integration/src/sqlbuild/compiler/compiled_project/publication/test_changed.py b/tests/integration/src/sqlbuild/compiler/compiled_project/publication/test_changed.py index 10f655d911..cddcad4a5b 100644 --- a/tests/integration/src/sqlbuild/compiler/compiled_project/publication/test_changed.py +++ b/tests/integration/src/sqlbuild/compiler/compiled_project/publication/test_changed.py @@ -11,6 +11,7 @@ ChangedJobTestCase, ) from tests.integration.src.sqlbuild.compiler.compiled_project.publication.helpers import ( + ORDER_SKEW_SECONDS, changed_job_files, duckdb_rows, request_job_run, @@ -18,7 +19,6 @@ sqlite_rows, ) -ORDER_SKEW_SECONDS: float = 5.2 EXPECTED_CHANGED_RUNS: tuple[tuple[str, frozenset[str], dict[str, int]], ...] = ( ("first run", frozenset({"stg_orders", "stg_customers", "customer_orders"}), {"success": 3}), ("nothing changed", frozenset(), {"success": 3}), diff --git a/tests/integration/src/sqlbuild/compiler/compiled_project/publication/test_plan_preview.py b/tests/integration/src/sqlbuild/compiler/compiled_project/publication/test_plan_preview.py index 1b1718ca42..793533dc8a 100644 --- a/tests/integration/src/sqlbuild/compiler/compiled_project/publication/test_plan_preview.py +++ b/tests/integration/src/sqlbuild/compiler/compiled_project/publication/test_plan_preview.py @@ -5,6 +5,7 @@ import sqlite3 import subprocess import sys +import time from contextlib import closing from pathlib import Path from textwrap import dedent @@ -28,6 +29,7 @@ request_warehouse_sync, ) from tests.integration.src.sqlbuild.compiler.compiled_project.publication.helpers import ( + ORDER_SKEW_SECONDS, changed_build_and_plan_from_copy, changed_build_report, changed_runs, @@ -386,6 +388,7 @@ def test_given_a_served_location_when_syncs_complete_then_it_replans_only_after_ write_files(project_dir=project, files=_PROJECT_FILES) built: subprocess.CompletedProcess[str] = run_sqb(project, "build", "--target", "development") assert built.returncode == 0, built.stderr + built_at: float = time.monotonic() edited: str = _PROJECT_FILES["models/order_count.sql"].replace(*test_case.edit) write_files(project_dir=project, files={"models/order_count.sql": edited}) control: Path = tmp_path / "control/.sqlbuild/control.sqlite3" @@ -433,6 +436,7 @@ def changed_build() -> dict[str, list[str]]: _ = wait_for_location_work(api, request_plan(control, ["model:orders"]), location, log) assert log.read_text().count(_PLANNED) == 1, "a sync that applied nothing keeps the count" + time.sleep(max(0.0, built_at + ORDER_SKEW_SECONDS - time.monotonic())) rebuilt: subprocess.CompletedProcess[str] = run_sqb( project, "build", "--target", "development" )