Repository navigation
test(#756): pin the Step Functions projections and record them - #1322
Conversation
`StateMachineState`, `ExecutionState` and `ActivityState` declare `AccountID` and `Region` under wire-visible `json` tags, and the two taggable ones also declare `EverTagged` as `ever_tagged` — eight of the wire-bookkeeping inventory's lines. None of the eight can reach a body. All eighteen routed operations answer through `statesJSONResponse` with a hand-built map, one of the two named projections `smToMap` and `execToMap`, or a list entry struct declared inside its own handler; `listTagsForResource` decodes the stored record into a one-member struct and answers only its tags; and every `json.Marshal` of a record in the plugin is in a `save*` helper writing to state. So the projection already existed in code and what was missing was the citation the projected inventory requires. `emulator/stepfunctions_wire_test.go` holds one test per record, each driving every operation that answers it and walking the decoded document for a member named for any of the three at any depth. The comparison is case-insensitive: the records spell their tags with the Go identifier while every published member of every shape here is lowerCamelCase, so nothing in a correct body folds to any of them. It is on the member *name* because the account and the Region appear legitimately in every body as segments of a `states` ARN. `ever_tagged` is the part that needed care. It carries `,omitempty` and is set by `TagResource` alone — never by create-with-tags (#938) — so the state-machine and activity tests tag the resource and require the flag on the stored record before requiring its absence from a response. Without that step the absence would hold of a record that never carried the member, which is the vacuous form #1304 shipped on EFS. A control confirms it: removing the stamp fails both tests at the record anchor rather than at an assertion on a body. Deliberately not the stronger form `emulator/rds_wire_test.go` uses, which requires a record's members to be exactly the published ones. `smToMap` answers seven of `DescribeStateMachine`'s fourteen published members and `describeActivity` three of five; an expectation keyed on that would have to be rewritten by the PR that closes the gap, and the absence walk is indifferent to it. That is also the form Config, Glue, EFS and Redshift already use. Six of the eighteen carry nothing a projection could leak — `UpdateStateMachine` answers only `updateDate`, `StopExecution` only `stopDate`, and the two deletes and the two tag writes an empty object — and are driven anyway, so the set reads as complete rather than as a sample. A control injecting a leak at each of the twenty-one assertion sites confirms every subtest fails at its own site and at no other, so none of them is decoration. `make wire-bookkeeping-check` moves to 159 projected across 62 records, 160 still reachable of the same 319 declared.
API_DescribeActivity publishes activityArn, creationDate, encryptionConfiguration and name — four members, not the five the first reading recorded. The claim is load-bearing twice over: it is the stated reason this file asserts absence rather than exact membership, and it is the count the follow-up issue on the member gap will cite.
|
The two findings this block turned up are filed rather than fixed here, following #1319 → #1320:
Neither needs a change to the test this PR adds — it asserts member names, which is why the |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
What
Discharges the Step Functions block of #756's AC3:
StateMachineState,ExecutionStateandActivityStateare recorded inscripts/wire-bookkeeping-projected.txt, citing one test each.make wire-bookkeeping-checkmoves to 159 projected across 62 records, 160 still reachable ofthe same 319 declared (from 151/59/168).
Why these eight lines are discharged by a citation rather than by a fix
All eighteen routed operations answer through
statesJSONResponsewith a hand-builtmap[string]interface{}, one of the two named projectionssmToMap/execToMap, or a list entrystruct declared inside its own handler;
listTagsForResourcedecodes the stored record into aone-member struct and answers only its tags. Every
json.Marshalof a record in the plugin is in asave*helper writing tostate.Put. The projection already existed in code — what was missing wasthe citation the projected inventory requires before it will accept a record.
Deletion is not available: all three records are keyed by account and Region, and
json:"-"orretyping in place changes the format of every recorded run, because
MemoryStateManagersnapshotsthose bytes and a replay reads them back (
emulator/ecr_wire.gois the worked statement).ever_tagged— the part that needed careEverTaggedcarries,omitemptyand is set byTagResourcealone, never by create-with-tags(#938). An absence assertion against a never-tagged record would pass on a response that could not
have carried the member — the vacuous form #1304 shipped on EFS. So the state-machine and activity
tests tag the resource and require the flag on the stored record before requiring its absence from
a response.
Why absence rather than exact membership
emulator/rds_wire_test.go's form — require a record's members to be exactly the published ones —is not taken here.
smToMapanswers 7 ofDescribeStateMachine's 14 published members anddescribeActivity3 of 5; an expectation keyed on that would have to be rewritten by the PR thatcloses the gap. The absence walk is indifferent to it, and is the form Config, Glue, EFS and
Redshift already use.
Six of the eighteen carry nothing a projection could leak —
UpdateStateMachineanswers onlyupdateDate,StopExecutiononlystopDate, and the two deletes and the two tag writes an emptyobject. They are driven anyway, so the set reads as complete rather than as a sample.
Verification
make test(race,-count=1) andmake lintclean; 21 subtests across the three tests.make docs-reference-check docs-versions version-check discarded-unmarshal-check wire-bookkeeping-check operation-catalog-check operation-docs-check— only the ratchet line moved.smToMap,execToMap, both create arms of each taggable record, the three list entry structs,StartSyncExecution's own map,GetExecutionHistory,UpdateStateMachine,StopExecution, bothdeletes, both tag writes and
ListTagsForResource— fails exactly the subtest that drives thatsite, naming the
$.a.b[0].cpath, and no other. RemovingtaggingStampRecordEverTaggedfailsboth taggable tests at the record anchor.
only thing holding the projection", so the third column is load-bearing.
Scope
#756 stays open — AC3 continues with
ec2_types.go's 30 lines,codedeploy_types.goandbackup_types.goat 6 each, and the long tail below. Two findings read out of this plugin are filedseparately rather than folded in:
HistoryEvent.timestamprenders RFC3339 where the JSON protocolpublishes epoch seconds while every other date in the plugin goes through
sfnEpoch, andDescribeStateMachine/DescribeActivityship a fraction of their published members.Refs #756