instancectl: the start-in-flight size test checks every start's answer, with a new invocation per start
Review fix round 3 (Task 5, Minor): the test's fake now makes a new invocation when the held start is released, and each case asserts the start's status (200, or 502 when the start fails).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+17
−2
internal/instancectl/size_test.go+17 −2
diff --git a/internal/instancectl/size_test.go b/internal/instancectl/size_test.go| index 78654b7a5..2f3a6b760 100644 |
| --- a/internal/instancectl/size_test.go |
| +++ b/internal/instancectl/size_test.go |
| @@ -490,7 +490,16 @@ func TestSizeTreatsAStartInFlightAsPopulated(t *testing.T) { |
| ctl.answers["show -p MemoryMax --value "+SliceName(genHost)] = "536870912\n" |
| ctl.answers["show -p MemoryMax -p CPUQuotaPerSecUSec"] = "MemoryMax=536870912\n" |
| entered, release := make(chan struct{}), make(chan struct{}) |
| - ctl.before = map[string]func(){"start": func() { close(entered); <-release }} |
| + // The start is held, then makes a new invocation as systemd |
| + // would, so every path can tell its start went through |
| + // (genCtl alone always answers the same one). |
| + ctl.before = map[string]func(){"start": func() { |
| + close(entered) |
| + <-release |
| + ctl.mu.Lock() |
| + ctl.answers["show -p InvocationID --value"] = "inv-after-start\n" |
| + ctl.mu.Unlock() |
| + }} |
| if fail { |
| ctl.fail = map[string]error{tc.start: errSizeWrite} |
| } |
| @@ -529,7 +538,13 @@ func TestSizeTreatsAStartInFlightAsPopulated(t *testing.T) { |
| t.Errorf("a growth during the start answered %d %s, want 200", status, body) |
| } |
| close(release) |
| - <-started |
| + want := http.StatusOK |
| + if fail { |
| + want = http.StatusBadGateway |
| + } |
| + if got := <-started; got != want { |
| + t.Errorf("the start answered %d, want %d", got, want) |
| + } |
| m := s.sliceMem(genHost) |
| m.mu.Lock() |
| n := len(m.starting) |