|
13 | 13 | from contextlib import contextmanager |
14 | 14 | from decimal import Decimal |
15 | 15 |
|
| 16 | +# All tests in this file are expected to fail with tablets due to #16567. |
| 17 | +# To ensure that Alternator TTL is still being tested, instead of |
| 18 | +# xfailing these tests, we temporarily coerce the tests below to avoid |
| 19 | +# using default tablets setting, even if it's available. We do this by |
| 20 | +# using the following tags when creating each table below: |
| 21 | +TAGS = [{'Key': 'experimental:initial_tablets', 'Value': 'none'}] |
| 22 | + |
16 | 23 | # passes_or_raises() is similar to pytest.raises(), except that while raises() |
17 | 24 | # expects a certain exception must happen, the new passes_or_raises() |
18 | 25 | # expects the code to either pass (not raise), or if it throws, it must |
@@ -85,6 +92,7 @@ def test_describe_ttl_without_ttl(test_table): |
85 | 92 | # and this information becomes available via DescribeTimeToLive |
86 | 93 | def test_ttl_enable(dynamodb): |
87 | 94 | with new_test_table(dynamodb, |
| 95 | + Tags=TAGS, |
88 | 96 | KeySchema=[ { 'AttributeName': 'p', 'KeyType': 'HASH' }, ], |
89 | 97 | AttributeDefinitions=[ { 'AttributeName': 'p', 'AttributeType': 'S' } ]) as table: |
90 | 98 | client = table.meta.client |
@@ -120,6 +128,7 @@ def test_ttl_enable(dynamodb): |
120 | 128 | # disable case. |
121 | 129 | def test_ttl_disable_errors(dynamodb): |
122 | 130 | with new_test_table(dynamodb, |
| 131 | + Tags=TAGS, |
123 | 132 | KeySchema=[ { 'AttributeName': 'p', 'KeyType': 'HASH' }, ], |
124 | 133 | AttributeDefinitions=[ { 'AttributeName': 'p', 'AttributeType': 'S' } ]) as table: |
125 | 134 | client = table.meta.client |
@@ -152,6 +161,7 @@ def test_ttl_disable_errors(dynamodb): |
152 | 161 | # minutes). But on Scylla it is currently almost instantaneous. |
153 | 162 | def test_ttl_disable(dynamodb, veryslow_on_aws): |
154 | 163 | with new_test_table(dynamodb, |
| 164 | + Tags=TAGS, |
155 | 165 | KeySchema=[ { 'AttributeName': 'p', 'KeyType': 'HASH' }, ], |
156 | 166 | AttributeDefinitions=[ { 'AttributeName': 'p', 'AttributeType': 'S' } ]) as table: |
157 | 167 | client = table.meta.client |
@@ -185,6 +195,7 @@ def test_update_ttl_errors(dynamodb): |
185 | 195 | client.update_time_to_live(TableName=nonexistent_table, |
186 | 196 | TimeToLiveSpecification={'AttributeName': 'expiration', 'Enabled': True}) |
187 | 197 | with new_test_table(dynamodb, |
| 198 | + Tags=TAGS, |
188 | 199 | KeySchema=[ { 'AttributeName': 'p', 'KeyType': 'HASH' }, ], |
189 | 200 | AttributeDefinitions=[ { 'AttributeName': 'p', 'AttributeType': 'S' } ]) as table: |
190 | 201 | # AttributeName must be between 1 and 255 characters long. |
@@ -232,6 +243,7 @@ def test_ttl_expiration(dynamodb): |
232 | 243 | delta = math.ceil(duration / 4) |
233 | 244 | assert delta >= 1 |
234 | 245 | with new_test_table(dynamodb, |
| 246 | + Tags=TAGS, |
235 | 247 | KeySchema=[ { 'AttributeName': 'p', 'KeyType': 'HASH' }, ], |
236 | 248 | AttributeDefinitions=[ { 'AttributeName': 'p', 'AttributeType': 'S' } ]) as table: |
237 | 249 | # Insert one expiring item *before* enabling the TTL, to verify that |
@@ -354,6 +366,7 @@ def test_ttl_expiration_with_rangekey(dynamodb, waits_for_expiration): |
354 | 366 | max_duration = 1200 if is_aws(dynamodb) else 240 |
355 | 367 | sleep = 30 if is_aws(dynamodb) else 0.1 |
356 | 368 | with new_test_table(dynamodb, |
| 369 | + Tags=TAGS, |
357 | 370 | KeySchema=[ { 'AttributeName': 'p', 'KeyType': 'HASH' }, |
358 | 371 | { 'AttributeName': 'c', 'KeyType': 'RANGE' } ], |
359 | 372 | AttributeDefinitions=[ { 'AttributeName': 'p', 'AttributeType': 'S' }, |
@@ -392,6 +405,7 @@ def test_ttl_expiration_hash(dynamodb, waits_for_expiration): |
392 | 405 | max_duration = 1200 if is_aws(dynamodb) else 240 |
393 | 406 | sleep = 30 if is_aws(dynamodb) else 0.1 |
394 | 407 | with new_test_table(dynamodb, |
| 408 | + Tags=TAGS, |
395 | 409 | KeySchema=[ { 'AttributeName': 'p', 'KeyType': 'HASH' }, ], |
396 | 410 | AttributeDefinitions=[ { 'AttributeName': 'p', 'AttributeType': 'N' } ]) as table: |
397 | 411 | ttl_spec = {'AttributeName': 'p', 'Enabled': True} |
@@ -424,6 +438,7 @@ def test_ttl_expiration_range(dynamodb, waits_for_expiration): |
424 | 438 | max_duration = 1200 if is_aws(dynamodb) else 240 |
425 | 439 | sleep = 30 if is_aws(dynamodb) else 0.1 |
426 | 440 | with new_test_table(dynamodb, |
| 441 | + Tags=TAGS, |
427 | 442 | KeySchema=[ { 'AttributeName': 'p', 'KeyType': 'HASH' }, { 'AttributeName': 'c', 'KeyType': 'RANGE' } ], |
428 | 443 | AttributeDefinitions=[ { 'AttributeName': 'p', 'AttributeType': 'S' }, { 'AttributeName': 'c', 'AttributeType': 'N' } ]) as table: |
429 | 444 | ttl_spec = {'AttributeName': 'c', 'Enabled': True} |
@@ -463,6 +478,7 @@ def check_expired(): |
463 | 478 | def test_ttl_expiration_hash_wrong_type(dynamodb): |
464 | 479 | duration = 900 if is_aws(dynamodb) else 3 |
465 | 480 | with new_test_table(dynamodb, |
| 481 | + Tags=TAGS, |
466 | 482 | KeySchema=[ { 'AttributeName': 'p', 'KeyType': 'HASH' }, ], |
467 | 483 | AttributeDefinitions=[ { 'AttributeName': 'p', 'AttributeType': 'S' } ]) as table: |
468 | 484 | ttl_spec = {'AttributeName': 'p', 'Enabled': True} |
@@ -496,6 +512,7 @@ def test_ttl_expiration_gsi_lsi(dynamodb, waits_for_expiration): |
496 | 512 | max_duration = 3600 if is_aws(dynamodb) else 240 |
497 | 513 | sleep = 30 if is_aws(dynamodb) else 0.1 |
498 | 514 | with new_test_table(dynamodb, |
| 515 | + Tags=TAGS, |
499 | 516 | KeySchema=[ |
500 | 517 | { 'AttributeName': 'p', 'KeyType': 'HASH' }, |
501 | 518 | { 'AttributeName': 'c', 'KeyType': 'RANGE' }, |
@@ -589,6 +606,7 @@ def test_ttl_expiration_lsi_key(dynamodb, waits_for_expiration): |
589 | 606 | max_duration = 3600 if is_aws(dynamodb) else 240 |
590 | 607 | sleep = 30 if is_aws(dynamodb) else 0.1 |
591 | 608 | with new_test_table(dynamodb, |
| 609 | + Tags=TAGS, |
592 | 610 | KeySchema=[ |
593 | 611 | { 'AttributeName': 'p', 'KeyType': 'HASH' }, |
594 | 612 | { 'AttributeName': 'c', 'KeyType': 'RANGE' }, |
@@ -644,6 +662,7 @@ def test_ttl_expiration_streams(dynamodb, dynamodbstreams): |
644 | 662 | # max_duration, we report a failure. |
645 | 663 | max_duration = 3600 if is_aws(dynamodb) else 10 |
646 | 664 | with new_test_table(dynamodb, |
| 665 | + Tags=TAGS, |
647 | 666 | KeySchema=[ |
648 | 667 | { 'AttributeName': 'p', 'KeyType': 'HASH' }, |
649 | 668 | { 'AttributeName': 'c', 'KeyType': 'RANGE' }, |
@@ -756,6 +775,7 @@ def test_ttl_expiration_long(dynamodb, waits_for_expiration): |
756 | 775 | N=400 |
757 | 776 | max_duration = 1200 if is_aws(dynamodb) else 15 |
758 | 777 | with new_test_table(dynamodb, |
| 778 | + Tags=TAGS, |
759 | 779 | KeySchema=[ { 'AttributeName': 'p', 'KeyType': 'HASH' }, |
760 | 780 | { 'AttributeName': 'c', 'KeyType': 'RANGE' } ], |
761 | 781 | AttributeDefinitions=[ { 'AttributeName': 'p', 'AttributeType': 'N' }, |
|
0 commit comments