Repository navigation
test(cloudwatch): a botocore-driven check for the JSON path (#757) - #792
Merged
Merged
Conversation
aws-sdk-go-v2 resolves CloudWatch to Smithy RPC v2 CBOR, so every Go test — unit, httptest and the test/e2e journey alike — exercises CBOR and none exercises awsJson1_0. That is the gap that let substrate ship a CloudWatch answering XML to the AWS CLI while its own suite stayed green, and the failure mode was silence: HTTP 200, no members found by botocore's JSON parser, and `aws cloudwatch list-metrics` printing nothing at all. python/tests/test_cloudwatch_botocore.py drives boto3 against a real substrate process over five behaviours: a JSON MetricData array reaching state, the MetricName filter, an alarm keeping its modeled types (Threshold reads back 80.5, not 80), GetMetricData's two present-and-empty lists, and a refusal arriving as a ClientError whose Code is ResourceNotFoundException at HTTP 404. All five fail against ae8d706 and pass on 0c3e7d9. They live in the Python suite because that is where a non-Go client already runs: the CI job builds the binary and exports SUBSTRATE_BINARY today. boto3 becomes a `test` extra rather than a dependency, since the plugin itself does not need it, and the CI install becomes `pip install -e './python[test]'` — without it the tests importorskip and the gap reopens silently. This is the first Python test that launches a substrate process rather than a mock.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Sep 11, 2026
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.
#757's last acceptance criterion had two halves:
PR #791 shipped the journey. This is the other half, and without it the issue cannot close.
Closes #757.
Why a Go test cannot cover this
aws-sdk-go-v2resolves CloudWatch to Smithy RPC v2 CBOR. So do all of substrate's Go teststhat speak a real protocol — the unit tests, the
httptesttiers, and the newtest/e2ejourney. Every one of them exercises CBOR and none exercises
awsJson1_0, which is theprotocol botocore picks. That is not a thin gap; it is exactly how substrate shipped a
CloudWatch that answered XML to the AWS CLI while its own suite was green, and the failure mode
was silence: the call returned HTTP 200, botocore's JSON parser found no members, and
aws cloudwatch list-metricsprinted nothing at all rather than failing.A manual
awsinvocation proved the fix in PR #791; nothing automated guards it.Fail-before, pass-after
Same test file, two binaries,
substrate_isolatedstarting a real process per test:At
ae8d706the JSON request body was never parsed, soset_alarm_stateon anever-created alarm reported
InvalidParameterValue(AlarmName missing) rather than theResourceNotFoundExceptionthe test asserts — a good illustration of the class of bug thistier catches and the CBOR tier cannot.
The pre-fix binary was built from a detached worktree at
ae8d706, not from a mutated tree.What the five tests assert
test_put_metric_data_body_is_parsed— a JSONMetricDataarray reaches state, soListMetricsreports both points. This is the input half: the handler readsMetricData.member.1.MetricName, botocore sends an array.test_list_metrics_honours_the_metric_name_filter— the filter is applied, not ignored.test_alarm_round_trip_keeps_modeled_types—Thresholdreads back80.5, not80; arenderer writing every number as an integer would pass a round-trip test against itself.
Also
EvaluationPeriods == 2,Period == 300,ActionsEnabled is True,StateReasonData(stored but never returned before CloudWatch emulation doesn't speak rpc-v2-cbor — current aws-sdk-go-v2 clients fail to deserialize responses #785),
"OKActions" not in alarm(absent, not empty),"NextToken" not in for_metric, disable/enable, and delete leavingMetricAlarms == [].test_get_metric_data_reports_no_results_rather_than_nothing— both lists present andempty, which is the distinction a bare 200 with an unparseable body destroyed.
test_a_refusal_reports_its_code_and_message—ClientErrorwithCode == "ResourceNotFoundException", the alarm name in the message, HTTP 404. Shaped asREST/JSON the code went into a header botocore's JSON parser never reads, so a refusal
surfaced as
An error occurred (404)and a consumer'sexceptbranch keyed on the code wasunreachable.
The dependency, deliberately an extra
boto3 is a
testextra, not a dependency — the plugin does not need it, and a consumerinstalling
pytest-substrateshould not inherit an AWS SDK to use a server fixture. The wheelmetadata confirms the split:
The CI install therefore becomes
pip install -e './python[test]'. Without that change thetests would
importorskipand pass vacuously, which is a worse outcome than not writing them:the gap would look closed. The guard is
pytest.importorskiprather than a bare import so acontributor without boto3 gets a skip instead of a collection error.
This is the first Python test that launches a substrate process rather than exercising a
mock; all 459 previous lines were mocks. Verified it starts and tears down cleanly, including
under repeated runs, before pushing.
Verification
No Go files change in this PR.