Skip to content

Commit c459566

Browse files
committed
Use lightweight fixtures for standby compression tests
1 parent 9f3a5ce commit c459566

2 files changed

Lines changed: 66 additions & 4 deletions

File tree

lib/instances/snapshot_compression_test.go

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"time"
1111

1212
"github.com/kernel/hypeman/lib/hypervisor"
13+
"github.com/kernel/hypeman/lib/paths"
1314
snapshotstore "github.com/kernel/hypeman/lib/snapshot"
1415
"github.com/stretchr/testify/assert"
1516
"github.com/stretchr/testify/require"
@@ -405,10 +406,22 @@ func assertCompressionJobCanceled(t *testing.T, mgr *manager, target *compressio
405406
}, time.Second, 10*time.Millisecond)
406407
}
407408

409+
func newSnapshotCompressionTestManager(t *testing.T) *manager {
410+
t.Helper()
411+
412+
p := paths.New(t.TempDir())
413+
return &manager{
414+
paths: p,
415+
now: time.Now,
416+
compressionJobs: make(map[string]*compressionJob),
417+
stateSubscribers: newSubscribers(),
418+
}
419+
}
420+
408421
func TestStartCompressionJobDelayedCancellationRecordsSkipped(t *testing.T) {
409422
t.Parallel()
410423

411-
mgr, _ := setupTestManager(t)
424+
mgr := newSnapshotCompressionTestManager(t)
412425
delay := 45 * time.Second
413426
timer := newFakeCompressionTimer()
414427
mgr.compressionTimerFactory = func(got time.Duration) compressionTimer {
@@ -455,7 +468,9 @@ func TestStartCompressionJobDelayedCancellationRecordsSkipped(t *testing.T) {
455468
}
456469

457470
func TestRecoverPendingStandbyCompressionJobsRequeuesDelayedJob(t *testing.T) {
458-
mgr, _ := setupTestManager(t)
471+
t.Parallel()
472+
473+
mgr := newSnapshotCompressionTestManager(t)
459474
now := time.Date(2026, time.April, 6, 12, 0, 0, 0, time.UTC)
460475
mgr.now = func() time.Time { return now }
461476

@@ -519,7 +534,9 @@ func TestRecoverPendingStandbyCompressionJobsRequeuesDelayedJob(t *testing.T) {
519534
}
520535

521536
func TestRecoverPendingStandbyCompressionJobsStartsImmediateCompression(t *testing.T) {
522-
mgr, _ := setupTestManager(t)
537+
t.Parallel()
538+
539+
mgr := newSnapshotCompressionTestManager(t)
523540
now := time.Date(2026, time.April, 6, 12, 5, 0, 0, time.UTC)
524541
mgr.now = func() time.Time { return now }
525542

@@ -565,6 +582,8 @@ func TestRecoverPendingStandbyCompressionJobsStartsImmediateCompression(t *testi
565582
}
566583

567584
func TestRecoverPendingStandbyCompressionJobsClearsStalePlans(t *testing.T) {
585+
t.Parallel()
586+
568587
tests := []struct {
569588
name string
570589
prepare func(t *testing.T, mgr *manager, instanceID string, now time.Time)
@@ -622,7 +641,9 @@ func TestRecoverPendingStandbyCompressionJobsClearsStalePlans(t *testing.T) {
622641

623642
for _, tt := range tests {
624643
t.Run(tt.name, func(t *testing.T) {
625-
mgr, _ := setupTestManager(t)
644+
t.Parallel()
645+
646+
mgr := newSnapshotCompressionTestManager(t)
626647
now := time.Date(2026, time.April, 6, 12, 10, 0, 0, time.UTC)
627648
mgr.now = func() time.Time { return now }
628649
instanceID := "recover-stale-" + tt.name

skills/test-agent/agents/test-agent/NOTES.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,47 @@
218218
- `TestVolumeMultiAttachReadOnly`
219219
- `exec-agent not ready for instance ... within 15s (last state: Initializing)`
220220
- `TestVolumeFromArchive`
221+
222+
## 2026-04-06 - PR #184 standby compression delay branch (`codex/standby-compression-delay`)
223+
224+
### CI red signature
225+
- Linux `test` job on PR [#184](https://github.com/kernel/hypeman/pull/184) failed while the other checks passed.
226+
- Observed failures from the GitHub Actions log:
227+
- `TestQEMUStandbyRestoreCompressionScenarios`
228+
- `TestQEMUStandbyAndRestore`
229+
- `TestBasicEndToEnd`
230+
- `TestForkCloudHypervisorFromRunningNetwork`
231+
- Failure shapes were integration stalls, not deterministic assertion failures:
232+
- `instance ... did not reach Running within 20s (last state: Initializing)`
233+
- `rpc error: code = DeadlineExceeded desc = stream terminated by RST_STREAM with error code: CANCEL`
234+
235+
### Investigation
236+
- Initial stopgap of removing `t.Parallel()` from the new restart-recovery tests was rejected; that was the wrong direction and was not kept.
237+
- Reproduced the branch on `deft-kernel-dev` using the CI-like Linux/root flow with correct prewarm env:
238+
- `go mod download`
239+
- `make oapi-generate`
240+
- `make build`
241+
- `go run ./cmd/test-prewarm`
242+
- `sudo env ... go test -count=1 -tags containers_image_openpgp -timeout=20m ./...`
243+
- Tight loop on the exact CI-failing tests did not reproduce a flake once the command shape matched CI and prewarm settings were correct.
244+
245+
### Root cause and fix
246+
- The new standby compression recovery tests were unit-style tests but used `setupTestManager`, which pulls in much heavier integration-style manager setup than needed.
247+
- That extra setup was unnecessary for these tests and added avoidable load to an already heavy `lib/instances` package.
248+
- Fix:
249+
- Added a lightweight `newSnapshotCompressionTestManager` helper in `lib/instances/snapshot_compression_test.go`
250+
- Moved the new delayed-job and restart-recovery tests to that lightweight fixture
251+
- Restored `t.Parallel()` on the new recovery tests and subtests
252+
- This keeps coverage and parallelism intact while removing needless setup cost.
253+
254+
### Validation
255+
- Targeted stress loop after the fixture change:
256+
- `go test -count=20 -run '^(TestRecoverPendingStandbyCompressionJobs|TestStartCompressionJobDelayedCancellationRecordsSkipped)$' ./lib/instances`
257+
- Result: pass
258+
- Deft full fresh-cache CI-like runs after the fix:
259+
- Run 1: pass (`lib/instances` 193.279s)
260+
- Run 2: pass (`lib/instances` 261.633s)
261+
- Run 3: pass (`lib/instances` 173.573s)
221262
- `exec-agent not ready for instance ... within 15s (last state: Initializing)`
222263

223264
### Additional flakes reproduced during Deft full-suite verification

0 commit comments

Comments
 (0)