Speed up the vaultik and database package tests #265

Merged
clawbot merged 1 commits from issue-235-faster-tests into next 2026-10-07 17:12:07 +02:00
Collaborator

Closes #235.

Measured in the test phase of the Dockerfile as make test runs it, with -v added locally for per-test times.

Before, internal/vaultik took 31.9s, 23.6s of it in 36 tests that ran one at a time; 24 of those were serial only because they call log.Initialize. The slowest serial tests were TestListSnapshots_JSONReportsTruncation (3.9s), the two tests in changed_file_restore_test.go (about 2s each) and TestRestoreCleansTempDirOnInterrupt (1.7s). internal/database took 9.8s, 8.4s of it in TestLargeDatasets, which committed each of its 1,500 inserts on its own.

  • The 24 tests call log.Initialize before t.Parallel(), as the package's other tests do, so the logger is replaced before any parallel test runs. The 12 still serial change the umask, TMPDIR, os.Stderr or time.Local.
  • TestLargeDatasets makes its inserts in one transaction and still creates 1,000 files.
  • TestDedupOnlySnapshotRestores names its second backup second instead of sleeping 1.1s for a new snapshot ID, as changed_file_restore_test.go does.

After, over four runs: internal/vaultik 13.3s to 14.1s, internal/database 5.2s to 6.0s.

  • Partially verified: the before figures are one run at a host load average near 60, the after runs were at lower load, so part of the drop in parallel test times is the host. The serial time (23.6s before, 5.8s after) depends little on load.
  • Not changed: TestRestoreSweeperEvictsBlobs (about 6.5s, 30 MB of random data) is now the longest test; the serial truncation test needs 1,001 manifests to pass the listing cap.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/vaultik/issues/235. Measured in the `test` phase of the `Dockerfile` as `make test` runs it, with `-v` added locally for per-test times. Before, `internal/vaultik` took 31.9s, 23.6s of it in 36 tests that ran one at a time; 24 of those were serial only because they call `log.Initialize`. The slowest serial tests were `TestListSnapshots_JSONReportsTruncation` (3.9s), the two tests in `changed_file_restore_test.go` (about 2s each) and `TestRestoreCleansTempDirOnInterrupt` (1.7s). `internal/database` took 9.8s, 8.4s of it in `TestLargeDatasets`, which committed each of its 1,500 inserts on its own. - The 24 tests call `log.Initialize` before `t.Parallel()`, as the package's other tests do, so the logger is replaced before any parallel test runs. The 12 still serial change the umask, `TMPDIR`, `os.Stderr` or `time.Local`. - `TestLargeDatasets` makes its inserts in one transaction and still creates 1,000 files. - `TestDedupOnlySnapshotRestores` names its second backup `second` instead of sleeping 1.1s for a new snapshot ID, as `changed_file_restore_test.go` does. After, over four runs: `internal/vaultik` 13.3s to 14.1s, `internal/database` 5.2s to 6.0s. - Partially verified: the before figures are one run at a host load average near 60, the after runs were at lower load, so part of the drop in parallel test times is the host. The serial time (23.6s before, 5.8s after) depends little on load. - Not changed: `TestRestoreSweeperEvictsBlobs` (about 6.5s, 30 MB of random data) is now the longest test; the serial truncation test needs 1,001 manifests to pass the listing cap. Model: opus-5-5
clawbot added the needs-review label 2026-10-07 16:13:32 +02:00
clawbot self-assigned this 2026-10-07 16:13:32 +02:00
clawbot added 1 commit 2026-10-07 16:13:32 +02:00
In the Dockerfile test phase, internal/vaultik spent 23.6s of 31.9s in
36 tests run one at a time. 24 of them were serial only because they
call log.Initialize; they now call it before t.Parallel(), so the
logger is replaced before any parallel test runs. The 12 still serial
change the umask, TMPDIR, os.Stderr or time.Local.

TestLargeDatasets took 8.4s of the 9.8s internal/database run by
committing each of its 1,500 inserts on its own; it now makes them in
one transaction. TestDedupOnlySnapshotRestores gives its second backup
its own snapshot name instead of sleeping 1.1s for a new snapshot ID.

Model: opus-5-5
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit e161343eac into next 2026-10-07 17:12:07 +02:00
clawbot deleted branch issue-235-faster-tests 2026-10-07 17:12:08 +02:00
Sign in to join this conversation.