diff --git a/CHANGES.md b/CHANGES.md index a9589fa6..763de469 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -15,6 +15,7 @@ - MongoDB: Make `migr8 extract` and `migr8 export` accept the `--limit` option - MongoDB: Fix indentation in prettified SQL output of `migr8 translate` - MongoDB: Add capability to give type hints and add transformations +- Dependencies: Adjust code for lorrystream version 0.0.3 ## 2024/07/25 v0.0.16 - `ctk load table`: Added support for MongoDB Change Streams diff --git a/cratedb_toolkit/iac/aws.py b/cratedb_toolkit/iac/aws.py index 904af12c..1aad2d73 100644 --- a/cratedb_toolkit/iac/aws.py +++ b/cratedb_toolkit/iac/aws.py @@ -1,9 +1,10 @@ +from lorrystream.carabas.aws import DynamoDBKinesisPipe, RDSPostgreSQLDMSKinesisPipe from lorrystream.carabas.aws.function.model import LambdaFactory from lorrystream.carabas.aws.function.oci import LambdaPythonImage -from lorrystream.carabas.aws.stack import DynamoDBKinesisPipe __all__ = [ + "DynamoDBKinesisPipe", "LambdaFactory", "LambdaPythonImage", - "DynamoDBKinesisPipe", + "RDSPostgreSQLDMSKinesisPipe", ] diff --git a/cratedb_toolkit/io/processor/kinesis_lambda.py b/cratedb_toolkit/io/processor/kinesis_lambda.py index c9c60a78..c2219beb 100644 --- a/cratedb_toolkit/io/processor/kinesis_lambda.py +++ b/cratedb_toolkit/io/processor/kinesis_lambda.py @@ -25,7 +25,7 @@ # /// script # requires-python = ">=3.9" # dependencies = [ -# "commons-codec==0.0.3", +# "commons-codec==0.0.4", # "sqlalchemy-cratedb==0.38.0", # ] # /// diff --git a/pyproject.toml b/pyproject.toml index 1771e5f4..85cc9d26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -151,7 +151,7 @@ io = [ "sqlalchemy>=2", ] kinesis = [ - "lorrystream @ git+https://github.com/daq-tools/lorrystream.git@kinesis", + "lorrystream[carabas]==0.0.3", ] mongodb = [ "commons-codec[mongodb,zyp]==0.0.4", diff --git a/tests/io/test_iac.py b/tests/io/test_iac.py new file mode 100644 index 00000000..8136bfd6 --- /dev/null +++ b/tests/io/test_iac.py @@ -0,0 +1,10 @@ +# ruff: noqa: F401 + + +def test_iac_imports(): + from cratedb_toolkit.iac.aws import ( + DynamoDBKinesisPipe, + LambdaFactory, + LambdaPythonImage, + RDSPostgreSQLDMSKinesisPipe, + ) diff --git a/tests/io/test_processor.py b/tests/io/test_processor.py new file mode 100644 index 00000000..db972ffc --- /dev/null +++ b/tests/io/test_processor.py @@ -0,0 +1,31 @@ +import os +import sys + +import pytest + + +@pytest.fixture +def reset_handler(): + try: + del sys.modules["cratedb_toolkit.io.processor.kinesis_lambda"] + except KeyError: + pass + + +def test_processor_invoke_no_records(reset_handler, mocker, caplog): + """ + Roughly verify that the unified Lambda handler works. + """ + + # Configure environment variables. + handler_environment = { + "MESSAGE_FORMAT": "dms", + } + mocker.patch.dict(os.environ, handler_environment) + + from cratedb_toolkit.io.processor.kinesis_lambda import handler + + event = {"Records": []} + handler(event, None) + + assert "Successfully processed 0 records" in caplog.messages