You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compare query strings based on set of components in ec2 integration tests (#3859)
## Motivation and Context
Avoids comparing raw strings in ec2 integration tests
## Description
With a updated service model for ec2, we have run into the following
test failures in its integration tests,
```
----- paginators_handle_unset_tokens stdout ----
body did not match. left=expected, right=actual
Diff < left / right > :
<Action=DescribeSpotPriceHistory&Version=2016-11-15&·[1;48;5;52;31mAvailabilityZone=eu-north-1a&InstanceType.1=g5.48xlarge&ProductDescription.1=Linux%2FUNIX
>Action=DescribeSpotPriceHistory&Version=2016-11-15&InstanceType.1=g5.48xlarge&ProductDescription.1=Linux%2FUNIX·[1;48;5;22;32m&AvailabilityZone=eu-north-1a
thread 'paginators_handle_unset_tokens' panicked at sdk/aws-smithy-runtime/src/client/http/test_util/replay.rs:98:43:
---- paginators_handle_empty_tokens stdout ----
body did not match. left=expected, right=actual
Diff < left / right > :
<Action=DescribeSpotPriceHistory&Version=2016-11-15&·[1;48;5;52;31mAvailabilityZone=eu-north-1a&InstanceType.1=g5.48xlarge&ProductDescription.1=Linux%2FUNIX
>Action=DescribeSpotPriceHistory&Version=2016-11-15&InstanceType.1=g5.48xlarge&ProductDescription.1=Linux%2FUNIX·[1;48;5;22;32m&AvailabilityZone=eu-north-1a
thread 'paginators_handle_empty_tokens' panicked at sdk/aws-smithy-runtime/src/client/http/test_util/replay.rs:98:43:
```
We don't know exactly how a generated ec2 SDK built up query strings in
a different order from what it is today, but whatever the root cause is,
the ultimate fix remains the same. Comparing raw query strings can be
unreliable, so this PR will fix that by comparing sets of strings
derived from query strings.
## Testing
Ran the edited tests against the generated ec2 SDK in question and it
passed (without this PR, it did fail).
----
_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
let expected = expected.split('&').collect::<HashSet<&str>>();
23
+
let actual = actual.split('&').collect::<HashSet<&str>>();
24
+
assert_eq!(expected, actual);
25
+
assert_eq!(expected.len(), actual.len());
26
+
}
27
+
22
28
/// See https://github.com/awslabs/aws-sdk-rust/issues/391
23
29
///
24
30
/// EC2 replies with `<nextToken></nextToken>` which our XML parser parses as empty string and not "none"
25
31
#[tokio::test]
26
32
asyncfnpaginators_handle_empty_tokens(){
27
-
let request= "Action=DescribeSpotPriceHistory&Version=2016-11-15&AvailabilityZone=eu-north-1a&InstanceType.1=g5.48xlarge&ProductDescription.1=Linux%2FUNIX";
28
33
let response = r#"<?xml version="1.0" encoding="UTF-8"?>
let first_item = paginator.try_next().await.expect("success");
55
55
assert_eq!(first_item,None);
56
-
http_client.assert_requests_match(&[]);
56
+
let req = captured_request.expect_request();
57
+
let actual_body = std::str::from_utf8(req.body().bytes().unwrap()).unwrap();
58
+
let expected_body = "Action=DescribeSpotPriceHistory&Version=2016-11-15&AvailabilityZone=eu-north-1a&InstanceType.1=g5.48xlarge&ProductDescription.1=Linux%2FUNIX";
/// See https://github.com/awslabs/aws-sdk-rust/issues/405
60
63
///
61
64
/// EC2 can also reply with the token truly unset which will be interpreted as `None`
62
65
#[tokio::test]
63
66
asyncfnpaginators_handle_unset_tokens(){
64
-
let request= "Action=DescribeSpotPriceHistory&Version=2016-11-15&AvailabilityZone=eu-north-1a&InstanceType.1=g5.48xlarge&ProductDescription.1=Linux%2FUNIX";
65
67
let response = r#"<?xml version="1.0" encoding="UTF-8"?>
let first_item = paginator.try_next().await.expect("success");
91
88
assert_eq!(first_item,None);
92
-
http_client.assert_requests_match(&[]);
89
+
let req = captured_request.expect_request();
90
+
let actual_body = std::str::from_utf8(req.body().bytes().unwrap()).unwrap();
91
+
let expected_body = "Action=DescribeSpotPriceHistory&Version=2016-11-15&AvailabilityZone=eu-north-1a&InstanceType.1=g5.48xlarge&ProductDescription.1=Linux%2FUNIX";
0 commit comments