Skip to content
This repository was archived by the owner on Feb 13, 2023. It is now read-only.

Commit 47f103c

Browse files
committed
Issue #1206: Is it possible this will work? Everything is composer run-tests
1 parent df90d4d commit 47f103c

File tree

3 files changed

+183
-62
lines changed

3 files changed

+183
-62
lines changed

.travis.yml

+36-45
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
2+
language: php
3+
php: '7.1'
24
services: docker
35

46
env:
@@ -12,64 +14,53 @@ env:
1214
DRUPALVM_DIR: /var/www/drupalvm
1315
DRUSH_BIN: drush
1416
TEST_INSTALLED_EXTRAS: true
17+
CONTAINER_ID: dvm-test
1518

1619
matrix:
1720
# Defaults - Ubuntu 16.04.
1821
- type: defaults
1922
distro: ubuntu1604
20-
init: /sbin/init
21-
run_opts: "--privileged"
22-
# # Defaults - Ubuntu 14.04.
23-
# - type: defaults
24-
# distro: ubuntu1404
25-
# init: /sbin/init
26-
# run_opts: "--privileged"
27-
# # PHP 5.6 - Ubuntu 16.04.
28-
# - type: defaults
29-
# distro: ubuntu1604
30-
# init: /sbin/init
31-
# run_opts: "--privileged"
32-
# local_config: tests/ubuntu-16-php56.config.yml
33-
# DRUSH_BIN: "${DRUPALVM_DIR}/drupal/vendor/drush/drush/drush"
34-
# TEST_INSTALLED_EXTRAS: false
35-
# # Nginx and Drush make file test - Ubuntu 16.04.
36-
# - type: nginx-drush-make
37-
# distro: ubuntu1604
38-
# init: /sbin/init
39-
# run_opts: "--privileged"
40-
# local_config: tests/ubuntu-16-nginx.config.yml
41-
# config_dir: /var/www/drupalvm/config
42-
# # PostgreSQL - Ubuntu 16.04.
43-
# - type: postgresql
44-
# distro: ubuntu1604
45-
# init: /sbin/init
46-
# run_opts: "--privileged"
47-
# local_config: tests/ubuntu-16-postgresql.config.yml
48-
# config_dir: /var/www/drupalvm/config
49-
# DRUSH_BIN: "${DRUPALVM_DIR}/drupal/vendor/drush/drush/drush"
50-
# TEST_INSTALLED_EXTRAS: false
51-
# # Defaults - CentOS 7.
52-
# - type: centos
53-
# distro: centos7
54-
# init: /usr/lib/systemd/systemd
55-
# run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
56-
# # Defaults - Debian 8.
57-
# - type: debian
58-
# distro: debian8
59-
# init: /lib/systemd/systemd
60-
# run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
23+
# Defaults - Ubuntu 14.04.
24+
- type: defaults
25+
distro: ubuntu1404
26+
# Defaults - CentOS 7.
27+
- type: centos
28+
distro: centos7
29+
# Defaults - Debian 8.
30+
- type: debian
31+
distro: debian8
32+
33+
# PHP 5.6 - Ubuntu 16.04.
34+
- type: defaults
35+
distro: ubuntu1604
36+
local_config: tests/ubuntu-16-php56.config.yml
37+
DRUSH_BIN: "${DRUPALVM_DIR}/drupal/vendor/drush/drush/drush"
38+
TEST_INSTALLED_EXTRAS: false
39+
40+
# Nginx and Drush make file test - Ubuntu 16.04.
41+
- type: nginx-drush-make
42+
distro: ubuntu1604
43+
local_config: tests/ubuntu-16-nginx.config.yml
44+
config_dir: /var/www/drupalvm/config
45+
46+
# PostgreSQL - Ubuntu 16.04.
47+
- type: postgresql
48+
distro: ubuntu1604
49+
local_config: tests/ubuntu-16-postgresql.config.yml
50+
config_dir: /var/www/drupalvm/config
51+
DRUSH_BIN: "${DRUPALVM_DIR}/drupal/vendor/drush/drush/drush"
52+
TEST_INSTALLED_EXTRAS: false
6153

