-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,9 +12,20 @@ jobs: | |
steps: | ||
# need checkout before using docker-compose-action | ||
- uses: actions/checkout@v3 | ||
- uses: adambirds/[email protected] | ||
- name: Staring blood-info and scraper services | ||
uses: isbang/[email protected] | ||
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 | ||
run: sleep 10 && docker-compose run --rm test | ||
|
||
- name: Stop | ||
if: always() | ||
shell: bash | ||
run: docker-compose down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |