Skip to content

chore(deps): truffle v0.58.0, and migrate 21 tests off a fabricated AMI - #722

Merged
scttfrdmn merged 2 commits into
mainfrom
chore/truffle-058-substrate-migration
Oct 7, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
chore/truffle-058-substrate-migration

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Split out from the doctor Nitro work, because it turned out to be a dependency migration rather than a version line. The feature PR follows and depends on this.

What happened

Bumping truffle to v0.58.0 — for the Nitro generation data — also moves the substrate test emulator v0.97.0 → v0.120.0 transitively, and that broke 21 tests across 5 packages in one step.

The cause is neither the AWS SDK nor spawn. v0.120.0 validates AMI ids where v0.97.0 did not, which is correct — real EC2 answers InvalidAMIID.NotFound. But the emulator ships with zero images, so the fabricated ami-12345678 these tests passed to RunInstances had no valid replacement. I checked DescribeImages on a fresh server: zero images. No valid AMI id existed at all.

Fixed by registering a real AMI through RegisterImage, in one shared testutil.RegisterTestAMI rather than copied per package. That's what a caller would do against EC2, so the tests stop depending on how lenient the emulator happens to be — the same reasoning as truffle#177, which decoupled three of its own tests from emulator gaps instead of pinning the emulator back.

Filed upstream as substrate#1432, framed as a note and a suggestion rather than a bug report: the new strictness is an improvement. What would have helped is a changelog line, or an error that hints at the missing RegisterImage.

Two judgement calls

Pure-logic tests keep a literal id. My first pass replaced every occurrence and broke the PlanCapacity tests — which have no substrate server at all, because they never call EC2. A test that doesn't touch AWS shouldn't acquire an emulator dependency, so those keep ami-12345678 as inert data.

One test needed more than a new AMI. TestEC2Provider_LookupAndTagEBSCost_NoVolumesIsNotMeasured asserts that an instance with no discoverable EBS volumes reports an unmeasured fallback (#517 defect 2). Its own comment admitted where the premise came from:

The test instance from newTestEC2Provider has no block device mappings (the substrate emulator's DescribeInstances response doesn't populate them)

v0.120.0 populates them, and attaches a root volume whether or not the AMI declares a RootDeviceName — I tried nil and still got a volume. So that scenario is unreachable through the emulator now.

Rather than contrive it, the test points at a nonexistent instance id and reaches the same documented fallback deterministically. Its own comment already noted the two branches are "the same shape of fallback ... just reached one branch earlier", so the contract under test is unchanged. The part worth not restoring is that it was passing because of something substrate hadn't implemented, not because of anything spawn did.

Also

lambda/ttl-reaper needed its own go mod tidy — nested modules pin their own deps and would otherwise fail CI with updates to go.mod needed.

Verified

  • full short suite: 0 failures (from 21)
  • go vet, gofmt, docs-gen all clean
  • lambda/ttl-reaper builds
  • the AMI-registration path confirmed end to end against the emulator: register, then launch, then assert

The SDK minimums (service/ec2 1.321.1 → 1.335.0, sts 1.45.5 → 1.51.0, plus config/credentials/imds/smithy-go) are required by truffle v0.58.0's own go.mod, not chosen here.

Bumping truffle to v0.58.0 — for the Nitro generation data it now exposes — also
moves the substrate test emulator v0.97.0 -> v0.120.0 transitively, and that broke
21 tests across 5 packages in one step.

Root cause, which is not the AWS SDK and not spawn: v0.120.0 validates AMI ids
where v0.97.0 did not. That is CORRECT — real EC2 answers InvalidAMIID.NotFound —
but the emulator ships with ZERO images, so the fabricated "ami-12345678" these
tests passed to RunInstances had no valid replacement. I checked DescribeImages on
a fresh server: zero. So no valid AMI id existed at all.

Fixed by registering a real AMI via RegisterImage, in one shared
testutil.RegisterTestAMI rather than per package. That is what a caller would do
against EC2, so the tests stop depending on how lenient the emulator happens to
be — the same reasoning as truffle#177, which decoupled three of its own tests
from emulator gaps instead of pinning the emulator back.

Filed upstream as substrate#1432. Deliberately framed as a note and a suggestion
rather than a bug: the new strictness is an improvement, and what would have
helped is a changelog line or an error that hints at the missing RegisterImage.

Two judgement calls worth stating:

PURE-LOGIC TESTS KEEP A LITERAL ID. My first pass replaced every occurrence and
broke the PlanCapacity tests, which have no substrate server at all — they never
call EC2. A test that does not touch AWS should not acquire an emulator
dependency, so those keep "ami-12345678" as inert data.

ONE TEST NEEDED MORE THAN AN AMI. TestEC2Provider_LookupAndTagEBSCost_NoVolumes
IsNotMeasured asserts that an instance with NO discoverable EBS volumes reports an
unmeasured fallback (#517 defect 2). Its own comment admitted the premise came
from "the substrate emulator's DescribeInstances response doesn't populate them".
v0.120.0 populates them, and attaches a root volume whether or not the AMI
declares a RootDeviceName — I tried nil and still got a volume. So that scenario
is unreachable through the emulator now.

Rather than contrive it, the test points at a nonexistent instance id and reaches
the same documented fallback deterministically. Its previous comment already noted
the two branches are "the same shape of fallback ... just reached one branch
earlier", so the contract under test is unchanged. It was passing because of
something substrate had not implemented, not because of anything spawn did, which
is the part worth not restoring.

lambda/ttl-reaper needed its own go mod tidy — nested modules pin their own deps
and would otherwise fail CI with "updates to go.mod needed".

Suite is fully green: 0 failures, vet and gofmt clean, docs-gen current.
@codecov

codecov Bot commented Oct 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/testutil/substrate.go 0.00% 17 Missing ⚠️

📢 Thoughts on this report? Let us know!

All three traced to verification gaps on my side rather than new breakage.

E2E Tier 0: test/e2e/tier0_status_json_test.go passed the same fabricated
ami-12345678. I missed it because that file is behind //go:build e2e_tier0, so
`go test -short ./...` never compiles it — my local green was measuring less than
CI does. Now uses testutil.RegisterTestAMI like the rest; verified with
`go test -tags e2e_tier0`, which is the invocation I should have run before
claiming the suite was clean.

Test job ("Lambda modules") and Go Vulnerability Check ("Scan all modules") were
one cause: I tidied lambda/ttl-reaper and assumed it was the only nested module
affected. It was not — alert-handler, autoscale-orchestrator and sweep-orchestrator
needed it too. Nested modules pin their own deps behind a replace to the root, so a
root bump leaves them stale and BOTH jobs fail with "updates to go.mod needed",
which says nothing about a vulnerability and is easy to misread as one.

Verified by running what CI runs rather than what is convenient:
  - root short suite: 0 failures
  - go test -tags e2e_tier0 ./test/e2e/: ok (125s, full tier 0)
  - all 11 nested modules: build + vet + test ok
  - govulncheck on the root and all 11 nested modules: 0 vulnerabilities
  - gofmt, vet, docs-gen clean
@scttfrdmn
scttfrdmn merged commit e37d0a4 into main Oct 7, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the chore/truffle-058-substrate-migration branch October 7, 2026 22:59
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