Files
floci/tools
Priamo Germosen 7bc09c7925 chore(tools): read the answers AWS already gave out of LocalStack's snapshots (#7494)
Several questions this repository had about AWS behaviour were settled one
at a time by opening LocalStack's AWS-validated snapshots by hand: the two
IAM constraint messages showing that IAM leaves the offending value out,
the enum set UpdateAccessKey names, the STS message for an invalid
parameter. A test LocalStack marks @markers.aws.validated ran against a
real account, so what its snapshot carries is a recording rather than an
emulator's answer, and there are 37 services' worth of them.

This asks the whole set at once. Per recording it prints the service, the
test, its marker, the date LocalStack recorded it, the path inside the
recorded content, and the error code, status and message. --grep adds every
other recorded string carrying a text, for a question that is not about an
error code; --services all reads every service that carries a snapshot, for
a wording Smithy writes rather than a service does; --tsv is one row per
line, for pasting into an issue. A marker other than validated is not
evidence of AWS behaviour, so those tests are left out unless
--all-markers asks for them, and then each line says which marker it
carries.

Three things decide whether what it prints can be trusted.

The markers are read off the parsed test file rather than matched line by
line. A parametrized test stacks @pytest.mark.parametrize between the
marker and the def, over a line per case, and matching lines found 10 of
IAM's 84 AWS-validated tests before this read the decorators instead. A
class's marker carries to the tests inside it, and a test's own wins over
it.

A marker is looked up by the key a snapshot names: Class::name for a test
in a class, the bare name for one at module level, and the bare name as
well for a name the file carries exactly once, since a snapshot key
sometimes names no class for a test that now sits in one. LocalStack
carries 20 names defined in more than one class, so keying those bare would
let one class's validated marker stand for another class's unmarked test,
and an unclassified recording would read as AWS evidence.

An answer is read off the object that holds it rather than by walking the
path string back down, so an error nested in a list keeps its message and
status, and a key with a dot in it is one step rather than two. The path
stays as a label for the reader. A field that would end the row or the
column, a newline or a tab, is escaped: 53 of the messages in these
snapshots carry one.

A snapshot is looked for all the way down a service's directory, since it
sits beside its test: 137 of the files in that tree are a directory or two
below the service's own door and hold 1505 recordings, which a search one
level deep reads none of. The service a recording belongs to is the
directory under tests/aws/services rather than the one the file sits in,
and a recording is reported under its key's own tail,
test_iam.py::TestOne::test_x[case], so two classes carrying one test name
stay two tests in the output and in the count. That tail is cut at the file
rather than at the last slash: 33 keys in that tree carry a slash inside
the parameter, and cutting there leaves name] where a test should be.

LocalStack is not vendored here, so the tool takes a checkout:
make snapshot-mine LOCALSTACK=../localstack. Its own tests cover each of
those readings and run with make snapshot-mine-test. A full run over a
checkout reads 2173 recordings over 1195 tests.
2026-11-04 08:06:03 -06:00
..