From fff7e8e9fff3681cbdefeba9090b8560fec1196f Mon Sep 17 00:00:00 2001 From: snamiki1212 Date: Fri, 29 Dec 2023 09:55:20 +0900 Subject: [PATCH] : --- Dockerfile | 2 +- Dockerfile_tester | 2 +- compose.yaml | 18 +++++++++--------- e2e/run-api-tests.sh | 3 +++ x.sh | 25 +++++++++++++++++++++++++ 5 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 x.sh diff --git a/Dockerfile b/Dockerfile index 307054a..a2e38e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 && \ diff --git a/Dockerfile_tester b/Dockerfile_tester index 0ac1807..fe6f79d 100644 --- a/Dockerfile_tester +++ b/Dockerfile_tester @@ -8,7 +8,7 @@ COPY . . RUN apt-get update; \ apt-get install -y \ curl\ - nodejs \ + nodejs-current \ npm; # Install newman diff --git a/compose.yaml b/compose.yaml index 9730625..12394ee 100644 --- a/compose.yaml +++ b/compose.yaml @@ -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: @@ -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"] diff --git a/e2e/run-api-tests.sh b/e2e/run-api-tests.sh index 883be06..7963495 100644 --- a/e2e/run-api-tests.sh +++ b/e2e/run-api-tests.sh @@ -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 \ diff --git a/x.sh b/x.sh new file mode 100644 index 0000000..84f5119 --- /dev/null +++ b/x.sh @@ -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