From be2f61f1a2abecdccdcb7079e18ff53dd96d2a80 Mon Sep 17 00:00:00 2001 From: Sylvain Gaudan Date: Thu, 22 Feb 2024 15:54:11 +0100 Subject: [PATCH 1/6] initial endpoint tests --- .github/workflows/tests.yaml | 15 +++++++++++++++ test_endpoints.sh | 24 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 .github/workflows/tests.yaml create mode 100755 test_endpoints.sh diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..fa2b625 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,15 @@ +name: Test ARLAS Exploration stack + +on: push + +jobs: + endpoint-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Start stack + run: start.sh + - name: Run endpoints tests + run: test_endpoints.sh + - name: Stop stack + run: stop.sh diff --git a/test_endpoints.sh b/test_endpoints.sh new file mode 100755 index 0000000..aa1ca5f --- /dev/null +++ b/test_endpoints.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env sh + +test_status (){ + verb=$1 + endpoint=$2 + expected=$3 + computed=`curl -X ${verb} -k -s -o /dev/null -I -w "%{http_code}" "${endpoint}"` + + if [ "$computed" != "$expected" ]; then + echo $endpoint NOT ok : $computed " < > " $expected + exit 1 + else + echo $endpoint "ok: " $verb " is " $computed + fi +} + +test_status GET "http://localhost:81/hub/assets/hub-icon.png" 200 +test_status GET "http://localhost:81/permissions/authorize/resources" 200 +test_status GET "http://localhost:81/permissions/authorize/resources" 200 +test_status GET "http://localhost:81/persist/persist/resources/config.json?size=20&page=1&order=desc" 200 +test_status GET "http://localhost:81/server/collections/" 200 +test_status GET "http://localhost:81/wui/favicon.ico" 200 +test_status GET "http://localhost:81/builder/favicon.ico" 200 +test_status GET "http://localhost:9999" 000 From 13ce681edf62ec6677625d4f1b497bcee1a82a86 Mon Sep 17 00:00:00 2001 From: Sylvain Gaudan Date: Thu, 22 Feb 2024 15:55:23 +0100 Subject: [PATCH 2/6] local calls --- .github/workflows/tests.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index fa2b625..cffcbfb 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -8,8 +8,8 @@ jobs: steps: - uses: actions/checkout@v2 - name: Start stack - run: start.sh + run: ./start.sh - name: Run endpoints tests - run: test_endpoints.sh + run: ./test_endpoints.sh - name: Stop stack - run: stop.sh + run: ./stop.sh From 2a4cc027f39afc440de2dc8fe27907844067c123 Mon Sep 17 00:00:00 2001 From: Sylvain Gaudan Date: Thu, 22 Feb 2024 15:57:58 +0100 Subject: [PATCH 3/6] wait a bit for arlas --- test_endpoints.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test_endpoints.sh b/test_endpoints.sh index aa1ca5f..a2ab50b 100755 --- a/test_endpoints.sh +++ b/test_endpoints.sh @@ -13,6 +13,7 @@ test_status (){ echo $endpoint "ok: " $verb " is " $computed fi } +sleep 10 test_status GET "http://localhost:81/hub/assets/hub-icon.png" 200 test_status GET "http://localhost:81/permissions/authorize/resources" 200 From 39bae7cf2883ebe134b8df31eb1d72497b0132a3 Mon Sep 17 00:00:00 2001 From: Sylvain Gaudan Date: Fri, 23 Feb 2024 11:29:07 +0100 Subject: [PATCH 4/6] echo code --- start.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/start.sh b/start.sh index b6bd6fd..a848fe2 100755 --- a/start.sh +++ b/start.sh @@ -269,6 +269,7 @@ if [ "$ignore_es" = true ]; else code="$(curl -IL --silent $ES_NODE | grep "^HTTP\/")" fi + echo "ARLAS CODE: $code" eval "sleep 5" done #Restart ARLAS server when we are sure that ES is UP From 48c450b2e7cc0efcc21afa6f4496e66a94eda526 Mon Sep 17 00:00:00 2001 From: Sylvain Gaudan Date: Fri, 23 Feb 2024 15:10:03 +0100 Subject: [PATCH 5/6] not use include --- start.sh | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/start.sh b/start.sh index a848fe2..cd8f847 100755 --- a/start.sh +++ b/start.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -o errexit -o pipefail + SCRIPT_DIRECTORY="$(cd "$(dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd)" ready_message(){ @@ -223,36 +225,39 @@ if [ ! -z ${ARLAS_ELASTIC_INDEX+x} ]; fi echo "DOCKER COMPOSE SERVICES RUNNING : ${docker_compose_services_array[@]}" + +DOCKER_COMPOSE_FILES="-f $SCRIPT_DIRECTORY/docker-compose-arlas-builder.yaml -f $SCRIPT_DIRECTORY/docker-compose-arlas-hub.yaml -f $SCRIPT_DIRECTORY/docker-compose-arlas-permissions.yaml -f $SCRIPT_DIRECTORY/docker-compose-arlas-persistence.yaml -f $SCRIPT_DIRECTORY/docker-compose-arlas-server.yaml -f $SCRIPT_DIRECTORY/docker-compose-arlas-wui.yaml -f $SCRIPT_DIRECTORY/docker-compose-elasticsearch.yaml -f $SCRIPT_DIRECTORY/docker-compose-net.yaml -f $SCRIPT_DIRECTORY/docker-compose-nginx.yaml -f $SCRIPT_DIRECTORY/docker-compose-volumes.yaml" + #Run Docker-compose services -eval "docker-compose -p arlas_exploration_stack -f $SCRIPT_DIRECTORY/docker-compose-arlas-stack.yaml up -d ${docker_compose_services_array[@]}" +eval "docker-compose -p arlas_exploration_stack $DOCKER_COMPOSE_FILES up -d ${docker_compose_services_array[@]}" # Make a note of its Process ID (PID): #We need to stop useless local services started because of depends_on value in docker_compose.yaml if [ "$ignore_persistence" = true ]; then - eval "docker-compose -p arlas_exploration_stack -f $SCRIPT_DIRECTORY/docker-compose-arlas-stack.yaml stop arlas-persistence-server" - eval "docker-compose -p arlas_exploration_stack -f $SCRIPT_DIRECTORY/docker-compose-arlas-stack.yaml rm --force arlas-persistence-server" + eval "docker-compose -p arlas_exploration_stack $DOCKER_COMPOSE_FILES stop arlas-persistence-server" + eval "docker-compose -p arlas_exploration_stack $DOCKER_COMPOSE_FILES rm --force arlas-persistence-server" fi if [ "$ignore_permissions" = true ]; then - eval "docker-compose -p arlas_exploration_stack -f $SCRIPT_DIRECTORY/docker-compose-arlas-stack.yaml stop arlas-permissions-server" - eval "docker-compose -p arlas_exploration_stack -f $SCRIPT_DIRECTORY/docker-compose-arlas-stack.yaml rm --force arlas-permissions-server" + eval "docker-compose -p arlas_exploration_stack $DOCKER_COMPOSE_FILES stop arlas-permissions-server" + eval "docker-compose -p arlas_exploration_stack $DOCKER_COMPOSE_FILES rm --force arlas-permissions-server" fi if [ "$ignore_arlas" = true ]; then - eval "docker-compose -p arlas_exploration_stack -f $SCRIPT_DIRECTORY/docker-compose-arlas-stack.yaml stop arlas-server" - eval "docker-compose -p arlas_exploration_stack -f $SCRIPT_DIRECTORY/docker-compose-arlas-stack.yaml rm --force arlas-server" + eval "docker-compose -p arlas_exploration_stack $DOCKER_COMPOSE_FILES stop arlas-server" + eval "docker-compose -p arlas_exploration_stack $DOCKER_COMPOSE_FILES rm --force arlas-server" #No local service to waiting for ready_message exit 0 fi if [ "$ignore_es" = true ]; then - eval "docker-compose -p arlas_exploration_stack -f $SCRIPT_DIRECTORY/docker-compose-arlas-stack.yaml stop elasticsearch" - eval "docker-compose -p arlas_exploration_stack -f $SCRIPT_DIRECTORY/docker-compose-arlas-stack.yaml rm --force elasticsearch" + eval "docker-compose -p arlas_exploration_stack $DOCKER_COMPOSE_FILES stop elasticsearch" + eval "docker-compose -p arlas_exploration_stack $DOCKER_COMPOSE_FILES rm --force elasticsearch" ready_message exit 0 else @@ -273,7 +278,7 @@ if [ "$ignore_es" = true ]; eval "sleep 5" done #Restart ARLAS server when we are sure that ES is UP - eval "docker-compose -p arlas_exploration_stack -f $SCRIPT_DIRECTORY/docker-compose-arlas-stack.yaml restart arlas-server" + eval "docker-compose -p arlas_exploration_stack $DOCKER_COMPOSE_FILES restart arlas-server" ready_message fi From eeaef4f01c59bc9c4b4d298831e4022ce118a096 Mon Sep 17 00:00:00 2001 From: Sylvain Gaudan Date: Fri, 23 Feb 2024 15:14:44 +0100 Subject: [PATCH 6/6] not use include for stop --- stop.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stop.sh b/stop.sh index 1371397..2f1ac07 100755 --- a/stop.sh +++ b/stop.sh @@ -10,4 +10,8 @@ if [ -f "$envFile" ];then export $(eval "echo \"$(cat .env)\"" | xargs) fi -eval "docker-compose -p arlas_exploration_stack -f $SCRIPT_DIRECTORY/docker-compose-arlas-stack.yaml down" +DOCKER_COMPOSE_FILES="-f $SCRIPT_DIRECTORY/docker-compose-arlas-builder.yaml -f $SCRIPT_DIRECTORY/docker-compose-arlas-hub.yaml -f $SCRIPT_DIRECTORY/docker-compose-arlas-permissions.yaml -f $SCRIPT_DIRECTORY/docker-compose-arlas-persistence.yaml -f $SCRIPT_DIRECTORY/docker-compose-arlas-server.yaml -f $SCRIPT_DIRECTORY/docker-compose-arlas-wui.yaml -f $SCRIPT_DIRECTORY/docker-compose-elasticsearch.yaml -f $SCRIPT_DIRECTORY/docker-compose-net.yaml -f $SCRIPT_DIRECTORY/docker-compose-nginx.yaml -f $SCRIPT_DIRECTORY/docker-compose-volumes.yaml" + +#Run Docker-compose services +eval "docker-compose -p arlas_exploration_stack $DOCKER_COMPOSE_FILES down" +