diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..cffcbfb --- /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/start.sh b/start.sh index b6bd6fd..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 @@ -269,10 +274,11 @@ 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 - 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 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" + diff --git a/test_endpoints.sh b/test_endpoints.sh new file mode 100755 index 0000000..a2ab50b --- /dev/null +++ b/test_endpoints.sh @@ -0,0 +1,25 @@ +#!/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 +} +sleep 10 + +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