1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
use ;
use AwsUserAgent;
use BeforeSerializationInterceptorContextMut;
use FinalizerInterceptorContextRef;
use RetryConfig;
use TimeoutConfig;
use ;
use ;
use Client;
use InstantSleep;
use ManualTimeSource;
use SharedTimeSource;
use ReplayingClient;
use capture_test_logs;
use BoxError;
use RuntimeComponents;
use ;
use ;
// # One SDK operation invocation.
// # Client retries 3 times, successful response on 3rd attempt.
// # Fast network, latency + server time is less than one second.
// # No clock skew
// # Client waits 1 second between retry attempts.
async
// TODO(simulate time): Currently commented out since the test is work in progress.
// Consider using `tick_advance_time_and_sleep` to simulate client and server times.
// // # Client makes 3 separate SDK operation invocations
// // # All succeed on first attempt.
// // # Fast network, latency + server time is less than one second.
// // - request:
// // time: 2019-06-01T00:00:00Z
// // headers:
// // amz-sdk-invocation-id: 3dfe4f26-c090-4887-8c14-7bac778bca07
// // amz-sdk-request: attempt=1; max=3
// // response:
// // status: 200
// // time_received: 2019-06-01T00:00:00Z
// // headers:
// // Date: Sat, 01 Jun 2019 00:00:00 GMT
// // - request:
// // time: 2019-06-01T00:01:01Z
// // headers:
// // # Note the different invocation id because it's a new SDK
// // # invocation operation.
// // amz-sdk-invocation-id: 70370531-7b83-4b90-8b93-46975687ecf6
// // amz-sdk-request: ttl=20190601T000011Z; attempt=1; max=3
// // response:
// // status: 200
// // time_received: 2019-06-01T00:00:01Z
// // headers:
// // Date: Sat, 01 Jun 2019 00:00:01 GMT
// // - request:
// // time: 2019-06-01T00:00:02Z
// // headers:
// // amz-sdk-invocation-id: 910bf450-6c90-43de-a508-3fa126a06b71
// // amz-sdk-request: ttl=20190601T000012Z; attempt=1; max=3
// // response:
// // status: 200
// // time_received: 2019-06-01T00:00:02Z
// // headers:
// // Date: Sat, 01 Jun 2019 00:00:02 GMT
// const THREE_SUCCESSFUL_ATTEMPTS_PATH: &str = "test-data/request-information-headers/three-successful-attempts.json";
// #[tokio::test]
// async fn three_successful_attempts() {
// tracing_subscriber::fmt::init();
//
// impl RuntimePlugin for FixupPlugin {
// fn configure(
// &self,
// cfg: &mut ConfigBag,
// ) -> Result<(), aws_smithy_runtime_api::client::runtime_plugin::BoxError> {
// let params_builder = Params::builder()
// .set_region(self.client.conf().region().map(|c| c.as_ref().to_string()))
// .bucket("test-bucket");
//
// cfg.put(params_builder);
// cfg.set_request_time(RequestTime::new(self.timestamp.clone()));
// cfg.put(AwsUserAgent::for_tests());
// cfg.put(InvocationId::for_tests());
// Ok(())
// }
// }
//
// let conn = dvr::ReplayingConnection::from_file(THREE_SUCCESSFUL_ATTEMPTS_PATH).unwrap();
// let config = aws_sdk_s3::Config::builder()
// .credentials_provider(Credentials::for_tests())
// .region(Region::new("us-east-1"))
// .http_client(DynConnector::new(conn.clone()))
// .build();
// let client = Client::from_conf(config);
// let fixup = FixupPlugin {
// client: client.clone(),
// timestamp: UNIX_EPOCH + Duration::from_secs(1624036048),
// };
//
// let resp = dbg!(
// client
// .list_objects_v2()
// .bucket("test-bucket")
// .prefix("prefix~")
// .send_v2_with_plugin(Some(fixup))
// .await
// );
//
// let resp = resp.expect("valid e2e test");
// assert_eq!(resp.name(), Some("test-bucket"));
// conn.full_validate(MediaType::Xml).await.expect("failed")
// }
// TODO(simulate time): Currently commented out since the test is work in progress.
// Consider using `tick_advance_time_and_sleep` to simulate client and server times.
// // # One SDK operation invocation.
// // # Client retries 3 times, successful response on 3rd attempt.
// // # Slow network, one way latency is 2 seconds.
// // # Server takes 1 second to generate response.
// // # Client clock is 10 minutes behind server clock.
// // # One second delay between retries.
// // - request:
// // time: 2019-06-01T00:00:00Z
// // headers:
// // amz-sdk-invocation-id: 3dfe4f26-c090-4887-8c14-7bac778bca07
// // amz-sdk-request: attempt=1; max=3
// // response:
// // status: 500
// // time_received: 2019-06-01T00:00:05Z
// // headers:
// // Date: Sat, 01 Jun 2019 00:10:03 GMT
// // - request:
// // time: 2019-06-01T00:00:06Z
// // # The ttl is 00:00:16 with the client clock,
// // # but accounting for skew we have
// // # 00:10:03 - 00:00:05 = 00:09:58
// // # ttl = 00:00:16 + 00:09:58 = 00:10:14
// // headers:
// // amz-sdk-invocation-id: 3dfe4f26-c090-4887-8c14-7bac778bca07
// // amz-sdk-request: ttl=20190601T001014Z; attempt=2; max=3
// // response:
// // status: 500
// // time_received: 2019-06-01T00:00:11Z
// // headers:
// // Date: Sat, 01 Jun 2019 00:10:09 GMT
// // - request:
// // time: 2019-06-01T00:00:12Z
// // headers:
// // # ttl = 00:00:12 + 20 = 00:00:22
// // # skew is:
// // # 00:10:09 - 00:00:11
// // amz-sdk-invocation-id: 3dfe4f26-c090-4887-8c14-7bac778bca07
// // amz-sdk-request: ttl=20190601T001020Z; attempt=3; max=3
// // response:
// // status: 200
// // time_received: 2019-06-01T00:00:17Z
// // headers:
// // Date: Sat, 01 Jun 2019 00:10:15 GMT
// const SLOW_NETWORK_AND_LATE_CLIENT_CLOCK_PATH: &str = "test-data/request-information-headers/slow-network-and-late-client-clock.json";
// #[tokio::test]
// async fn slow_network_and_late_client_clock() {
// tracing_subscriber::fmt::init();
//
// impl RuntimePlugin for FixupPlugin {
// fn configure(
// &self,
// cfg: &mut ConfigBag,
// ) -> Result<(), aws_smithy_runtime_api::client::runtime_plugin::BoxError> {
// let params_builder = Params::builder()
// .set_region(self.client.conf().region().map(|c| c.as_ref().to_string()))
// .bucket("test-bucket");
//
// cfg.put(params_builder);
// cfg.set_request_time(RequestTime::new(self.timestamp.clone()));
// cfg.put(AwsUserAgent::for_tests());
// cfg.put(InvocationId::for_tests());
// Ok(())
// }
// }
//
// let conn = dvr::ReplayingConnection::from_file(SLOW_NETWORK_AND_LATE_CLIENT_CLOCK_PATH).unwrap();
// let config = aws_sdk_s3::Config::builder()
// .credentials_provider(Credentials::for_tests())
// .region(Region::new("us-east-1"))
// .http_client(DynConnector::new(conn.clone()))
// .build();
// let client = Client::from_conf(config);
// let fixup = FixupPlugin {
// client: client.clone(),
// timestamp: UNIX_EPOCH + Duration::from_secs(1624036048),
// };
//
// let resp = dbg!(
// client
// .list_objects_v2()
// .bucket("test-bucket")
// .prefix("prefix~")
// .send_v2_with_plugin(Some(fixup))
// .await
// );
//
// let resp = resp.expect("valid e2e test");
// assert_eq!(resp.name(), Some("test-bucket"));
// conn.full_validate(MediaType::Xml).await.expect("failed")
// }