2017-07-14 17:05:42 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-07-16 12:55:01 +00:00
|
|
|
DC_SCRIPT=./scripts/example/dc-example.sh
|
2017-07-26 21:45:26 +00:00
|
|
|
EXPECTED_SERVICES_COUNT=5
|
2017-07-16 12:55:01 +00:00
|
|
|
|
2017-07-16 14:20:59 +00:00
|
|
|
start_services() {
|
2017-07-26 21:45:26 +00:00
|
|
|
$DC_SCRIPT up -d mongo redis openldap authelia nginx
|
2017-07-16 12:55:01 +00:00
|
|
|
sleep 3
|
|
|
|
}
|
|
|
|
|
2017-07-16 14:20:59 +00:00
|
|
|
shut_services() {
|
|
|
|
$DC_SCRIPT down
|
|
|
|
}
|
2017-07-16 12:55:01 +00:00
|
|
|
|
2017-07-16 14:20:59 +00: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-14 17:05:42 +00:00
|
|
|
|
2017-07-16 14:20:59 +00:00
|
|
|
run_integration_tests() {
|
|
|
|
echo "Start services..."
|
|
|
|
start_services
|
2017-07-19 19:06:12 +00:00
|
|
|
expect_services_count $EXPECTED_SERVICES_COUNT
|
2017-07-16 14:20:59 +00:00
|
|
|
|
2017-07-26 21:45:26 +00:00
|
|
|
sleep 5
|
|
|
|
./node_modules/.bin/grunt run:integration-tests
|
2017-07-16 14:20:59 +00:00
|
|
|
shut_services
|
|
|
|
}
|
2017-07-14 17:05:42 +00:00
|
|
|
|
2017-07-16 14:20:59 +00:00
|
|
|
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
|
2017-07-19 19:06:12 +00:00
|
|
|
expect_services_count 5
|
2017-07-16 14:20:59 +00:00
|
|
|
}
|
2017-07-14 17:05:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-07-16 12:55:01 +00:00
|
|
|
|
2017-07-16 14:20:59 +00:00
|
|
|
set -e
|
2017-07-16 12:55:01 +00:00
|
|
|
|
2017-07-16 14:20:59 +00:00
|
|
|
echo "Make sure services are not already running"
|
|
|
|
shut_services
|
2017-07-16 12:55:01 +00:00
|
|
|
|
2017-07-16 14:20:59 +00:00
|
|
|
# Prepare & test example from end user perspective
|
2017-07-26 21:45:26 +00:00
|
|
|
run_integration_tests
|
2017-07-16 12:55:01 +00:00
|
|
|
|
2017-07-16 14:20:59 +00:00
|
|
|
# Other tests like executing the deployment script
|
|
|
|
run_other_tests
|