mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
Tests deployment commands provided to users in README
This commit is contained in:
parent
7fd0f8e144
commit
c648a482d7
|
@ -1,14 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
service_count=`docker ps -a | grep "Up " | wc -l`
|
|
||||||
|
|
||||||
if [ "${service_count}" -eq "5" ]
|
|
||||||
then
|
|
||||||
echo "Service are up and running."
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
echo "Some services exited..."
|
|
||||||
docker ps -a
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
|
@ -2,53 +2,88 @@
|
||||||
|
|
||||||
DC_SCRIPT=./scripts/example/dc-example.sh
|
DC_SCRIPT=./scripts/example/dc-example.sh
|
||||||
|
|
||||||
run_services() {
|
start_services() {
|
||||||
$DC_SCRIPT up -d redis openldap
|
$DC_SCRIPT up -d redis openldap authelia nginx nginx-tests
|
||||||
sleep 2
|
|
||||||
$DC_SCRIPT up -d authelia nginx nginx-tests
|
|
||||||
sleep 3
|
sleep 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shut_services() {
|
||||||
|
$DC_SCRIPT down
|
||||||
|
}
|
||||||
|
|
||||||
|
expect_services_count() {
|
||||||
|
EXPECTED_COUNT=$1
|
||||||
|
service_count=`docker ps -a | grep "Up " | wc -l`
|
||||||
|
|
||||||
|
if [ "${service_count}" -eq "$EXPECTED_COUNT" ]
|
||||||
|
then
|
||||||
|
echo "Services are up and running."
|
||||||
|
else
|
||||||
|
echo "Some services exited..."
|
||||||
|
docker ps -a
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
run_integration_tests() {
|
||||||
|
echo "Prepare nginx-test configuration"
|
||||||
|
cat example/nginx/nginx.conf | sed 's/listen 443 ssl/listen 8080 ssl/g' | dd of="test/integration/nginx.conf"
|
||||||
|
|
||||||
|
echo "Build services images..."
|
||||||
|
$DC_SCRIPT build
|
||||||
|
|
||||||
|
echo "Start services..."
|
||||||
|
start_services
|
||||||
|
docker ps -a
|
||||||
|
|
||||||
|
echo "Display services logs..."
|
||||||
|
$DC_SCRIPT logs redis
|
||||||
|
$DC_SCRIPT logs openldap
|
||||||
|
$DC_SCRIPT logs nginx
|
||||||
|
$DC_SCRIPT logs nginx-tests
|
||||||
|
$DC_SCRIPT logs authelia
|
||||||
|
|
||||||
|
echo "Check number of services"
|
||||||
|
expect_services_count 5
|
||||||
|
|
||||||
|
echo "Run integration tests..."
|
||||||
|
$DC_SCRIPT run --rm integration-tests
|
||||||
|
|
||||||
|
echo "Shutdown services..."
|
||||||
|
shut_services
|
||||||
|
}
|
||||||
|
|
||||||
|
run_system_tests() {
|
||||||
|
echo "Start services..."
|
||||||
|
start_services
|
||||||
|
expect_services_count 5
|
||||||
|
|
||||||
|
./node_modules/.bin/mocha --compilers ts:ts-node/register --recursive test/system
|
||||||
|
shut_services
|
||||||
|
}
|
||||||
|
|
||||||
|
run_other_tests() {
|
||||||
|
echo "Test dev environment deployment (commands in README)"
|
||||||
|
npm install --only=dev
|
||||||
|
./node_modules/.bin/grunt build-dist
|
||||||
|
./scripts/example/deploy-example.sh
|
||||||
|
expect_services_count 4
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "Make sure services are not already running"
|
echo "Make sure services are not already running"
|
||||||
$DC_SCRIPT down
|
shut_services
|
||||||
|
|
||||||
|
|
||||||
# Prepare & run integration tests
|
# Prepare & run integration tests
|
||||||
|
run_integration_tests
|
||||||
echo "Prepare nginx-test configuration"
|
|
||||||
cat example/nginx/nginx.conf | sed 's/listen 443 ssl/listen 8080 ssl/g' | dd of="test/integration/nginx.conf"
|
|
||||||
|
|
||||||
echo "Build services images..."
|
|
||||||
$DC_SCRIPT build
|
|
||||||
|
|
||||||
echo "Start services..."
|
|
||||||
run_services
|
|
||||||
docker ps -a
|
|
||||||
|
|
||||||
echo "Display services logs..."
|
|
||||||
$DC_SCRIPT logs redis
|
|
||||||
$DC_SCRIPT logs openldap
|
|
||||||
$DC_SCRIPT logs nginx
|
|
||||||
$DC_SCRIPT logs nginx-tests
|
|
||||||
$DC_SCRIPT logs authelia
|
|
||||||
|
|
||||||
echo "Check number of services"
|
|
||||||
./scripts/example/check-services.sh
|
|
||||||
|
|
||||||
echo "Run integration tests..."
|
|
||||||
$DC_SCRIPT run --rm integration-tests
|
|
||||||
|
|
||||||
echo "Shutdown services..."
|
|
||||||
$DC_SCRIPT down
|
|
||||||
|
|
||||||
# Prepare & test example from end user perspective
|
# Prepare & test example from end user perspective
|
||||||
|
run_system_tests
|
||||||
|
|
||||||
echo "Start services..."
|
# Other tests like executing the deployment script
|
||||||
run_services
|
run_other_tests
|
||||||
|
|
||||||
./node_modules/.bin/mocha --compilers ts:ts-node/register --recursive test/system
|
|
||||||
|
|
||||||
$DC_SCRIPT down
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user