Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,13 @@ def test_given_one_invocation_lookup_when_planned_then_each_table_is_read_once_b
assert run(project_dir, "build").returncode == 0
# A command that ends before its first heartbeat writes none, and ClickHouse plans a table
# with no parts as a read of nothing, so give the heartbeats table a part before planning.
# The row starts now: an expired TTL would drop it on insert and its empty part soon after.
execute_clickhouse_sql(
config=clickhouse_e2e_config,
statements=(
f"INSERT INTO {recall_database}.recall_heartbeats (invocation_id) "
"VALUES ('planning-setup')",
f"INSERT INTO {recall_database}.recall_heartbeats "
"(invocation_id, invocation_started_at, beat_at, stale_at) "
"VALUES ('planning-setup', now64(6), now64(6), now64(6))",
),
)
sql: str = (
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/src/sqlbuild/cli/recall/_test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ class HeldLockTestCase:
builds_before_lock: int
expected_exit_code: int
expected_notice: str
expected_failed_records: int
expected_recorded_builds: int
#: Far beyond the budget; only a build that waits for the lock itself reaches it.
hang_guard_seconds: float

Expand Down
1 change: 1 addition & 0 deletions tests/integration/src/sqlbuild/cli/recall/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
STOP_HANG_SECONDS: int = 120
EMPTY_RESULT: bytes = b'{"rows": []}'
NUMBERED_LINE: re.Pattern[bytes] = re.compile(rb"^(\d+) std(?:out|err)$", re.MULTILINE)
INCOMPLETE_HISTORY: re.Pattern[str] = re.compile(r"incomplete \((\d+) dropped, (\d+) failed\)")
PROJECT_TOML: str = (
'name = "orders_shop"\n'
'adapter = "duckdb"\n'
Expand Down
13 changes: 13 additions & 0 deletions tests/integration/src/sqlbuild/cli/recall/test_local_recall.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
EMITTED_STDERR,
EMITTED_STDOUT,
EMITTED_TAIL,
INCOMPLETE_HISTORY,
MEBIBYTE,
build_while_store_locked,
build_with_failing_recall_notices,
Expand Down Expand Up @@ -546,6 +547,8 @@ def test_given_a_successful_command_when_recorded_then_it_ends_completed(
builds_before_lock=1,
expected_exit_code=0,
expected_notice="Recall delivery did not finish within the shutdown timeout",
expected_failed_records=0,
expected_recorded_builds=2,
hang_guard_seconds=60.0,
),
HeldLockTestCase(
Expand All @@ -554,6 +557,8 @@ def test_given_a_successful_command_when_recorded_then_it_ends_completed(
builds_before_lock=0,
expected_exit_code=0,
expected_notice="Recall delivery did not finish within the shutdown timeout",
expected_failed_records=0,
expected_recorded_builds=1,
hang_guard_seconds=60.0,
),
],
Expand All @@ -568,10 +573,18 @@ def test_given_a_locked_store_when_building_then_it_gives_up_at_the_shutdown_dea
)

locked, locked_total = build_while_store_locked(project_dir)
unlocked: subprocess.CompletedProcess[bytes] = run(project_dir, "build")
recorded_builds: list[list[object]] = recall_rows(
project_dir, "SELECT count(*) FROM invocations WHERE command = 'build'"
)

stderr: str = locked.stderr.decode(errors="replace")
assert locked.returncode == test_case.expected_exit_code
assert test_case.expected_notice in stderr
assert [
(int(dropped) > 0, int(failed)) for dropped, failed in INCOMPLETE_HISTORY.findall(stderr)
] == [(True, test_case.expected_failed_records)], stderr
assert (unlocked.returncode, recorded_builds) == (0, [[test_case.expected_recorded_builds]])
assert stderr.rstrip().endswith("completed successfully; only its Recall history is affected.")
assert locked_total < test_case.hang_guard_seconds, stderr

Expand Down
Loading