Skip to content

Commit 2c963d0

Browse files
authored
Log actual recorded events on panic in match_events! (#4069)
## Motivation and Context We've had flaky tests in our release pipeline. The pain points are that reproducing these failures is difficult and that when a test does fail, `panic` from the `match_events!` macro does not provide visibility into the actual recorded events. This PR does not address the underlying test failures but aims to improve visibility into the actual recorded events when a test fails. This will help us better diagnose and troubleshoot flaky tests. Here is the new diagnostic message looks like (deliberately made a test fail just to show what the message looks like): ``` expected `ev!(connect)` but got Response(HttpResponse { status: 429, body: b"{\"__type\":\"com.amazonaws.dynamodb.v20120810#ThrottlingException\",\n\"message\":\"enhance your calm\"}" }) actual recorded events: [DnsLookup("this-url-is-converted-to-localhost.com"), NewConnection, Response(HttpResponse { status: 429, body: b"{\"__type\":\"com.amazonaws.dynamodb.v20120810#ThrottlingException\",\n\"message\":\"enhance your calm\"}" }), Response(HttpResponse { status: 200, body: b"{\"Count\":0,\"Items\":[],\"ScannedCount\":2}" })] ``` ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
1 parent 7f10206 commit 2c963d0

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

rust-runtime/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust-runtime/aws-smithy-http-client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "aws-smithy-http-client"
33
authors = ["AWS Rust SDK Team <aws-sdk-rust@amazon.com>"]
44
description = "HTTP client abstractions for generated smithy clients"
5-
version = "1.0.0"
5+
version = "1.0.1"
66
license = "Apache-2.0"
77
edition = "2021"
88
repository = "https://github.com/smithy-lang/smithy-rs"

rust-runtime/aws-smithy-http-client/src/test_util/wire.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,12 @@ pub fn check_matches(events: &[RecordedEvent], matchers: &[Matcher]) {
8080
let mut idx = -1;
8181
loop {
8282
idx += 1;
83-
let bail = |err: Box<dyn Error>| panic!("failed on event {}:\n {}", idx, err);
83+
let bail = |err: Box<dyn Error>| {
84+
panic!(
85+
"failed on event {}:\n {}\n actual recorded events: {:?}",
86+
idx, err, events
87+
)
88+
};
8489
match (events_iter.next(), matcher_iter.next()) {
8590
(Some(event), Some((matcher, _msg))) => matcher(event).unwrap_or_else(bail),
8691
(None, None) => return,

0 commit comments

Comments
 (0)