Skip to content

Commit

Permalink
test: test
Browse files Browse the repository at this point in the history
Signed-off-by: Tiago Castro <[email protected]>
  • Loading branch information
tiagolobocastro committed Jan 1, 2025
1 parent 05b09f4 commit 2ea0d97
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/bdd.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: BDD CI
on:
workflow_call:
push:
branches:
- ci

env:
CARGO_TERM_COLOR: always
Expand Down Expand Up @@ -33,7 +36,14 @@ jobs:
- name: Run BDD Tests
run: |
nix-shell --run "deployer start --image-pull-policy always -w 60s && deployer stop"
nix-shell --run "./scripts/python/test.sh"
while [ $? -eq 0 ]; do
nix-shell --run "./scripts/python/test.sh"
done
- uses: actions/upload-artifact@v4
if: failure()
with:
name: bdd-failure
path: logs.txt
- name: Cleanup
if: always()
run: nix-shell --run "./scripts/python/test-residue-cleanup.sh"
Expand All @@ -47,7 +57,7 @@ jobs:
fail-on-empty: true
title: Test results
# debugging
# - name: Setup tmate session
# if: ${{ failure() }}
# timeout-minutes: 120
# uses: mxschmitt/action-tmate@v3
- name: Setup tmate session
if: ${{ failure() }}
timeout-minutes: 1024
uses: mxschmitt/action-tmate@v3
1 change: 1 addition & 0 deletions tests/bdd/common/deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def start_with_opts(options: StartOptions):
@staticmethod
def stop(disconnect_nvme=False):
print(f"DeployerStop: {datetime.now()}")
Docker.log_containers()
clean = os.getenv("CLEAN")
if clean is not None and clean.lower() in ("no", "false", "f", "0"):
return
Expand Down
16 changes: 16 additions & 0 deletions tests/bdd/common/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,19 @@ def restart_container(name):
docker_client = docker.from_env()
container = docker_client.containers.get(name)
container.restart()

@staticmethod
def log_containers():
docker_client = docker.from_env()
logs = os.environ["ROOT_DIR"] + "/logs.txt"
with open(logs, 'w') as log_file:
# Iterate over all running containers
for container in client.containers.list():
# Write the container's name or ID
log_file.write(f'Logs for container {container.name}:\n')
log_file.write('-' * 40 + '\n')
# Get the container logs
logs = container.logs().decode('utf-8')
# Write the logs to the file
log_file.write(logs)
log_file.write('\n\n')

0 comments on commit 2ea0d97

Please sign in to comment.