Repository navigation
test(#756): pin EC2's networking projections and record them - #1329
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.gocarries noxmltag, so a record handed toencoding/xmlwould render<AccountID>.ec2XMLResponsesites is handed a struct declared for its operation.emulator/is typed as an EC2 record, and no record is embedded ina response or sits behind an
interface{}field.What the new test asserts
emulator/ec2_wire_test.gofollowsredshift_wire_test.go's shape. It has onet.Parallel()testper record, and together they drive 37 routed operations:
EC2VPCEC2SubnetEC2SecurityGroupEC2InternetGatewayEC2RouteTableEC2NATGatewayEC2ElasticIPEach test walks the raw XML token stream and fails on an element named for a bookkeeping member at
any depth, reporting the
/a/b/cpath.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
,omitemptyon 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_idon most records,accountIdonEC2KeyPairandaccountIDonEC2LaunchTemplate. A case fold reconciles the last two withAccountID, but not thesnake_case form, so the list is
{"AccountID", "account_id", "Region", "EverTagged", "ever_tagged", "CreatedAt"}. It is written nowso PRs 2 and 3 extend the file rather than the list.
Negative controls (each run, then restored;
ec2_plugin.goverified diff-free afterwards)ec2XMLResponseto inject a leaked memberinto each record's describe set, using a different spelling each time:
AccountIDintovpcSet,account_idintosubnetSet,RegionintosecurityGroupInfo,ever_taggedintointernetGatewaySet,CreatedAtintorouteTableSet,accountIdintonatGatewaySetandEverTaggedintoaddressesSet. Exactly seven failures, one per test, each on that record'sDescribe subtest, and each named the path, e.g.
DescribeSubnets answered DescribeSubnetsResponse/subnetSet/account_id.account_iddropped from the list, the subnet testpassed on a body carrying
<account_id>.check-wire-bookkeepingreports "emulator/ defines no suchtest".
The ratchet
Also in this PR
Cognito's, but
codedeploy_sorts beforecognito_. The check does not enforce order, so nothingcaught it. This moves them back. No line changed.
ModifyVpcAttribute/ModifySubnetAttributeare sent the published parameter names(
EnableDnsHostnames.Value,MapPublicIpOnLaunch.Value). The handlers readEnableDNSHostnames.Value/MapPublicIPOnLaunch.Valueand discard the published names. That isModifySubnetAttribute and ModifyVpcAttribute read parameter names AWS does not publish, so every modify is silently discarded #1151, already filed. Only the response is asserted here, and it is the same either way; a
comment at each case points to ModifySubnetAttribute and ModifyVpcAttribute read parameter names AWS does not publish, so every modify is silently discarded #1151.
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.
EC2Volume,EC2Snapshot,EC2Image).EC2Instancewith itsEverTaggedvacuity trap,EC2KeyPairwithCreatedAt,EC2LaunchTemplate,EC2PlacementGroup).Puterrors in the security-group rule handler are Forty-nine write sites discard the error from state.Put, so a failed store answers 200 #1192's.