Skip to content

Commit

Permalink
Carabas: Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl authored and Andreas Motl committed Aug 16, 2024
1 parent 6d8cec1 commit fcee258
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
pip install "setuptools>=64" --upgrade
# Install package in editable mode.
pip install --use-pep517 --prefer-binary --editable=.[test,develop]
pip install --use-pep517 --prefer-binary --editable=.[all,test,develop]
- name: Run linter and software tests
run: |
Expand Down
17 changes: 12 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,15 @@ dynamic = [
"version",
]
dependencies = [
"async-kinesis<1.2",
"aws-lambda-layer<0.6",
"boltons",
"boto3<1.35",
"click<9",
"colorama<1",
"colorlog",
"commons-codec==0.0.3",
"cottonformation<1.2",
"dask",
"funcy",
"influxdb",
"influxdb-client[ciso]",
"localstack[runtime]<3.7",
"paho-mqtt",
"pandas<2.3",
"pika<1.4",
Expand All @@ -106,6 +101,17 @@ dependencies = [
"streamz",
"toolz",
]
optional-dependencies.all = [
"lorrystream[carabas]",
]
optional-dependencies.carabas = [
"aiobotocore==2.13.*", # for async-kinesis
"async-kinesis<1.2",
"aws-lambda-layer<0.6",
"boto3==1.34.*", # for async-kinesis
"cottonformation<1.2",
"localstack[base-runtime]<3.7",
]
optional-dependencies.develop = [
"black<25",
"mypy<1.12",
Expand Down Expand Up @@ -134,6 +140,7 @@ optional-dependencies.test = [
# https://github.com/docker/docker-py/issues/3256#issuecomment-2126888985
"cratedb-toolkit[testing]==0.0.15",
"docker<7",
"localstack-utils<1.1",
"pytest<9",
"pytest-asyncio-cooperative<0.30",
"pytest-cov<6",
Expand Down
2 changes: 1 addition & 1 deletion release/oci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ COPY . /src

# Install package.
RUN --mount=type=cache,id=pip,target=/root/.cache/pip \
pip install --use-pep517 --prefer-binary '/src'
pip install --use-pep517 --prefer-binary '/src[all]'

# Uninstall Git again.
RUN apt-get --yes remove --purge git && apt-get --yes autoremove
Expand Down
3 changes: 3 additions & 0 deletions tests/carabas/test_function.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from pathlib import Path

import pytest
from cottonformation.res import awslambda

from lorrystream.carabas.aws import LambdaFactory, LambdaPythonImage
from lorrystream.carabas.aws.model import GenericEnvStack


@pytest.mark.skip(reason="Needs adjustments for LocalStack-only operations")
def test_python_dockerfile():
python_image = LambdaPythonImage(
name="kinesis-cratedb-lambda",
Expand All @@ -17,6 +19,7 @@ def test_python_dockerfile():
assert "COPY kinesis_cratedb_lambda.py ${LAMBDA_TASK_ROOT}" in dockerfile


@pytest.mark.skip(reason="Needs adjustments for LocalStack-only operations")
def test_lambda_python():
python_image = LambdaPythonImage(
name="kinesis-cratedb-lambda",
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from lorrystream.util.common import setup_logging

from .fixtures.amqp import rabbitmq, rabbitmq_service # noqa: F401
from .fixtures.localstack import localstack, localstack_service # noqa: F401
from .fixtures.localstack import boto3_configure_localstack, boto3_session, localstack, localstack_service # noqa: F401


@pytest.fixture
Expand Down
21 changes: 16 additions & 5 deletions tests/fixtures/localstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,26 @@ def localstack_service():


@pytest.fixture(scope="function")
def localstack(localstack_service):
kinesis = boto3.client(
service_name="kinesis",
endpoint_url="http://localhost:4566",
)
def localstack(localstack_service, boto3_session):
kinesis = boto3_session.client("kinesis")
for stream_name in TEST_STREAMS:
try:
kinesis.delete_stream(StreamName=stream_name)
except botocore.exceptions.ClientError as error:
if error.response["Error"]["Code"] != "ResourceNotFoundException":
raise
time.sleep(0.5)


@pytest.fixture(scope="session", autouse=True)
def boto3_configure_localstack():
os.environ["AWS_ENDPOINT_URL"] = "http://localhost:4566"


@pytest.fixture(scope="session")
def boto3_session():
return boto3.Session(
region_name="us-east-1",
aws_access_key_id="foo",
aws_secret_access_key="bar", # noqa: S106
)
9 changes: 2 additions & 7 deletions tests/test_kinesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,11 @@
import logging
import time

import boto3

logger = logging.getLogger(__name__)


def test_kinesis_stream_operations(localstack):
kinesis = boto3.client(
service_name="kinesis",
endpoint_url="http://localhost:4566",
)
def test_kinesis_stream_operations(localstack, boto3_session):
kinesis = boto3_session.client("kinesis")

kinesis.create_stream(StreamName="test", ShardCount=1)
time.sleep(0.1)
Expand Down

0 comments on commit fcee258

Please sign in to comment.