10
10
)
11
11
12
12
# Base request structures that are shared between DDB and dict formats
13
+ # Use ConsistentRead: True for all requests;
14
+ # many of these are used in integ tests, where consistent reads reduce test flakiness.
13
15
14
16
15
17
def base_put_item_request (item ):
@@ -19,7 +21,7 @@ def base_put_item_request(item):
19
21
20
22
def base_get_item_request (item ):
21
23
"""Base structure for get_item requests."""
22
- return {"Key" : {"partition_key" : item ["partition_key" ], "sort_key" : item ["sort_key" ]}}
24
+ return {"Key" : {"partition_key" : item ["partition_key" ], "sort_key" : item ["sort_key" ]}, "ConsistentRead" : True }
23
25
24
26
25
27
def base_delete_item_request (item ):
@@ -32,6 +34,7 @@ def base_query_request(item):
32
34
return {
33
35
"KeyConditionExpression" : "partition_key = :pk" ,
34
36
"ExpressionAttributeValues" : {":pk" : item ["partition_key" ]},
37
+ "ConsistentRead" : True ,
35
38
}
36
39
37
40
@@ -40,6 +43,7 @@ def base_scan_request(item):
40
43
return {
41
44
"FilterExpression" : "attribute2 = :a2" ,
42
45
"ExpressionAttributeValues" : {":a2" : item ["attribute2" ]},
46
+ "ConsistentRead" : True ,
43
47
}
44
48
45
49
@@ -50,7 +54,7 @@ def base_batch_write_item_request(actions_with_items):
50
54
51
55
def base_batch_get_item_request (keys ):
52
56
"""Base structure for batch_get_item requests."""
53
- return {"RequestItems" : {INTEG_TEST_DEFAULT_DYNAMODB_TABLE_NAME : {"Keys" : keys }}}
57
+ return {"RequestItems" : {INTEG_TEST_DEFAULT_DYNAMODB_TABLE_NAME : {"Keys" : keys , "ConsistentRead" : True }}}
54
58
55
59
56
60
def base_transact_write_item_request (actions_with_items ):
@@ -142,15 +146,15 @@ def basic_batch_execute_statement_request_plaintext_table():
142
146
143
147
# No exhaustive requests are intended to be able to be used as real requests.
144
148
# Some parameters conflict with each other when sent to DynamoDB.
145
- # These are only intended to test the conversion of the structure from client to resource format .
149
+ # These are only intended to test the conversion of the structure between client and resource formats .
146
150
147
151
148
152
def base_exhaustive_put_item_request (item ):
149
153
"""
150
154
Base structure for exhaustive put_item requests.
151
155
This is not intended to be able to be used as a real request.
152
156
Some parameters conflict with each other when sent to DynamoDB.
153
- This is only intended to test the conversion of the request from client to resource format .
157
+ This is only intended to test the conversion of the request between client and resource formats .
154
158
"""
155
159
return {
156
160
# Expected is legacy, but still in the boto3 docs.
@@ -174,7 +178,7 @@ def base_exhaustive_get_item_request(item):
174
178
Base structure for exhaustive get_item requests.
175
179
This is not intended to be able to be used as a real request.
176
180
Some parameters conflict with each other when sent to DynamoDB.
177
- This is only intended to test the conversion of the request from client to resource format .
181
+ This is only intended to test the conversion of the request between client and resource formats .
178
182
"""
179
183
return {
180
184
"ReturnConsumedCapacity" : "TOTAL" ,
@@ -196,7 +200,7 @@ def base_exhaustive_delete_item_request(item):
196
200
Base structure for exhaustive delete_item requests.
197
201
This is not intended to be able to be used as a real request.
198
202
Some parameters conflict with each other when sent to DynamoDB.
199
- This is only intended to test the conversion of the request from client to resource format .
203
+ This is only intended to test the conversion of the request between client and resource formats .
200
204
"""
201
205
return {
202
206
"ReturnConsumedCapacity" : "TOTAL" ,
@@ -211,7 +215,7 @@ def base_exhaustive_query_request(item):
211
215
Base structure for exhaustive query requests.
212
216
This is not intended to be able to be used as a real request.
213
217
Some parameters conflict with each other when sent to DynamoDB.
214
- This is only intended to test the conversion of the request from client to resource format .
218
+ This is only intended to test the conversion of the request between client and resource formats .
215
219
"""
216
220
return {
217
221
"IndexName" : "index_name" ,
@@ -240,7 +244,7 @@ def base_exhaustive_scan_request(item):
240
244
Base structure for exhaustive scan requests.
241
245
This is not intended to be able to be used as a real request.
242
246
Some parameters conflict with each other when sent to DynamoDB.
243
- This is only intended to test the conversion of the request from client to resource format .
247
+ This is only intended to test the conversion of the request between client and resource formats .
244
248
"""
245
249
return {
246
250
"IndexName" : "index_name" ,
@@ -310,7 +314,7 @@ def exhaustive_query_request_ddb(item):
310
314
Query request with all possible parameters.
311
315
This is not intended to be able to be used as a real request.
312
316
Some parameters conflict with each other when sent to DynamoDB.
313
- This is only intended to test the conversion of the request from client to resource format .
317
+ This is only intended to test the conversion of the request between client and resource formats .
314
318
"""
315
319
base = basic_query_request_ddb (item )
316
320
additional_keys = base_exhaustive_query_request (item )
@@ -390,6 +394,7 @@ def basic_query_paginator_request(key):
390
394
"TableName" : INTEG_TEST_DEFAULT_DYNAMODB_TABLE_NAME ,
391
395
"KeyConditionExpression" : "partition_key = :pk AND sort_key = :sk" ,
392
396
"ExpressionAttributeValues" : {":pk" : key ["partition_key" ], ":sk" : key ["sort_key" ]},
397
+ "ConsistentRead" : True ,
393
398
}
394
399
395
400
@@ -399,6 +404,7 @@ def basic_scan_paginator_request(item):
399
404
"TableName" : INTEG_TEST_DEFAULT_DYNAMODB_TABLE_NAME ,
400
405
"FilterExpression" : "partition_key = :pk AND sort_key = :sk" ,
401
406
"ExpressionAttributeValues" : {":pk" : item ["partition_key" ], ":sk" : item ["sort_key" ]},
407
+ "ConsistentRead" : True ,
402
408
}
403
409
404
410
@@ -427,7 +433,7 @@ def exhaustive_put_item_request_dict(item):
427
433
Get a put_item request in dict format for any item.
428
434
This is not intended to be able to be used as a real request.
429
435
Some parameters conflict with each other when sent to DynamoDB.
430
- This is only intended to test the conversion of the request from client to resource format .
436
+ This is only intended to test the conversion of the request between client and resource formats .
431
437
"""
432
438
base = basic_put_item_request_dict (item )
433
439
# Replace the default ConditionExpression string with a ConditionExpression object
@@ -452,7 +458,7 @@ def exhaustive_get_item_request_dict(item):
452
458
Get a get_item request in dict format for any item.
453
459
This is not intended to be able to be used as a real request.
454
460
Some parameters conflict with each other when sent to DynamoDB.
455
- This is only intended to test the conversion of the request from client to resource format .
461
+ This is only intended to test the conversion of the request between client and resource formats .
456
462
"""
457
463
base = basic_get_item_request_dict (item )
458
464
additional_keys = base_exhaustive_get_item_request (item )
@@ -478,7 +484,7 @@ def exhaustive_query_request_dict(item):
478
484
Get a query request in dict format for any item.
479
485
This is not intended to be able to be used as a real request.
480
486
Some parameters conflict with each other when sent to DynamoDB.
481
- This is only intended to test the conversion of the request from client to resource format .
487
+ This is only intended to test the conversion of the request between client and resource formats .
482
488
"""
483
489
base = basic_query_request_dict (item )
484
490
additional_keys = base_exhaustive_query_request (item )
@@ -495,7 +501,7 @@ def exhaustive_scan_request_dict(item):
495
501
Get a scan request in dict format for any item.
496
502
This is not intended to be able to be used as a real request.
497
503
Some parameters conflict with each other when sent to DynamoDB.
498
- This is only intended to test the conversion of the request from client to resource format .
504
+ This is only intended to test the conversion of the request between client and resource formats .
499
505
"""
500
506
base = basic_scan_request_dict (item )
501
507
additional_keys = base_exhaustive_scan_request (item )
0 commit comments