Skip to content

Commit

Permalink
Test cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Costanzo <[email protected]>
  • Loading branch information
ianco committed Dec 17, 2024
1 parent a2cedba commit 4d02556
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
5 changes: 0 additions & 5 deletions scenarios/examples/simple_restart/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ services:
- POSTGRES_PASSWORD=DB_PASSWORD
ports:
- 5433:5432
volumes:
- wallet-db-data:/var/lib/pgsql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U DB_USER"]
interval: 10s
Expand Down Expand Up @@ -124,6 +122,3 @@ services:
condition: service_healthy
bob:
condition: service_healthy

volumes:
wallet-db-data:
40 changes: 23 additions & 17 deletions scenarios/examples/simple_restart/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@
def healthy(container: Container) -> bool:
"""Check if container is healthy."""
inspect_results = container.attrs
print(">>> state:", inspect_results["State"])
return inspect_results["State"]["Running"] and inspect_results["State"]["Health"]["Status"] == "healthy"


def unhealthy(container: Container) -> bool:
"""Check if container is unhealthy."""
inspect_results = container.attrs
print(">>> state:", inspect_results["State"])
return not inspect_results["State"]["Running"]


Expand Down Expand Up @@ -133,21 +131,29 @@ async def main():
print(">>> new container:", 'alice', json.dumps(new_alice_container.attrs))
alice_id = new_alice_container.attrs['Id']

wait_until_healthy(client, alice_id)
print(">>> new alice container is healthy")

# run some more tests ... alice should still be connected to bob for example ...
async with Controller(base_url=ALICE) as alice, Controller(base_url=BOB) as bob:
# Present the the credential's attributes
print(">>> present proof ... again ...")
await indy_present_proof_v2(
bob,
alice,
bob_conn.connection_id,
alice_conn.connection_id,
requested_attributes=[{"name": "firstname"}],
)
print(">>> Done! (again)")
try:
wait_until_healthy(client, alice_id)
print(">>> new alice container is healthy")

# run some more tests ... alice should still be connected to bob for example ...
async with Controller(base_url=ALICE) as alice, Controller(base_url=BOB) as bob:
# Present the the credential's attributes
print(">>> present proof ... again ...")
await indy_present_proof_v2(
bob,
alice,
bob_conn.connection_id,
alice_conn.connection_id,
requested_attributes=[{"name": "firstname"}],
)
print(">>> Done! (again)")
finally:
# cleanup - shut down alice agent (not part of docker compose)
print(">>> shut down alice ...")
alice_container = client.containers.get(alice_id)
alice_container.stop()
wait_until_healthy(client, alice_id, is_healthy=False)
alice_container.remove()


if __name__ == "__main__":
Expand Down

0 comments on commit 4d02556

Please sign in to comment.