-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DynamoDB: Add software test for decoding list of objects #246
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from cratedb_toolkit.io.dynamodb.copy import DynamoDBFullLoad | ||
|
||
RECORD_UTM = { | ||
"Id": {"N": "101"}, | ||
"utmTags": { | ||
"L": [ | ||
{ | ||
"M": { | ||
"date": {"S": "2024-08-28T20:05:42.603Z"}, | ||
"utm_adgroup": {"L": [{"S": ""}, {"S": ""}]}, | ||
"utm_campaign": {"S": "34374686341"}, | ||
"utm_medium": {"S": "foobar"}, | ||
"utm_source": {"S": "google"}, | ||
} | ||
} | ||
] | ||
}, | ||
} | ||
|
||
|
||
def test_dynamodb_copy_list_of_objects(caplog, cratedb, dynamodb, dynamodb_test_manager): | ||
""" | ||
CLI test: Invoke `ctk load table` for DynamoDB. | ||
""" | ||
|
||
# Define source and target URLs. | ||
cratedb_url = f"{cratedb.get_connection_url()}/testdrive/demo" | ||
dynamodb_url = f"{dynamodb.get_connection_url()}/demo?region=us-east-1" | ||
|
||
# Populate source database with data. | ||
dynamodb_test_manager.load_records(table_name="demo", records=[RECORD_UTM]) | ||
|
||
# Run transfer command. | ||
table_loader = DynamoDBFullLoad(dynamodb_url=dynamodb_url, cratedb_url=cratedb_url) | ||
table_loader.start() | ||
|
||
# Verify data in target database. | ||
assert cratedb.database.table_exists("testdrive.demo") is True | ||
assert cratedb.database.refresh_table("testdrive.demo") is True | ||
assert cratedb.database.count_records("testdrive.demo") == 1 | ||
|
||
results = cratedb.database.run_sql("SELECT * FROM testdrive.demo;", records=True) # noqa: S608 | ||
assert results[0]["data"] == { | ||
"Id": 101.0, | ||
"utmTags": [ | ||
{ | ||
"date": "2024-08-28T20:05:42.603Z", | ||
"utm_adgroup": ["", ""], | ||
"utm_campaign": "34374686341", | ||
"utm_medium": "foobar", | ||
"utm_source": "google", | ||
} | ||
], | ||
} | ||
Comment on lines
+42
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. .... that's the outcome that proves data converges into a CrateDB record well, afaics. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on this input data (DynamoDB table record), and a SQL DDL like
[...]