Repository navigation
fix(#1123): a deployed resource that failed is not a deployed resource - #1257
Merged
Merged
Conversation
StackDeployer.Deploy reports a refusal on the resource's own DeployedResource.Error and returns no Go error, so `require.NoError` plus `result != nil` passes for a template in which nothing was created. TestCFN_AppSyncFullStack was that: `Ref` on a GraphQLApi is the API's ARN, so all three children addressed /v1/apis/arn:aws:appsync:.../datasources and were refused. Both AppSync CFN tests now name the API by Fn::GetAtt ApiId, the form the page documents, and assert each resource's error, physical ID and ARN. A sweep ran the 305 Deploy-calling tests individually against an instrumented failed-resource path — individually because 1464 t.Parallel() calls make whole-suite attribution wrong — and found 34 deploying a failing resource, five of them asserting something unobservable: - TestCFN_ChangeSet_CreateDescribeExecute added an SNS topic its deployer has no plugin for, ending in UPDATE_ROLLBACK_FAILED; it adds a queue now. - TestCFN_MultiKeyMapIsNotAnIntrinsic reused one bucket name across 20 iterations, so 19 rolled back and an empty Outputs satisfied both NotEquals. - The three AppSync refusal tests asserted only `result != nil`. requireDeployedCleanly sits beside newTestDeployer so a new test gets the per-resource assertion by default. TestCFN_Route53RecordSetGroup fails for a production reason, filed as #1256; its refusal is pinned so fixing #1256 turns the test red rather than leaving it green either way. No production behaviour changes. Closes #1123
6 tasks
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.
StackDeployer.Deployreports a resource it could not create on that resource's ownDeployedResource.Errorand returns no Go error. So the pair of assertions a CloudFormation testreaches for by default —
require.NoError(t, err)andresult != nil— is satisfied by a template inwhich every resource was refused.
TestCFN_AppSyncFullStackwas exactly that. It named its API by{"Ref": "MyAPI"}, which resolves tothe API's ARN — what
AWS::AppSync::GraphQLApi's Return values section publishes, and what #837made substrate answer — so all three child resources addressed
/v1/apis/arn:aws:appsync:us-east-1:123456789012:apis/<id>/datasourcesand were refusedUnknownOperationException. The stack reachedROLLBACK_COMPLETE. The test was green.What changed
Both AppSync CloudFormation tests now name the API by
{"Fn::GetAtt": ["MyAPI", "ApiId"]}, the formAWS's own page documents, and assert each deployed resource's error, physical ID and ARN rather than
only that the result is non-nil.
requireDeployedCleanly(t, result, wantResources)sits besidenewTestDeployer, so a newCloudFormation test gets the per-resource assertion by default. It checks the stack's status as well,
because a failed resource and the rollback it triggers are two observations of one event and a caller
may reach either first.
The sweep
All 305 tests that call
Deploywere run individually against an instrumented failed-resourcepath. Individually because the package has 1464
t.Parallel()calls, which make stderr attributionfrom one whole-suite run wrong — that variant mis-attributed 91 lines across 64 names against a true
34.
34 deploy a failing resource. Most are deliberate: a test whose subject is a refusal. Five were
asserting something they could not observe:
TestCFN_AppSyncFullStackRefinstead ofFn::GetAtt ApiIdTestCFN_ChangeSet_CreateDescribeExecuteAWS::SNS::Topicits deployer registers no plugin forTestCFN_MultiKeyMapIsNotAnIntrinsicTestCFN_AppSync{DataSourceMissingApiId,ResolverMissingFields,FunctionMissingApiId}result != nilTestCFN_ChangeSet_CreateDescribeExecute: executing the change set refused the topic withServiceNotAvailable, rolled the update back by re-deploying the first template, and refused the IAMrole with
EntityAlreadyExistson the way — ending inUPDATE_ROLLBACK_FAILEDwithassert.NotNil(t, result)holding throughout. It now adds anAWS::SQS::Queue, the same shape ofchange against a service the deployer can reach, and asserts the update clean.
TestCFN_MultiKeyMapIsNotAnIntrinsicis the sharpest of them. 19 of its 20 iterations were refusedBucketAlreadyExistsand rolled back, and a rolled-back stack has no outputs — soresult.Outputs["Both"]was"", which satisfies bothassert.NotEqualcalls. The repetition thatexists to catch a map-iteration race asserted nothing from the second iteration on. The bucket name
now carries the iteration, and the output is asserted exactly (
{"Fn::Sub":"also-${P}","Ref":"P"})rather than only as "neither intrinsic" —
encoding/jsonorders a map's keys, so byte-for-byteequality across 20 runs is the determinism claim the test is actually about.
The three AppSync refusal tests now assert the refusal they are named for, including that a resource
that was never created carries no ARN.
Route 53, and why it is not fixed here
TestCFN_Route53RecordSetGroupfails for a production reason:Refon a hosted zone answers the/hostedzone/Z…path formCreateHostedZonereturns, where the CloudFormation page publishes thebare ID, so a record set naming its zone the way AWS's examples do builds
POST /2013-04-01/hostedzone//hostedzone/Z…/rrsetand is refusedInvalidAction. Separately,deployRoute53RecordSetGroupkeeps only the Go error from each child, and a refusal is not one, sothe group reports a clean resource while every record set under it was refused.
That is filed as #1256, because this issue's last acceptance criterion predicted no production
change. The test is given the per-resource assertion it was missing, pinning today's refusal with a
TODO(#1256), so fixing #1256 turns this test red rather than leaving it silently green in eitherstate.
Verification
Non-vacuity was checked by keeping the new assertions and reverting only the template fixes:
Fn::GetAtt→Ref:Should be empty, but was UnknownOperationException: … /datasources is not recognized, three times, plus"ROLLBACK_COMPLETE" should not contain "ROLLBACK".Should be empty, but was EntityAlreadyExists: Role with name cs-test-role already exists.and"UPDATE_ROLLBACK_FAILED" should not contain "FAILED".Should be empty, but was BucketAlreadyExistsandmap[string]string{} does not contain "Both"— the vacuity, stated by the test runner.make lint0 issues;make testgreen with the race detector;docs-reference-check,docs-versions,version-check,discarded-unmarshal-checkandwire-bookkeeping-checkall pass.Compatibility
No production code changes.
docs/services.md's AppSync CloudFormation section is updated — thesentence recording that substrate's own tests used the
Refform is now the statement that they useFn::GetAttand assert every resource.Closes #1123