6254
before_install:
6355
# Pull container.
64-
- 'docker pull geerlingguy/docker-${distro}-ansible:latest'
56+
- docker pull geerlingguy/docker-${distro}-ansible:latest
6557

6658
# Install lint tools.
67-
- 'gem install rubocop'
59+
- gem install rubocop
6860

6961
script:
7062
# Vagrantfile syntax check.
7163
- 'rubocop ./Vagrantfile ./lib/drupalvm --except LineLength,Eval,MutableConstant,BlockLength,ConditionalAssignment,IndentArray,AlignParameters'
7264

73-
# Try something quite radical.
65+
# Run tests.
7466
- composer run-tests
75-

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ To run basic integration tests using Docker:
161161
1. [Install Docker](https://docs.docker.com/engine/installation/).
162162
2. In this project directory, run: `composer run-tests`
163163

164-
> Note: If you're on a Mac, and want to use Docker's `cached` volume option (or `delegated`, once it's available) for faster local filesystem access, you need to install [Docker's Edge release](https://docs.docker.com/docker-for-mac/install/#download-docker-for-mac).
164+
> Note: If you're on a Mac, you need to use [Docker's Edge release](https://docs.docker.com/docker-for-mac/install/#download-docker-for-mac), at least until [this issue](https://github.com/docker/for-mac/issues/77) is resolved.
165165
166166
The project's automated tests are run via Travis CI, and the more comprehensive test suite covers multiple Linux distributions and many different Drupal VM use cases and deployment techniques.
167167

tests/run-tests.sh

+146-16
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,169 @@
11
#!/bin/bash
2+
#
3+
# A script to run Drupal VM functional tests.
24

3-
# Set volume options.
5+
# Set defaults if they're not set upstream.
6+
CONFIG="${CONFIG:-tests/config.yml}"
7+
MAKEFILE="${MAKEFILE:-example.drupal.make.yml}"
8+
COMPOSERFILE="${COMPOSERFILE:-example.drupal.composer.json}"
9+
HOSTNAME="${HOSTNAME:-drupalvm.dev}"
10+
MACHINE_NAME="${MACHINE_NAME:-drupalvm}"
11+
IP="${IP:-192.168.88.88}"
12+
DRUPALVM_DIR="${DRUPALVM_DIR:-/var/www/drupalvm}"
13+
DRUSH_BIN="${DRUSH_BIN:-drush}"
14+
TEST_INSTALLED_EXTRAS="${TEST_INSTALLED_EXTRAS:-true}"
15+
CONTAINER_ID="${CONTAINER_ID:-dvm-test}"
16+
type="${type:-tests/defaults}"
17+
distro="${distro:-ubuntu1604}"
18+
19+
## Set up vars for Docker setup.
20+
# CentOS 7
21+
if [ $distro = 'centos7' ]; then
22+
init="/usr/lib/systemd/systemd"
23+
opts="--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
24+
# CentOS 6
25+
elif [ $distro = 'centos6' ]; then
26+
init="/sbin/init"
27+
opts="--privileged"
28+
# Ubuntu 16.04
29+
elif [ $distro = 'ubuntu1604' ]; then
30+
init="/lib/systemd/systemd"
31+
opts="--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
32+
# Ubuntu 14.04
33+
elif [ $distro = 'ubuntu1404' ]; then
34+
init="/sbin/init"
35+
opts="--privileged"
36+
# Ubuntu 12.04
37+
elif [ $distro = 'ubuntu1204' ]; then
38+
init="/sbin/init"
39+
opts="--privileged"
40+
# Debian 8
41+
elif [ $distro = 'debian8' ]; then
42+
init="/lib/systemd/systemd"
43+
opts="--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
44+
# Fedora 24
45+
elif [ $distro = 'fedora24' ]; then
46+
init="/usr/lib/systemd/systemd"
47+
opts="--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
48+
fi
49+
50+
# Set OS-specific options.
451
if [[ "$OSTYPE" == "darwin"* ]]; then
552
volume_opts='rw,cached'
53+
xargs_command='xargs'
654
else
755
volume_opts='rw'
56+
xargs_command='xargs -r'
857
fi
958

59+
# Exit on any individual command failure.
60+
set -e
61+
62+
# Pretty colors.
63+
red='\033[0;31m'
64+
green='\033[0;32m'
65+
neutral='\033[0m'
66+
1067
# Remove test container if it already exists.
11-
docker ps -aq --filter name=dvm-test | xargs docker rm -f -v
68+
printf "\n"${green}"Removing any existing test containers..."${neutral}"\n"
69+
docker ps -aq --filter name=$CONTAINER_ID | $xargs_command docker rm -f -v
70+
printf ${green}"...done!"${neutral}"\n"
1271

1372
# Run the container.
14-
docker run --name=dvm-test -d \
73+
printf "\n"${green}"Starting Docker container: geerlingguy/docker-$distro-ansible."${neutral}"\n"
74+
docker run --name=$CONTAINER_ID -d \
1575
--add-host "$HOSTNAME drupalvm":127.0.0.1 \
1676
-v $PWD:/var/www/drupalvm/:$volume_opts \
17-
-p 8888:80 \
18-
--privileged \
19-
geerlingguy/docker-ubuntu1604-ansible:latest \
20-
/lib/systemd/systemd
77+
$opts \
78+
geerlingguy/docker-$distro-ansible:latest \
79+
$init
2180

22-
# Create Drupal directory.
23-
docker exec dvm-test mkdir -p /var/www/drupalvm/drupal
81+
# Set up directories.
82+
docker exec $CONTAINER_ID mkdir -p /var/www/drupalvm/drupal
83+
[[ ! -z "$config_dir" ]] && docker exec $CONTAINER_ID mkdir -p $config_dir || true
84+
85+
# Copy configuration into place.
86+
docker exec $CONTAINER_ID cp $DRUPALVM_DIR/$CONFIG ${config_dir:-$DRUPALVM_DIR}/config.yml
87+
docker exec $CONTAINER_ID cp $DRUPALVM_DIR/$MAKEFILE ${config_dir:-$DRUPALVM_DIR}/drupal.make.yml
88+
docker exec $CONTAINER_ID cp $DRUPALVM_DIR/$COMPOSERFILE ${config_dir:-$DRUPALVM_DIR}/drupal.composer.json
89+
[[ ! -z "$DRUPALVM_ENV" ]] && docker exec $CONTAINER_ID bash -c "cp $DRUPALVM_DIR/tests/$DRUPALVM_ENV.config.yml ${config_dir:-$DRUPALVM_DIR}/$DRUPALVM_ENV.config.yml" || true
90+
91+
# Override configuration variables with local config.
92+
[[ ! -z "$local_config" ]] && docker exec $CONTAINER_ID bash -c "cp $DRUPALVM_DIR/$local_config ${config_dir:-$DRUPALVM_DIR}/local.config.yml" || true
2493

2594
# Check playbook syntax.
26-
docker exec --tty dvm-test env TERM=xterm ansible-playbook /var/www/drupalvm/provisioning/playbook.yml --syntax-check
95+
printf "\n"${green}"Checking playbook syntax..."${neutral}"\n"
96+
docker exec --tty $CONTAINER_ID env TERM=xterm ansible-playbook $DRUPALVM_DIR/provisioning/playbook.yml --syntax-check
97+
98+
# Run the setup playbook.
99+
printf "\n"${green}"Running the setup playbook..."${neutral}"\n"
100+
docker exec --tty $CONTAINER_ID env TERM=xterm ansible-playbook /var/www/drupalvm/tests/test-setup.yml
27101

28-
# Set things up and run the Ansible playbook.
29-
docker exec --tty dvm-test env TERM=xterm ansible-playbook /var/www/drupalvm/tests/test-setup.yml
30-
docker exec dvm-test env TERM=xterm ANSIBLE_FORCE_COLOR=true COMPOSER_PROCESS_TIMEOUT=1800 ansible-playbook /var/www/drupalvm/provisioning/playbook.yml
102+
# Run the Drupal VM playbook.
103+
printf "\n"${green}"Running the Drupal VM playbook..."${neutral}"\n"
104+
if [ ! -z "${config_dir}" ]; then
105+
# Run with config_dir specified.
106+
docker exec $CONTAINER_ID env TERM=xterm ANSIBLE_FORCE_COLOR=true DRUPALVM_ENV=$DRUPALVM_ENV \
107+
ansible-playbook $DRUPALVM_DIR/provisioning/playbook.yml \
108+
--extra-vars="config_dir=$config_dir";
109+
else
110+
# Run without config_dir specified.
111+
docker exec $CONTAINER_ID env TERM=xterm ANSIBLE_FORCE_COLOR=true DRUPALVM_ENV=$DRUPALVM_ENV \
112+
ansible-playbook $DRUPALVM_DIR/provisioning/playbook.yml;
113+
fi
31114

32-
# Check if Drupal was installed successfully.
33-
docker exec dvm-test curl -s --header Host:$HOSTNAME localhost \
115+
# Drupal.
116+
printf "\n"${green}"Running functional tests..."${neutral}"\n"
117+
docker exec $CONTAINER_ID curl -s --header Host:$HOSTNAME localhost \
34118
| grep -q '<title>Welcome to Drupal' \
35119
&& (echo 'Drupal install pass' && exit 0) \
36120
|| (echo 'Drupal install fail' && exit 1)
37121

122+
# Adminer.
123+
if [ $TEST_INSTALLED_EXTRAS = true ]; then
124+
docker exec $CONTAINER_ID curl -s --header Host:adminer.$HOSTNAME localhost \
125+
| grep -q '<title>Login - Adminer' \
126+
&& (echo 'Adminer install pass' && exit 0) \
127+
|| (echo 'Adminer install fail' && exit 1)
128+
fi
129+
130+
# Pimp My Log.
131+
if [ $TEST_INSTALLED_EXTRAS = true ]; then
132+
docker exec $CONTAINER_ID curl -s --header Host:pimpmylog.$HOSTNAME localhost \
133+
| grep -q '<title>Pimp my Log' \
134+
&& (echo 'Pimp my Log install pass' && exit 0) \
135+
|| (echo 'Pimp my Log install fail' && exit 1)
136+
fi
137+
138+
# MailHog.
139+
if [ $TEST_INSTALLED_EXTRAS = true ]; then
140+
docker exec $CONTAINER_ID curl -s localhost:8025 \
141+
| grep -q '<title>MailHog' \
142+
&& (echo 'MailHog install pass' && exit 0) \
143+
|| (echo 'MailHog install fail' && exit 1)
144+
fi
145+
146+
# Varnish.
147+
if [ $TEST_INSTALLED_EXTRAS = true ]; then
148+
docker exec $CONTAINER_ID curl -sI --header Host:$HOSTNAME localhost:81 \
149+
| grep -q 'Via: .* varnish' \
150+
&& (echo 'Varnish install pass' && exit 0) \
151+
|| (echo 'Varnish install fail' && exit 1)
152+
fi
153+
154+
# Dashboard.
155+
docker exec $CONTAINER_ID curl -s --header Host:$IP localhost
156+
| grep -q "<li>$IP $HOSTNAME</li>"
157+
&& (echo 'Dashboard install pass' && exit 0)
158+
|| (echo 'Dashboard install fail' && exit 1)
159+
160+
# Drush.
161+
docker exec $CONTAINER_ID $DRUSH_BIN @$MACHINE_NAME.$HOSTNAME status
162+
| grep -q 'Drupal bootstrap.*Successful'
163+
&& (echo 'Drush install pass' && exit 0)
164+
|| (echo 'Drush install fail' && exit 1)
165+
38166
# Remove test container.
39-
docker rm -f dvm-test
167+
printf "\n"${green}"Cleaning up..."${neutral}"\n"
168+
docker rm -f $CONTAINER_ID
169+
printf ${green}"...done!"${neutral}"\n\n"

0 commit comments

Comments
 (0)