2017-07-15 00:05:42 +07:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-08-08 21:03:12 +07:00
|
|
|
DC_SCRIPT=./scripts/example-commit/dc-example.sh
|
2017-09-24 19:49:03 +07:00
|
|
|
EXPECTED_SERVICES_COUNT=6
|
2017-07-16 19:55:01 +07:00
|
|
|
|
2017-10-07 05:09:42 +07:00
|
|
|
build_services() {
|
|
|
|
$DC_SCRIPT build authelia
|
|
|
|
}
|
|
|
|
|
2017-07-16 21:20:59 +07:00
|
|
|
start_services() {
|
2017-09-24 19:49:03 +07:00
|
|
|
$DC_SCRIPT up -d mongo redis openldap authelia nginx smtp
|
2017-07-16 19:55:01 +07:00
|
|
|
sleep 3
|
|
|
|
}
|
|
|
|
|
2017-07-16 21:20:59 +07:00
|
|
|
shut_services() {
|
2017-09-22 22:53:18 +07:00
|
|
|
$DC_SCRIPT down --remove-orphans
|
2017-07-16 21:20:59 +07:00
|
|
|
}
|
2017-07-16 19:55:01 +07:00
|
|
|
|
2017-07-16 21:20:59 +07:00
|
|
|
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
|
|
|
|
}
|
2017-07-15 00:05:42 +07:00
|
|
|
|
2017-07-16 21:20:59 +07:00
|
|
|
run_integration_tests() {
|
|
|
|
echo "Start services..."
|
|
|
|
start_services
|
2017-09-24 19:49:03 +07:00
|
|
|
expect_services_count $EXPECTED_SERVICES_COUNT
|
2017-07-16 21:20:59 +07:00
|
|
|
|
2017-07-27 04:45:26 +07:00
|
|
|
sleep 5
|
2017-10-07 05:09:42 +07:00
|
|
|
./node_modules/.bin/grunt run:test-int
|
2017-07-16 21:20:59 +07:00
|
|
|
shut_services
|
|
|
|
}
|
2017-07-15 00:05:42 +07:00
|
|
|
|
2017-07-16 21:20:59 +07:00
|
|
|
run_other_tests() {
|
|
|
|
echo "Test dev environment deployment (commands in README)"
|
|
|
|
npm install --only=dev
|
|
|
|
./node_modules/.bin/grunt build-dist
|
2017-08-08 21:03:12 +07:00
|
|
|
./scripts/example-commit/deploy-example.sh
|
2017-09-24 19:49:03 +07:00
|
|
|
expect_services_count $EXPECTED_SERVICES_COUNT
|
2017-08-08 21:03:12 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
run_other_tests_docker() {
|
|
|
|
echo "Test dev docker deployment (commands in README)"
|
|
|
|
./scripts/example-dockerhub/deploy-example.sh
|
2017-09-24 19:49:03 +07:00
|
|
|
expect_services_count $EXPECTED_SERVICES_COUNT
|
2017-07-16 21:20:59 +07:00
|
|
|
}
|
2017-07-15 00:05:42 +07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-07-16 19:55:01 +07:00
|
|
|
|
2017-07-16 21:20:59 +07:00
|
|
|
set -e
|
2017-07-16 19:55:01 +07:00
|
|
|
|
2017-07-16 21:20:59 +07:00
|
|
|
echo "Make sure services are not already running"
|
|
|
|
shut_services
|
2017-07-16 19:55:01 +07:00
|
|
|
|
2017-10-07 05:09:42 +07:00
|
|
|
# Build the container
|
|
|
|
build_services
|
|
|
|
|
2017-07-16 21:20:59 +07:00
|
|
|
# Prepare & test example from end user perspective
|
2017-07-27 04:45:26 +07:00
|
|
|
run_integration_tests
|
2017-07-16 19:55:01 +07:00
|
|
|
|
2017-07-16 21:20:59 +07:00
|
|
|
# Other tests like executing the deployment script
|
|
|
|
run_other_tests
|
2017-08-08 21:03:12 +07:00
|
|
|
|
|
|
|
# Test example with precompiled container
|
2017-09-22 22:53:18 +07:00
|
|
|
run_other_tests_docker
|