Skip to content

Commit

Permalink
:
Browse files Browse the repository at this point in the history
  • Loading branch information
snamiki1212 committed Dec 29, 2023
1 parent 20a88b1 commit b1641ad
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ WORKDIR /app
COPY . .

# Define Healthcheck fot the container
HEALTHCHECK --interval=5s --timeout=5s --start-period=5s --retries=20 CMD [ "curl","http://0.0.0.0:8080/api/healthcheck" ]
# HEALTHCHECK --interval=5s --timeout=5s --start-period=5s --retries=20 CMD [ "curl","http://0.0.0.0:8080/api/healthcheck" ]

# Upgrade the system and install dependencies for PostgreSQL
RUN apt-get update && \
Expand Down
1 change: 1 addition & 0 deletions Dockerfile_tester
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ RUN apt-get update; \
apt-get install -y \
curl\
nodejs \
nodejs-current \
npm;

# Install newman
Expand Down
18 changes: 9 additions & 9 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ services:
container_name: app
build: .
command: 'bash -c "diesel setup && cargo watch --exec run"'
healthcheck:
test: ["CMD", "curl", "http://app:8080/api/healthcheck"]
interval: 5s
timeout: 5s
retries: 100
start_period: 30s
# healthcheck:
# test: ["CMD", "curl", "http://app:8080/api/healthcheck"]
# interval: 5s
# timeout: 5s
# retries: 100
# start_period: 30s
volumes:
- .:/app
depends_on:
Expand Down Expand Up @@ -43,9 +43,9 @@ services:
command: sh ./e2e/run-api-tests.sh
volumes:
- .:/app
depends_on:
app:
condition: service_healthy
# depends_on:
# app:
# condition: service_healthy
networks:
- network_for_test
profiles: ["test_e2e"]
Expand Down
3 changes: 3 additions & 0 deletions e2e/run-api-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ echo "PASSWORD=$PASSWORD"
# Ready for E2E
npm install -g newman

# healthcheck
sh ../x.sh

# Run E2E test
echo "running e2e..."
npx newman run ./e2e/Conduit.postman_collection.json \
Expand Down
25 changes: 25 additions & 0 deletions x.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
HOST="10.0.0.0:8080"
RETRY=10
SLEEP=1
CURL_TIMEOUT=3 #sec
# RESULT=`curl --max-time $CURL_TIMEOUT http://${HOST}/api/healthcheck`

for i in {1..10}; do
echo "-------------------"

# run curl
echo "running curl..."
RESULT=`curl --max-time $CURL_TIMEOUT http://${HOST}/api/healthcheck`

# check
if [ "$RESULT" == "OK" ]; then
echo "API is ready"
break
fi
echo "API is not ready, retrying..."

docker compose logs

# sleep
sleep $SLEEP
done

0 comments on commit b1641ad

Please sign in to comment.