Skip to content

test(backup): wait for the server in two flaky backup tests - #983

Closed
LeeroyHannigan wants to merge 2 commits into
mainfrom
fix/test-move-sync-landed-row
Closed

LeeroyHannigan wants to merge 2 commits into
mainfrom
fix/test-move-sync-landed-row

Conversation

@LeeroyHannigan

Copy link
Copy Markdown
Collaborator

What

Two tests in tests/test_backup_job.py read the server's output before the server wrote what they check. Each test now waits for it.

test_a_row_that_lands_during_the_moves_sync_exits_1:

  • The move writes its output to a pipe. The test stops reading the pipe when the move prints that it syncs the configured store.
  • The sync then prints one line for each of the 2,000 junk prefixes, about 160 KB. The pipe fills, and the move stops before it reads the other stores' rows.
  • The test lets the held CreateBackup insert go and checks that the job's row is in the catalog under the old root. Then it reads the rest of the output.
  • _read_until moves from tests/test_cli_migrate_concurrency.py to tests/lifecycle_helpers.py, and both test modules use it.

test_a_tampered_data_file_fails_the_restore_before_any_item now uses _restore_fails, as the other failing-restore tests in the file do. The helper polls the server log for the FAILED line for up to 15 s after the target is gone.

Both tests check what they checked before. No production code changes.

Why

Both tests failed on main and in the merge queue.

  • The move test let the insert go when the move printed that line. Then it depended on the sync's listing taking longer than the insert's commit. On a fast runner the sync read the other stores' rows first. It found no row of the old root, so the report did not name the job's row. It failed this way on main at 89b9427 and 9a1105b, and in the merge queue for build: make the workspace crates packageable for crates.io #927 and fix(storage-mongodb): store each access key ID once #823.
  • The tampered-file test read the server log once, as soon as DescribeTable answered that the target was gone. The restore job writes its FAILED line after it removes the target, so the test could read the log before the line was there. It failed this way on main at bf5ea8f and 511d6c7.

Testing done

I ran the tests in a container as root, where root owns every parent directory of the backup root, as the filesystem backup store requires. The server was a release PostgreSQL build of this branch, against PostgreSQL 16.

Test Version Runs Passed
Move test This branch 8 8
Move test This branch, with a 3 s wait before the insert goes 2 2
Move test main 5 5
Move test main, with a 3 s wait before the insert goes 5 0
Tampered-file test This branch 3 3

With the 3 s wait, main's move test fails at the same assertion as in CI, and the report shows "Rows of other stores: (none)". The wait does not change the result on this branch. The move cannot read the other stores' rows until the test reads the pipe again.

A build with the landed-row report removed from crates/app/src/cmd_backup.rs failed the move test at that assertion in 2 of 2 runs. That run used the first version of this change, which had the same assertions.

The tampered-file test failed on the SQLite shards in CI. I ran it on PostgreSQL, and CI runs it on both.

tests/test_cli_migrate_concurrency.py is the other user of _read_until. Its 3 tests pass.

Checklist

  • I have read CONTRIBUTING.md
  • All tests pass (cargo test --workspace)
  • Code is formatted (cargo fmt --check)
  • Clippy is clean (cargo clippy -- -W clippy::pedantic)
  • I have added or updated tests for new functionality
  • I have updated documentation if behavior changed
  • Breaking changes are noted below (if any)
  • If this changes the wire protocol, Storage trait, auth model, on-disk
    format, or public CLI surface, an RFC has been accepted or is linked
    below. Otherwise, an ADR captures the decision (link below).

ADR / RFC: n/a


By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.

test_a_row_that_lands_during_the_moves_sync_exits_1 let the held
CreateBackup insert go when the move printed that it syncs the
configured store. It then depended on the sync's listing of 2,000 junk
prefixes taking longer than the insert's commit. On a fast runner the
sync read the other stores' rows first and found no row of the old
root, so the report did not name the job's row. The test failed this
way on main at 89b9427 and 9a1105b, and in the merge queue for #927
and #823.

The move now writes to a pipe that the test stops reading at that line.
The sync's report of the junk prefixes fills the pipe, so the move
cannot reach its read of the other stores' rows before the test reads
again. The test reads again once the job's row is in the catalog under
the old root.

The test reads the pipe with _read_until, which moves from
tests/test_cli_migrate_concurrency.py to tests/lifecycle_helpers.py so
both tests use one copy.

Signed-off-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>
test_a_tampered_data_file_fails_the_restore_before_any_item read the
server log once, as soon as DescribeTable answered that the target was
gone. The restore job writes its FAILED line after it removes the
target, so on a fast runner the test read the log before the line was
there and found no FAILED line. The test failed this way on main at
bf5ea8f and 511d6c7.

The test now uses _restore_fails, which the other failing-restore tests
in the file use. It polls the log for the FAILED line for up to 15 s
after the target is gone, and it checks that the target stays CREATING
until it is removed.

Signed-off-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

Closing in favour of #985, which fixes these two cells and three more whose ports could collide with the server's. For the tampered cell, I asked #985 to call _restore_fails, as this PR does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant