Skip to content

test(sweep): add the detached-sweep hardware test, and list the Lambda as hardware-sensitive - #750

Merged
scttfrdmn merged 2 commits into
mainfrom
test/749-detached-sweep-hardware
Oct 8, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
test/749-detached-sweep-hardware

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Written to verify #725's tags on hardware. It found #749 instead — a detached
parameter sweep launches zero instances and reports success. This PR is the
test and the manifest entry; the fix is #749.

What the test does

Launches a two-row detached sweep (the default path), polls for the rows, then
asserts each carries spawn:managed=true and spawn:ttl-deadline, and that the
reaper's ec2:TerminateInstances is actually permitted against the tag — a tag
is only worth having if it unlocks the terminate.

It currently fails, correctly, at the polling step. #725's tag assertions are
written and waiting behind #749, because the default path creates nothing to tag.

Two traps recorded in the script, both of which I hit writing it

1. Rows must be found by spawn:sweep-id, never by Name. The orchestrator
names rows <SweepName>-<index> from a derived SweepName, not the name passed
to spawn launch. My first version filtered on Name=<cli-arg>-* and matched
nothing — and because the cleanup used the same filter, it would have missed
any row that did launch. I caught it from the launch output before anything
could leak.

The hardware smoke's sweep leg already documents this lesson about --tag:

the first version of this leg filtered on a tag the rows never received and
reported "found 0" while two rows were running — the leg's own discovery key was
a flag it was testing for absence

Same trap, one layer along. That is an argument for discovering sweep rows by
sweep-id everywhere, not just here.

2. The orchestrator's log group is in the infra account, while the rows land
in the target account. Tailing it with the launch profile returns
ResourceNotFoundException, which is how the first run reported "0 rows" with no
reason attached — I had to re-fetch the log separately with the infra profile to
find the MissingParameter at all. The script now uses the right profile for
that one call and says why.

A correction to my own earlier diagnosis

The polling loop is retained, but it is explicitly not why an earlier run of
this check saw zero rows. I had attributed the smoke's
expected 2 running rows, found 0 to checking before the Lambda had launched
anything. That was wrong: it was #749, a real total failure. "Found 0" was a true
positive I explained away as a timing artifact, and then built polling to fix.
The comment in the script says so, because the next person reading a zero-row
result deserves to not be sent down the same path.

The manifest entry is the durable half

lambda/sweep-orchestrator/ was not in scripts/hardware-sensitive.txt, and
that is why #749 shipped. It composes RunInstances from param keys, with no
compile-time link to the CLI that writes them — so no unit test on either side
can see a key-set disagreement across that seam. Added, with the reason, in the
format the file asks for ("the reason is recorded so the list can be argued with
rather than inherited").

Cost safety

Smallest ARM type, 20-minute TTL, explicit terminate, and a leak-check that
re-queries rather than trusting the terminate call. The real run created no
instances and left none behind — verified twice, once by the script and once by an
independent describe-instances across the whole target account.

bash -n on the script, go build ./..., go test -short ./...,
make check-docs, changelog gate, semgrep scan --config=auto --error
(0 findings).

…a as hardware-sensitive

Written to verify #725's tags on real hardware; it found #749 instead —
a detached parameter sweep launches ZERO instances. The CLI never seeds
`ami` into the params the orchestrator reads, so every RunInstances is
rejected with MissingParameter: ImageId, the Lambda logs "All instances
launched and completed", and the CLI prints "Parameter sweep queued
successfully" and exits 0.

So this test currently FAILS, correctly. #725's tag assertions are
written and waiting behind #749, since the default path creates nothing
to tag.

Two traps are recorded in the script because I hit both writing it:

1. Rows must be discovered by spawn:sweep-id, NEVER by Name. The
   orchestrator names rows "<SweepName>-<index>" from a derived
   SweepName, not the name passed to `spawn launch` — so a Name filter
   built from the CLI argument matches nothing. My first version did
   that, which would have made the script's own CLEANUP miss any row
   that did launch. The hardware smoke's sweep leg documents the same
   lesson about --tag; this is it one layer along.

2. The orchestrator's log group is in the INFRA account while the rows
   land in the target account. Tailing it with the launch profile
   returns ResourceNotFoundException and loses the one diagnostic that
   explains the failure — which is how the first run reported "0 rows"
   with no reason attached.

The polling loop is retained but is explicitly NOT why an earlier check
saw zero rows: that was #749, a real total failure, which the absence of
polling had merely made easy to misread. I had attributed it to timing.

Also adds lambda/sweep-orchestrator/ to scripts/hardware-sensitive.txt.
It composes RunInstances from param keys with no compile-time link to
the CLI that writes them, so no unit test on either side can see a
key-set disagreement across that seam. Its absence from the manifest is
why #749 shipped.

Cost safety: smallest ARM type, 20-minute TTL, explicit terminate, and a
leak-check that re-queries rather than trusting the terminate call. The
real run created no instances and left none behind, verified twice.
@codecov

codecov Bot commented Oct 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Two corrections to the leak-check, both found by running it:

1. shutting-down was excluded from the post-terminate state list. It is
   excluded from EC2's own default filter too — the blind spot behind
   #736 — so the check would report "nothing left behind" for an
   instance merely mid-termination, and identically for one whose
   terminate FAILED and left it stuck.

2. An ad-hoc cross-check I ran alongside this used
   `length(Reservations[].Instances[?State.Name!=`terminated`])`, which
   counts RESERVATIONS, not instances: the filter yields one list per
   reservation, so two reservations holding ZERO live instances answers
   "2". It raised a false leak alarm on a run where the script was
   correct. The script already used the sound form (server-side filter +
   grep -c on instance IDs); the reasoning is now written down next to
   it so nobody reaches for length() again.

Also waits for the instances to leave the live states instead of
sleeping a fixed 15s, so "still shutting down" and "stuck" are
distinguishable.
@scttfrdmn
scttfrdmn merged commit 7a896dc into main Oct 8, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the test/749-detached-sweep-hardware branch October 8, 2026 04:46
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