Skip to content

Commit 18c2ce3

Browse files
authored
Merge pull request #15 from devops-coop/feature-vagrant
Add Vagrant testing environment
2 parents f5fb49a + 37dba3b commit 18c2ce3

File tree

3 files changed

+70
-2
lines changed

3 files changed

+70
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
*~
2+
3+
#Vagrant Files
4+
.vagrant/*

README.rst

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,35 @@ If you'd like to help with the project itself, here are some other ways you can
205205

206206
Testing
207207
~~~~~~~
208+
Testing can be done using the provided Vagrantfile or by installing `Docker <https://docs.docker.com/engine/installation/>`__ and `Docker Compose <https://docs.docker.com/compose/>`__ locally.
208209

209-
This role includes a Docker-based test harness for integration testing.
210+
Testing with Vagrant
211+
"""""""""""""""""""""
212+
This role includes a Vagrantfile used with a Docker-based test harness that approximates the Travis CI setup for integration testing. Using Vagrant allows all contributors to test on the same platform and avoid false test failures due to untested or incompatible docker versions.
213+
214+
1. Install `Vagrant <https://www.vagrantup.com/>`__ and `VirtualBox <https://www.virtualbox.org/>`__.
215+
216+
2. Run ``vagrant up`` from the same directory as the Vagrantfile in this repository.
217+
218+
3. SSH into the VM with: ``vagrant ssh``
219+
220+
4. Run tests with ``make``.
221+
222+
::
223+
224+
make -C /vagrant xenial64 test
225+
226+
Integration tests use **systemd** by default. Set ``PROCESS_CONTROL`` to change this:
227+
228+
::
229+
230+
make -C /vagrant trusty64 test PROCESS_CONTROL=supervisor
231+
232+
See ``make help`` for more information including a full list of available targets.
233+
234+
Testing with Docker and Docker Compose locally
235+
""""""""""""""""""""""""""""""""""""""""""""""""
236+
Alternatively, you can install `Docker <https://docs.docker.com/engine/installation/>`__ and `Docker Compose <https://docs.docker.com/compose/>`__ to run these tests locally on your machine.
210237

211238
1. Install `Docker <https://docs.docker.com/engine/installation/>`__ and `Docker Compose <https://docs.docker.com/compose/>`__.
212239

@@ -222,7 +249,7 @@ Integration tests use **systemd** by default. Set ``PROCESS_CONTROL`` to change
222249

223250
make trusty64 test PROCESS_CONTROL=supervisor
224251

225-
See ``make help`` for more information.
252+
See ``make help`` for more information including a full list of available targets.
226253

227254
License
228255
-------

Vagrantfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Defines our Vagrant environment
2+
#
3+
# -*- mode: ruby -*-
4+
# vi: set ft=ruby :
5+
6+
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
7+
VAGRANTFILE_API_VERSION = "2"
8+
9+
$setupScript = <<SCRIPT
10+
echo provisioning docker...
11+
sudo apt-get update
12+
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
13+
sudo apt-add-repository 'deb https://apt.dockerproject.org/repo ubuntu-trusty main'
14+
sudo apt-get update
15+
sudo apt-get -o Dpkg::Options::="--force-confnew" install --force-yes -y docker-engine=1.10.2-0~trusty
16+
sudo usermod -a -G docker vagrant
17+
sudo apt-get install python3-pip -y && sudo pip3 install --upgrade pip
18+
sudo pip install docker-compose==1.6.2
19+
20+
docker version
21+
22+
docker-compose version
23+
SCRIPT
24+
25+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
26+
config.vm.box = "bento/ubuntu-14.04"
27+
config.vm.define "server" do |host|
28+
host.vm.hostname = "server"
29+
host.vm.provider "virtualbox" do |vb|
30+
vb.memory = "1024"
31+
vb.cpus = "1"
32+
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
33+
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
34+
vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
35+
end
36+
host.vm.provision :shell, :inline => $setupScript
37+
end
38+
end

0 commit comments

Comments
 (0)