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

Commit 49d212c

Browse files
committed
Issue #1206: Add composer run-tests command for running tests in a Docker container.
1 parent c8bbc36 commit 49d212c

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,21 @@ Drupal VM runs on almost any modern computer that can run VirtualBox and Vagrant
154154
- Find out more about local development with Vagrant + VirtualBox + Ansible in this presentation: [Local Development Environments - Vagrant, VirtualBox and Ansible](http://www.slideshare.net/geerlingguy/local-development-on-virtual-machines-vagrant-virtualbox-and-ansible).
155155
- Learn about how Ansible can accelerate your ability to innovate and manage your infrastructure by reading [Ansible for DevOps](http://www.ansiblefordevops.com/).
156156

157+
## Tests
158+
159+
To run basic integration tests using Docker:
160+
161+
1. [Install Docker](https://docs.docker.com/engine/installation/).
162+
2. In this project directory, run: `composer run-tests`
163+
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).
165+
166+
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.
167+
157168
## License
158169

159170
This project is licensed under the MIT open source license.
160171

161172
## About the Author
162173

163-
[Jeff Geerling](http://www.jeffgeerling.com/) created Drupal VM in 2014 for a more efficient Drupal site and core/contrib development workflow. This project is featured as an example in [Ansible for DevOps](http://www.ansiblefordevops.com/).
174+
[Jeff Geerling](https://www.jeffgeerling.com/) created Drupal VM in 2014 for a more efficient Drupal site and core/contrib development workflow. This project is featured as an example in [Ansible for DevOps](https://www.ansiblefordevops.com/).

composer.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,11 @@
2020
"source": "https://github.com/geerlingguy/drupal-vm",
2121
"docs": "http://docs.drupalvm.com"
2222
},
23-
"require": {}
23+
"require": {},
24+
"config": {
25+
"process-timeout": 1800
26+
},
27+
"scripts": {
28+
"run-tests": "./tests/run-tests.sh"
29+
}
2430
}

tests/run-tests.sh

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
# Set volume options.
4+
if [[ "$OSTYPE" == "darwin"* ]]; then
5+
volume_opts='rw,cached'
6+
else
7+
volume_opts='rw'
8+
fi
9+
10+
# Remove test container if it already exists.
11+
docker ps -aq --filter name=dvm-test | xargs docker rm -f -v
12+
13+
# Run the container.
14+
docker run --name=dvm-test -d \
15+
--add-host "$HOSTNAME drupalvm":127.0.0.1 \
16+
-v $PWD:/var/www/drupalvm/:$volume_opts \
17+
-p 8888:80 \
18+
--privileged \
19+
geerlingguy/docker-ubuntu1604-ansible:latest \
20+
/lib/systemd/systemd
21+
22+
# Create Drupal directory.
23+
docker exec dvm-test mkdir -p /var/www/drupalvm/drupal
24+
25+
# Check playbook syntax.
26+
docker exec --tty dvm-test env TERM=xterm ansible-playbook /var/www/drupalvm/provisioning/playbook.yml --syntax-check
27+
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
31+
32+
# Check if Drupal was installed successfully.
33+
docker exec dvm-test curl -s --header Host:$HOSTNAME localhost \
34+
| grep -q '<title>Welcome to Drupal' \
35+
&& (echo 'Drupal install pass' && exit 0) \
36+
|| (echo 'Drupal install fail' && exit 1)
37+
38+
# Remove test container.
39+
docker rm -f dvm-test

0 commit comments

Comments
 (0)