Skip to content

Commit

Permalink
Return redis_events tests (#48)
Browse files Browse the repository at this point in the history
* Return redis_events tests

Signed-off-by: jamshale <jamiehalebc@gmail.com>

* Don't run github workflows on PR edited

Signed-off-by: jamshale <jamiehalebc@gmail.com>

* Add extra $ to redis_events service commands

Signed-off-by: jamshale <jamiehalebc@gmail.com>

* Change integration test image names

Signed-off-by: jamshale <jamiehalebc@gmail.com>

* Update integration README

Signed-off-by: jamshale <jamiehalebc@gmail.com>

---------

Signed-off-by: jamshale <jamiehalebc@gmail.com>
  • Loading branch information
jamshale authored Dec 4, 2023
1 parent 220d71c commit dbf8042
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-integration-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Integration Tests
on:
pull_request:
types: [opened, edited, synchronize, reopened, ready_for_review]
types: [opened, synchronize, reopened, ready_for_review]
branches:
- "**"
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-linting-and-unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Linting and Unit Tests
on:
pull_request:
types: [opened, edited, synchronize, reopened, ready_for_review]
types: [opened, synchronize, reopened, ready_for_review]
branches:
- "**"
push:
Expand Down
4 changes: 2 additions & 2 deletions redis_events/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ services:
[
"/bin/sh",
"-c",
'/wait && python -m redis_events.v1_0.services.relay.relay "$@"',
'/wait && python -m redis_events.v1_0.services.relay.relay "$$@"',
"--",
]

Expand Down Expand Up @@ -153,7 +153,7 @@ services:
[
"/bin/sh",
"-c",
'/wait && python -m redis_events.v1_0.services.deliverer.deliver "$@"',
'/wait && python -m redis_events.v1_0.services.deliverer.deliver "$$@"',
"--",
]

Expand Down
2 changes: 1 addition & 1 deletion redis_events/docker/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ endpoint:

plugin:
- redis_events.v1_0.redis_queue.events
# - basicmessage_storage.v1_0
- basicmessage_storage.v1_0

plugin-config: plugins-config.yml

Expand Down
2 changes: 1 addition & 1 deletion redis_events/integration/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ WORKDIR /usr/src/app
COPY --from=base /usr/src/app/.venv /usr/src/app/.venv
ENV PATH="/usr/src/app/.venv/bin:$PATH"

# RUN pip install git+https://github.com/hyperledger/aries-acapy-plugins@main#subdirectory=basicmessage_storage
RUN pip install git+https://github.com/hyperledger/aries-acapy-plugins@main#subdirectory=basicmessage_storage

COPY redis_events/ redis_events/
COPY docker/*.yml ./
Expand Down
4 changes: 2 additions & 2 deletions redis_events/integration/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Integration Tests

All plugins should have a suite of integration tests. We use `docker compose` to set up the environment, and make use of the [Dockerfile](../docker/Dockerfile) to produce our ACA-Py/Plugin image. To simplify, we have another [Dockerfile](Dockerfile.test.runner) for running those [tests](/tests/).
We use `docker compose` to set up the environment, and make use of the main dockefile in the docker directory [Dockerfile](../docker/Dockerfile), and a similar dockerfile in integration driectory [Dockerfile](../integration/Dockerfile), which has an additional plugin basic_messages. This is used to persist message history for better testing. To simplify, we have another [Dockerfile](Dockerfile.test.runner) for running those [tests](/tests/).

## Build and run Tests

The integration tests will start 2 agents - bob and alice - and a juggernaut container that will execute the tests. Test results will be found in the juggernaut container output. The juggernaut container should close itself down, the logs can be reviewed in the `Docker` view, open `Containers`, open `integration`, right-click the `integration-tests` container and select `View Logs`
The integration tests will start 2 agents - faber and alice - and a juggernaut container that will execute the tests. Test results will be found in the juggernaut container output. The juggernaut container should close itself down, the logs can be reviewed in the `Docker` view, open `Containers`, open `integration`, right-click the `integration-tests` container and select `View Logs`

```sh
# open a terminal in vs code
Expand Down
8 changes: 4 additions & 4 deletions redis_events/integration/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ services:
[
"/bin/sh",
"-c",
'/wait && python -m redis_events.v1_0.services.relay.relay "$@"',
'/wait && python -m redis_events.v1_0.services.relay.relay "$$@"',
"--",
]

Expand Down Expand Up @@ -157,15 +157,15 @@ services:
[
"/bin/sh",
"-c",
'/wait && python -m redis_events.v1_0.services.deliverer.deliver "$@"',
'/wait && python -m redis_events.v1_0.services.deliverer.deliver "$$@"',
"--",
]
extra_hosts:
- "alice:host-gateway"
- "faber:host-gateway"

faber:
image: plugin-image
image: redis-events-integration
build:
context: ..
dockerfile: integration/Dockerfile
Expand All @@ -191,7 +191,7 @@ services:
- "alice:host-gateway"

alice:
image: plugin-image
image: redis-events
build:
context: ..
dockerfile: docker/Dockerfile
Expand Down
20 changes: 10 additions & 10 deletions redis_events/integration/tests/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ async def test_outbound_queue_removes_messages_from_queue_and_deliver_sends_them
retry_pop_count = retry_pop_count + 1
time.sleep(1)
msg_received = True
# messages = faber.retrieve_basicmessages()['results']
# assert "Hello Alice" in (msg['content'] for msg in messages)
# assert "Another Alice" in (msg['content'] for msg in messages)
messages = faber.retrieve_basicmessages()['results']
assert "Hello Alice" in (msg['content'] for msg in messages)
assert "Another Alice" in (msg['content'] for msg in messages)


@pytest.mark.asyncio
Expand All @@ -97,11 +97,11 @@ async def test_deliverer_pulls_messages_from_queue_and_sends_them(
)

time.sleep(5)
# messages = faber.retrieve_basicmessages()['results']
# matching_msgs = [
# msg for msg in messages if msg['content'] == "test-msg"]
# assert matching_msgs.__len__() == 2 # 1 for sent, 1 for received
# assert await redis.lrange("acapy_outbound", 0, -1) == []
messages = faber.retrieve_basicmessages()['results']
matching_msgs = [
msg for msg in messages if msg['content'] == "test-msg"]
assert matching_msgs.__len__() == 2 # 1 for sent, 1 for received
assert await redis.lrange("acapy_outbound", 0, -1) == []


@pytest.mark.asyncio
Expand Down Expand Up @@ -145,5 +145,5 @@ async def test_deliverer_retry_on_failure(
time.sleep(1)
msg_received = True

# assert "test-failed-msg" in (msg['content']
# for msg in faber.retrieve_basicmessages()['results'])
assert "test-failed-msg" in (msg['content']
for msg in faber.retrieve_basicmessages()['results'])

0 comments on commit dbf8042

Please sign in to comment.