Skip to content

test(#756): pin EC2's networking projections and record them - #1329

Merged
scttfrdmn merged 1 commit into
mainfrom
test/756-ec2-networking-projections
Oct 2, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
test/756-ec2-networking-projections

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

This is the first of three PRs for EC2, the largest block left in #756's AC3. It covers the seven
networking records, 14 of EC2's 30 baseline lines.

EC2 is shaped like Redshift, not CodeDeploy

No production code changes. EC2 was already projected in code; what it lacked was the citation. I
checked this statically before writing any test:

  • emulator/ec2_types.go carries no xml tag, so a record handed to encoding/xml would render
    <AccountID>.
  • Every one of the 88 ec2XMLResponse sites is handed a struct declared for its operation.
  • No XML-tagged field anywhere in emulator/ is typed as an EC2 record, and no record is embedded in
    a response or sits behind an interface{} field.

What the new test asserts

emulator/ec2_wire_test.go follows redshift_wire_test.go's shape. It has one t.Parallel() test
per record, and together they drive 37 routed operations:

Record Operations
EC2VPC CreateVpc, DescribeVpcs, ModifyVpcAttribute, DeleteVpc
EC2Subnet CreateSubnet, DescribeSubnets, ModifySubnetAttribute, DeleteSubnet
EC2SecurityGroup Create, Authorize Ingress/Egress, Describe, Revoke Ingress/Egress, Delete
EC2InternetGateway Create, Attach, Describe (while attached), Detach, Delete
EC2RouteTable Create, Associate, ReplaceRouteTableAssociation, CreateRoute, ReplaceRoute, Describe, DeleteRoute, Disassociate, Delete
EC2NATGateway Create, Describe, Delete
EC2ElasticIP Allocate, Associate, Describe (while associated), Disassociate, Release

Each test walks the raw XML token stream and fails on an element named for a bookkeeping member at
any depth, reporting the /a/b/c path.

Each describe is placed where its record is richest: after the authorizes, while the gateway is
attached, after the route exists, while the address is associated. That way the walk reaches the
nested elements rather than an empty resource.

Each case asserts a published element is present before the walk. The stored record is also read
back as raw JSON to prove it held both members. Neither member carries ,omitempty on these seven,
so neither can be absent for free.

The member list is longer than any other service's, and a control shows why

EC2 spells the account three ways: account_id on most records, accountId on EC2KeyPair and
accountID on EC2LaunchTemplate. A case fold reconciles the last two with AccountID, but not the
snake_case form, so the list is
{"AccountID", "account_id", "Region", "EverTagged", "ever_tagged", "CreatedAt"}. It is written now
so PRs 2 and 3 extend the file rather than the list.

Negative controls (each run, then restored; ec2_plugin.go verified diff-free afterwards)

  1. Per-record isolation, every spelling. I patched ec2XMLResponse to inject a leaked member
    into each record's describe set, using a different spelling each time: AccountID into vpcSet,
    account_id into subnetSet, Region into securityGroupInfo, ever_tagged into
    internetGatewaySet, CreatedAt into routeTableSet, accountId into natGatewaySet and
    EverTagged into addressesSet. Exactly seven failures, one per test, each on that record's
    Describe subtest
    , and each named the path, e.g.
    DescribeSubnets answered DescribeSubnetsResponse/subnetSet/account_id.
  2. The snake_case entry is required. With account_id dropped from the list, the subnet test
    passed on a body carrying <account_id>.
  3. A misspelled citation is refused. check-wire-bookkeeping reports "emulator/ defines no such
    test".

The ratchet

before: 319 declared, 171 projected across 68 records, 148 still reachable
after:  319 declared, 185 projected across 75 records, 134 still reachable

Also in this PR

Verification

All of these pass:

  • make lint: 0 issues.
  • make test: race, -count=1.
  • docs-reference-check docs-versions version-check discarded-unmarshal-check wire-bookkeeping-check operation-catalog-check operation-docs-check.

Not in scope

#756 stays open.

EC2VPC, EC2Subnet, EC2SecurityGroup, EC2InternetGateway, EC2RouteTable,
EC2NATGateway and EC2ElasticIP each declare AccountID and Region under
wire-visible json tags, fourteen of the inventory's lines. None reaches a
response: emulator/ec2_types.go carries no xml tag, every ec2XMLResponse site is
handed a struct declared for its operation, and no XML-tagged field anywhere is
typed as a record. So EC2 was already projected in code, as Redshift was, and
what it lacked was the citation.

emulator/ec2_wire_test.go holds one test per record, together driving
thirty-seven routed operations and walking the raw XML for an element named for
a bookkeeping member at any depth. The member list names the snake_case
account_id in its own right, because EC2 spells the account three ways and a
fold reaches only accountId and accountID; a control run without that entry
lets a leaked <account_id> pass.

check-wire-bookkeeping goes from 171 projected across 68 records to 185 across
75, and from 148 still reachable to 134, of the same 319 declared.

Also sorts scripts/wire-bookkeeping-projected.txt into byte order: #1328 had put
CodeDeploy's lines after Cognito's.

#756 stays open: EC2's storage, image and compute records follow.
@codecov

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 82b564b into main Oct 2, 2026
18 checks passed
@scttfrdmn
scttfrdmn deleted the test/756-ec2-networking-projections branch October 2, 2026 04:10
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