Skip to content

Commit

Permalink
Update integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
masayag committed Oct 29, 2023
1 parent 19f5550 commit 2638a65
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
24 changes: 21 additions & 3 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,27 @@ jobs:
steps:
# need checkout before using docker-compose-action
- uses: actions/checkout@v3
- uses: adambirds/docker-compose-action@v1.3.0
- uses: isbang/compose-action@v1.5.1
with:
compose-file: "docker-compose.yml"
down-flags: "--volumes --remove-orphans --rmi local"
test-container: "blood-info"
test-command: "$(wget -q -O- --no-check-certificate https://localhost:8443/station | jq '. | length') -gt 0"
services: |
db
blood-info
scraper
- name: Run Tests
shell: bash
run: sleep 10 && docker-compose run --rm test

- uses: isbang/[email protected]
with:
compose-file: "docker-compose.yml"
down-flags: "--volumes --remove-orphans --rmi local"
services: |
test
- name: Stop
if: always()
shell: bash
run: docker-compose down
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ services:
environment:
- SCRAPER_INTERVAL=300

test:
build:
context: .
dockerfile: test/integration/Dockerfile.test

20 changes: 20 additions & 0 deletions test/integration/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

# Define variables
total_duration=30 # Total duration in seconds
interval=5 # Interval in seconds
end_time=$(($(date +%s) + total_duration))

# Run the test in a loop
while [ $(date +%s) -lt $end_time ]; do
result=$(wget -q -O- --no-check-certificate https://blood-info:8443/stations | jq '. | length')
if [ -n "$result" ] && [ "$result" -ne 0 ]; then
echo "Test passed: There are $result stations reported."
exit 0
fi

sleep $interval # Wait for the specified interval before the next test
done

echo "Test failed: Result is empty or zero."
exit 1 # Test failed

0 comments on commit 2638a65

Please sign in to comment.