Skip to content

Commit

Permalink
Initial version of a scenario test with restart
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Costanzo <ian@anon-solutions.ca>
  • Loading branch information
ianco committed Dec 12, 2024
1 parent c10bcc0 commit c66ab4a
Show file tree
Hide file tree
Showing 4 changed files with 1,011 additions and 575 deletions.
150 changes: 150 additions & 0 deletions scenarios/examples/simple_restart/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
services:
wallet-db:
image: postgres:12
environment:
- POSTGRES_USER=DB_USER
- POSTGRES_PASSWORD=DB_PASSWORD
ports:
- 5433:5432
volumes:
- wallet-db-data:/var/lib/pgsql/data

alice:
image: bcgovimages/aries-cloudagent:py3.12_1.0.1
ports:
- "3001:3001"
environment:
RUST_LOG: 'aries-askar::log::target=error'
command: >
start
--label Alice
--inbound-transport http 0.0.0.0 3000
--outbound-transport http
--endpoint http://alice:3000
--admin 0.0.0.0 3001
--admin-insecure-mode
--tails-server-base-url http://tails:6543
--genesis-url http://test.bcovrin.vonx.io/genesis
--wallet-type askar
--wallet-name alice
--wallet-key insecure
--wallet-storage-type "postgres_storage"
--wallet-storage-config "{\"url\":\"wallet-db:5432\",\"max_connections\":5}"
--wallet-storage-creds "{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"DB_USER\",\"admin_password\":\"DB_PASSWORD\"}"
--auto-provision
--log-level debug
--debug-webhooks
healthcheck:
test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null
start_period: 30s
interval: 7s
timeout: 5s
retries: 5
depends_on:
tails:
condition: service_started

alice-upgrade:
image: acapy-test
profiles: ["upgrade-test"]
ports:
- "3001:3001"
environment:
RUST_LOG: 'aries-askar::log::target=error'
command: >
start
--label Alice
--inbound-transport http 0.0.0.0 3000
--outbound-transport http
--endpoint http://alice:3000
--admin 0.0.0.0 3001
--admin-insecure-mode
--tails-server-base-url http://tails:6543
--genesis-url http://test.bcovrin.vonx.io/genesis
--wallet-type askar
--wallet-name alice
--wallet-key insecure
--wallet-storage-type "postgres_storage"
--wallet-storage-config "{\"url\":\"wallet-db:5432\",\"max_connections\":5}"
--wallet-storage-creds "{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"DB_USER\",\"admin_password\":\"DB_PASSWORD\"}"
--auto-provision
--log-level debug
--debug-webhooks
healthcheck:
test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null
start_period: 30s
interval: 7s
timeout: 5s
retries: 5
depends_on:
tails:
condition: service_started

bob:
image: acapy-test
ports:
- "3002:3001"
environment:
RUST_LOG: 'aries-askar::log::target=error'
command: >
start
--label Bob
--inbound-transport http 0.0.0.0 3000
--outbound-transport http
--endpoint http://bob:3000
--admin 0.0.0.0 3001
--admin-insecure-mode
--tails-server-base-url http://tails:6543
--genesis-url http://test.bcovrin.vonx.io/genesis
--wallet-type askar
--wallet-name bob
--wallet-key insecure
--wallet-storage-type "postgres_storage"
--wallet-storage-config "{\"url\":\"wallet-db:5432\",\"max_connections\":5}"
--wallet-storage-creds "{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"DB_USER\",\"admin_password\":\"DB_PASSWORD\"}"
--auto-provision
--log-level debug
--debug-webhooks
--monitor-revocation-notification
healthcheck:
test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null
start_period: 30s
interval: 7s
timeout: 5s
retries: 5

tails:
image: ghcr.io/bcgov/tails-server:latest
ports:
- 6543:6543
environment:
- GENESIS_URL=http://test.bcovrin.vonx.io/genesis
command: >
tails-server
--host 0.0.0.0
--port 6543
--storage-path /tmp/tails-files
--log-level INFO
example:
container_name: controller
privileged: true
build:
context: ../..
environment:
- DOCKER_HOST=unix:///var/run/docker.sock
- ALICE=http://alice:3001
- ALICE_UPGRADE=http://alice-upgrade:3001
- BOB=http://bob:3001
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./example.py:/usr/src/app/example.py:ro,z
command: python -m example
depends_on:
alice:
condition: service_healthy
bob:
condition: service_healthy

volumes:
wallet-db-data:
41 changes: 41 additions & 0 deletions scenarios/examples/simple_restart/example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""Minimal reproducible example script.
This script is for you to use to reproduce a bug or demonstrate a feature.
"""

import asyncio
from os import getenv

import docker

from acapy_controller import Controller
from acapy_controller.logging import logging_to_stdout
from acapy_controller.protocols import connection, didexchange

ALICE = getenv("ALICE", "http://alice:3001")
BOB = getenv("BOB", "http://bob:3001")


async def main():
"""Test Controller protocols."""
async with Controller(base_url=ALICE) as alice, Controller(base_url=BOB) as bob:
await connection(alice, bob)
await didexchange(alice, bob)

# play with docker
client = docker.from_env()
containers = client.containers.list(all=True)
docker_containers = {}
for container in containers:
container_name = container.attrs['Config']['Labels']['com.docker.compose.service']
container_id = container.attrs['Id']
container_is_running = container.attrs['State']['Running']
docker_containers[container_name] = {'Id': container_id, 'Running': container_is_running}
print(">>> container:", container_name, docker_containers[container_name])

# try to restart a container (stop alice and start alice-upgrade)


if __name__ == "__main__":
logging_to_stdout()
asyncio.run(main())
Loading

0 comments on commit c66ab4a

Please sign in to comment.