Skip to content

Commit

Permalink
Kinesis: Adjust code for lorrystream version 0.0.3. Add tests.
Browse files Browse the repository at this point in the history
On the last occasion, dependencies to lorrystream have not been verified
correctly, so it was expectable that things go south.

This patch fixes them, and adds rudimentary software tests to avoid
tripping into the same situation as before.
  • Loading branch information
amotl committed Aug 16, 2024
1 parent 2e95ce4 commit d71aa85
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions cratedb_toolkit/iac/aws.py
Original file line number Diff line number Diff line change
@@ -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",
]
2 changes: 1 addition & 1 deletion cratedb_toolkit/io/processor/kinesis_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
# ]
# ///
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 10 additions & 0 deletions tests/io/test_iac.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ruff: noqa: F401


def test_iac_imports():
from cratedb_toolkit.iac.aws import (
DynamoDBKinesisPipe,
LambdaFactory,
LambdaPythonImage,
RDSPostgreSQLDMSKinesisPipe,
)
31 changes: 31 additions & 0 deletions tests/io/test_processor.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d71aa85

Please sign in to comment.