Skip to content

Commit

Permalink
Merge pull request #131 from gisaia/feat/tests
Browse files Browse the repository at this point in the history
Feat/tests
  • Loading branch information
sylvaingaudan authored Feb 23, 2024
2 parents c7db093 + eeaef4f commit 0b4f87e
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 11 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 16 additions & 10 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

#!/bin/bash
set -o errexit -o pipefail

SCRIPT_DIRECTORY="$(cd "$(dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd)"

ready_message(){
Expand Down Expand Up @@ -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
Expand All @@ -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
6 changes: 5 additions & 1 deletion stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

25 changes: 25 additions & 0 deletions test_endpoints.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0b4f87e

Please sign in to comment.