Skip to content

Commit

Permalink
Update dynamodb snapshots (localstack#8972)
Browse files Browse the repository at this point in the history
  • Loading branch information
steffyP authored Aug 24, 2023
1 parent cae0583 commit fc5570f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 56 deletions.
6 changes: 4 additions & 2 deletions tests/aws/services/cloudformation/resources/test_dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def test_globalindex_read_write_provisioned_throughput_dynamodb_table(
"$..Table.ProvisionedThroughput.LastDecreaseDateTime",
"$..Table.ProvisionedThroughput.LastIncreaseDateTime",
"$..Table.Replicas",
"$..Table.DeletionProtectionEnabled",
]
)
def test_default_name_for_table(deploy_cfn_template, snapshot, aws_client):
Expand All @@ -86,14 +87,15 @@ def test_default_name_for_table(deploy_cfn_template, snapshot, aws_client):
"$..Table.ProvisionedThroughput.LastIncreaseDateTime",
"$..Table.Replicas",
"$..Table.DeletionProtectionEnabled",
"$..Table.LatestStreamArn",
"$..Table.LatestStreamLabel",
]
)
@pytest.mark.parametrize("billing_mode", ["PROVISIONED", "PAY_PER_REQUEST"])
def test_billing_mode_as_conditional(deploy_cfn_template, snapshot, aws_client, billing_mode):
snapshot.add_transformer(snapshot.transform.dynamodb_api())
snapshot.add_transformer(snapshot.transform.key_value("TableName", "table-name"))
snapshot.add_transformer(
snapshot.transform.key_value("LatestStreamLabel", "latest-stream-label")
)
stack = deploy_cfn_template(
template_path=os.path.join(
os.path.dirname(__file__), "../../../templates/dynamodb_billing_conditional.yml"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"tests/aws/services/cloudformation/resources/test_dynamodb.py::test_default_name_for_table": {
"recorded-date": "21-10-2022, 11:11:09",
"recorded-date": "23-08-2023, 17:50:06",
"recorded-content": {
"table_description": {
"Table": {
Expand All @@ -11,6 +11,7 @@
}
],
"CreationDateTime": "datetime",
"DeletionProtectionEnabled": false,
"ItemCount": 0,
"KeySchema": [
{
Expand All @@ -37,7 +38,7 @@
}
},
"tests/aws/services/cloudformation/resources/test_dynamodb.py::test_billing_mode_as_conditional[PROVISIONED]": {
"recorded-date": "18-04-2023, 10:44:47",
"recorded-date": "23-08-2023, 17:59:11",
"recorded-content": {
"table_description": {
"Table": {
Expand All @@ -56,8 +57,8 @@
"KeyType": "HASH"
}
],
"LatestStreamArn": "arn:aws:dynamodb:<region>:111111111111:table/<table-name:1>/stream/2023-04-18T15:44:18.287",
"LatestStreamLabel": "2023-04-18T15:44:18.287",
"LatestStreamArn": "arn:aws:dynamodb:<region>:111111111111:table/<table-name:1>/stream/<latest-stream-label:1>",
"LatestStreamLabel": "<latest-stream-label:1>",
"ProvisionedThroughput": {
"NumberOfDecreasesToday": 0,
"ReadCapacityUnits": 5,
Expand All @@ -81,7 +82,7 @@
}
},
"tests/aws/services/cloudformation/resources/test_dynamodb.py::test_billing_mode_as_conditional[PAY_PER_REQUEST]": {
"recorded-date": "18-04-2023, 10:45:28",
"recorded-date": "23-08-2023, 17:59:35",
"recorded-content": {
"table_description": {
"Table": {
Expand All @@ -104,8 +105,8 @@
"KeyType": "HASH"
}
],
"LatestStreamArn": "arn:aws:dynamodb:<region>:111111111111:table/<table-name:1>/stream/2023-04-18T15:45:01.056",
"LatestStreamLabel": "2023-04-18T15:45:01.056",
"LatestStreamArn": "arn:aws:dynamodb:<region>:111111111111:table/<table-name:1>/stream/<latest-stream-label:1>",
"LatestStreamLabel": "<latest-stream-label:1>",
"ProvisionedThroughput": {
"NumberOfDecreasesToday": 0,
"ReadCapacityUnits": 0,
Expand Down
32 changes: 13 additions & 19 deletions tests/aws/services/dynamodb/test_dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
import pytest
from boto3.dynamodb.types import STRING

from localstack.aws.api.dynamodb import (
ContinuousBackupsUnavailableException,
PointInTimeRecoverySpecification,
)
from localstack.aws.api.dynamodb import PointInTimeRecoverySpecification
from localstack.services.dynamodbstreams.dynamodbstreams_api import get_kinesis_stream_name
from localstack.testing.aws.lambda_utils import _await_dynamodb_table_active
from localstack.testing.aws.util import is_aws_cloud
from localstack.testing.pytest import markers
from localstack.testing.snapshots.transformer import SortingTransformer
from localstack.utils import testutil
Expand Down Expand Up @@ -1391,13 +1389,6 @@ def test_dynamodb_create_table_with_sse_specification(
assert result["TableDescription"]["SSEDescription"]["KMSMasterKeyArn"] == kms_master_key_arn

@markers.aws.validated
@markers.snapshot.skip_snapshot_verify(
paths=[
"$..KeyMetadata..KeyUsage",
"$..KeyMetadata..MultiRegion",
"$..KeyMetadata..SigningAlgorithms",
]
)
def test_dynamodb_create_table_with_partial_sse_specification(
self, dynamodb_create_table_with_parameters, snapshot, aws_client
):
Expand Down Expand Up @@ -1593,10 +1584,7 @@ def test_nosql_workbench_localhost_region(
table = client.describe_table(TableName=table_name)
assert table.get("Table")

@markers.aws.only_localstack(reason="wait_for_stream_ready of kinesis stream")
@markers.snapshot.skip_snapshot_verify(
paths=["$..eventID", "$..SequenceNumber", "$..SizeBytes"]
)
@markers.aws.validated
def test_data_encoding_consistency(
self, dynamodb_create_table_with_parameters, wait_for_stream_ready, snapshot, aws_client
):
Expand All @@ -1611,8 +1599,10 @@ def test_data_encoding_consistency(
"StreamViewType": "NEW_AND_OLD_IMAGES",
},
)
stream_name = get_kinesis_stream_name(table_name)
wait_for_stream_ready(stream_name)
if not is_aws_cloud():
# required for LS because the stream is using kinesis, which needs to be ready
stream_name = get_kinesis_stream_name(table_name)
wait_for_stream_ready(stream_name)

# put item
aws_client.dynamodb.put_item(
Expand Down Expand Up @@ -1689,10 +1679,14 @@ def wait_for_continuous_backend():
),
)
return True
except ContinuousBackupsUnavailableException:
except Exception: # noqa
return False

assert poll_condition(wait_for_continuous_backend, timeout=10)
assert poll_condition(
wait_for_continuous_backend,
timeout=50 if is_aws_cloud() else 10,
interval=1 if is_aws_cloud() else 0.5,
)

response = aws_client.dynamodb.update_continuous_backups(
TableName=table_name,
Expand Down
48 changes: 20 additions & 28 deletions tests/aws/services/dynamodb/test_dynamodb.snapshot.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_valid_local_secondary_index": {
"recorded-date": "15-09-2022, 09:00:29",
"recorded-date": "23-08-2023, 16:32:11",
"recorded-content": {
"Items": {
"Count": 1,
Expand All @@ -26,7 +26,7 @@
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_return_values_in_put_item": {
"recorded-date": "13-07-2023, 11:57:53",
"recorded-date": "23-08-2023, 16:32:21",
"recorded-content": {
"PutFirstItem": {
"ResponseMetadata": {
Expand Down Expand Up @@ -77,7 +77,7 @@
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_empty_and_binary_values": {
"recorded-date": "15-09-2022, 09:00:44",
"recorded-date": "23-08-2023, 16:32:29",
"recorded-content": {
"PutFirstItem": {
"ResponseMetadata": {
Expand All @@ -94,7 +94,7 @@
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_batch_write_binary": {
"recorded-date": "15-09-2022, 10:19:38",
"recorded-date": "23-08-2023, 16:32:35",
"recorded-content": {
"Response": {
"UnprocessedItems": {},
Expand All @@ -106,7 +106,7 @@
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_dynamodb_execute_transaction": {
"recorded-date": "15-09-2022, 09:00:55",
"recorded-date": "23-08-2023, 16:32:44",
"recorded-content": {
"ExecutedTransaction": {
"Responses": [],
Expand Down Expand Up @@ -138,7 +138,7 @@
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_dynamodb_batch_execute_statement": {
"recorded-date": "15-09-2022, 09:01:02",
"recorded-date": "23-08-2023, 16:32:51",
"recorded-content": {
"ExecutedStatement": {
"Responses": [
Expand Down Expand Up @@ -170,7 +170,7 @@
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_dynamodb_partiql_missing": {
"recorded-date": "15-09-2022, 09:01:11",
"recorded-date": "23-08-2023, 16:33:00",
"recorded-content": {
"FirstNameNotMissing": [
{
Expand All @@ -185,13 +185,13 @@
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_create_duplicate_table": {
"recorded-date": "15-09-2022, 09:01:17",
"recorded-date": "23-08-2023, 16:33:08",
"recorded-content": {
"Error": "An error occurred (ResourceInUseException) when calling the CreateTable operation: Table already exists: <test-table>"
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_transaction_write_items": {
"recorded-date": "15-09-2022, 09:01:24",
"recorded-date": "23-08-2023, 16:33:16",
"recorded-content": {
"Response": {
"ResponseMetadata": {
Expand All @@ -202,13 +202,13 @@
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_transaction_write_canceled": {
"recorded-date": "15-09-2022, 09:01:29",
"recorded-date": "23-08-2023, 16:33:24",
"recorded-content": {
"Error": "An error occurred (TransactionCanceledException) when calling the TransactWriteItems operation: Transaction cancelled, please refer cancellation reasons for specific reasons [ConditionalCheckFailed, None]"
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_transaction_write_binary_data": {
"recorded-date": "15-09-2022, 09:01:36",
"recorded-date": "23-08-2023, 16:33:31",
"recorded-content": {
"WriteResponse": {
"ResponseMetadata": {
Expand All @@ -227,7 +227,7 @@
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_transact_get_items": {
"recorded-date": "15-09-2022, 09:01:41",
"recorded-date": "23-08-2023, 16:33:37",
"recorded-content": {
"TransactGetItems": {
"Responses": [
Expand All @@ -247,7 +247,7 @@
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_batch_write_items": {
"recorded-date": "15-09-2022, 09:01:46",
"recorded-date": "23-08-2023, 16:33:43",
"recorded-content": {
"BatchWriteResponse": {
"UnprocessedItems": {},
Expand All @@ -259,13 +259,13 @@
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_dynamodb_pay_per_request": {
"recorded-date": "15-09-2022, 09:01:57",
"recorded-date": "23-08-2023, 16:33:43",
"recorded-content": {
"Error": "An error occurred (ValidationException) when calling the CreateTable operation: One or more parameter values were invalid: Neither ReadCapacityUnits nor WriteCapacityUnits can be specified when BillingMode is PAY_PER_REQUEST"
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_dynamodb_create_table_with_partial_sse_specification": {
"recorded-date": "15-09-2022, 10:35:34",
"recorded-date": "23-08-2023, 16:33:50",
"recorded-content": {
"SSEDescription": {
"KMSMasterKeyArn": "arn:aws:kms:<region>:111111111111:key/<uuid:1>",
Expand Down Expand Up @@ -299,7 +299,7 @@
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_dynamodb_get_batch_items": {
"recorded-date": "15-09-2022, 09:02:09",
"recorded-date": "23-08-2023, 16:33:58",
"recorded-content": {
"Response": {
"Responses": {
Expand All @@ -314,7 +314,7 @@
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_dynamodb_idempotent_writing": {
"recorded-date": "15-09-2022, 09:02:15",
"recorded-date": "23-08-2023, 16:39:54",
"recorded-content": {
"Response1": {
"ResponseMetadata": {
Expand All @@ -331,13 +331,13 @@
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_batch_write_not_matching_schema": {
"recorded-date": "15-09-2022, 09:02:20",
"recorded-date": "23-08-2023, 16:34:26",
"recorded-content": {
"ValidationException": "An error occurred (ValidationException) when calling the BatchWriteItem operation: The provided key element does not match the schema"
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_data_encoding_consistency": {
"recorded-date": "09-11-2022, 11:27:21",
"recorded-date": "24-08-2023, 10:56:37",
"recorded-content": {
"GetItem": {
"data": {
Expand Down Expand Up @@ -386,7 +386,7 @@
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_continuous_backup_update": {
"recorded-date": "22-02-2023, 21:13:32",
"recorded-date": "23-08-2023, 16:34:39",
"recorded-content": {
"update-continuous-backup": {
"ContinuousBackupsDescription": {
Expand Down Expand Up @@ -417,13 +417,5 @@
}
}
}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_dynamodb_streams_arn_format": {
"recorded-date": "05-06-2023, 13:54:14",
"recorded-content": {}
},
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_dynamodb_streams_shard_iterator_format": {
"recorded-date": "05-06-2023, 17:04:25",
"recorded-content": {}
}
}

0 comments on commit fc5570f

Please sign in to comment.