Skip to content

Commit

Permalink
Fix integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: jamshale <jamiehalebc@gmail.com>
  • Loading branch information
jamshale committed Jan 8, 2024
1 parent 3fd7770 commit 6a2494a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
3 changes: 2 additions & 1 deletion kafka_events/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ USER root
RUN chown indy:indy -R .
USER indy

RUN poetry install --no-dev --extras aca-py
ARG install_flags='--with integration --extras aca-py'
RUN poetry install ${install_flags}

# Make site packages location more accessible (for use with volumes)
RUN ln -s $(poetry env info -p)/lib/python3.6/site-packages site-packages
Expand Down
36 changes: 18 additions & 18 deletions kafka_events/integration/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from aiokafka.consumer.consumer import AIOKafkaConsumer
from aiokafka.producer.producer import AIOKafkaProducer
import pytest
import pytest_asyncio

from acapy_client import Client
from acapy_client.api.connection import create_static, delete_connection, set_metadata
Expand All @@ -20,7 +20,7 @@
from echo_agent import EchoClient


@pytest.fixture(scope="session")
@pytest_asyncio.fixture(scope="session")
def event_loop():
"""Create a session scoped event loop.
pytest.asyncio plugin provides a default function scoped event loop
Expand All @@ -29,51 +29,51 @@ def event_loop():
return asyncio.get_event_loop()


@pytest.fixture(scope="session")
@pytest_asyncio.fixture(scope="session")
def host():
"""Hostname of agent under test."""
return getenv("AGENT_HOST", "localhost")


@pytest.fixture(scope="session")
@pytest_asyncio.fixture(scope="session")
def port():
"""Port of agent under test."""
return getenv("AGENT_PORT", 3000)


@pytest.fixture(scope="session")
@pytest_asyncio.fixture(scope="session")
def backchannel_port():
"""Port of agent under test backchannel."""
return getenv("AGENT_BACKCHANNEL_PORT", 3001)


@pytest.fixture(scope="session")
@pytest_asyncio.fixture(scope="session")
def echo_endpoint():
return getenv("ECHO_ENDPOINT", "http://localhost:4000")


@pytest.fixture(scope="session")
@pytest_asyncio.fixture(scope="session")
def backchannel(host, backchannel_port):
"""Yield backchannel client."""
yield Client(base_url="http://{}:{}".format(host, backchannel_port))


@pytest.fixture(scope="session")
@pytest_asyncio.fixture(scope="session")
def suite_seed():
yield hashlib.sha256(b"acapy-plugin-toolbox-int-test-runner").hexdigest()[:32]


@pytest.fixture(scope="session")
@pytest_asyncio.fixture(scope="session")
def agent_seed():
yield hashlib.sha256(b"acapy-plugin-toolbox-int-test-runner").hexdigest()[:32]


@pytest.fixture(scope="session")
@pytest_asyncio.fixture(scope="session")
def agent_endpoint(host, port):
yield "http://{}:{}".format(host, port)


@pytest.fixture(scope="session")
@pytest_asyncio.fixture(scope="session")
def agent_connection(
suite_seed, agent_seed, backchannel, echo_endpoint
) -> Iterator[ConnectionStaticResult]:
Expand Down Expand Up @@ -112,28 +112,28 @@ def agent_connection(
)


@pytest.fixture(scope="session")
@pytest_asyncio.fixture(scope="session")
def conn_record(agent_connection: ConnectionStaticResult):
yield agent_connection.record


@pytest.fixture(scope="session")
@pytest_asyncio.fixture(scope="session")
def connection_id(conn_record: ConnRecord):
yield conn_record.connection_id


@pytest.fixture(scope="session")
@pytest_asyncio.fixture(scope="session")
def echo_agent(echo_endpoint: str):
yield EchoClient(base_url=echo_endpoint)


@pytest.fixture
@pytest_asyncio.fixture
async def echo(echo_agent: EchoClient):
async with echo_agent as client:
yield client


@pytest.fixture(scope="session")
@pytest_asyncio.fixture(scope="session")
async def connection(
agent_connection: ConnectionStaticResult, echo_agent: EchoClient, suite_seed: str
):
Expand All @@ -148,15 +148,15 @@ async def connection(
yield conn


@pytest.fixture
@pytest_asyncio.fixture
def consumer():
def _consumer(topic: str):
return AIOKafkaConsumer(topic, bootstrap_servers="kafka", group_id="test")

yield _consumer


@pytest.fixture
@pytest_asyncio.fixture
async def producer():
producer = AIOKafkaProducer(bootstrap_servers="kafka")

Expand Down

0 comments on commit 6a2494a

Please sign in to comment.