Adding Vagrantfile for local testing

Running `vagrant up` will emulate the gate tests

Change-Id: I6d3df08a472b15f646ddfccf502c946b5b13d2e6
This commit is contained in:
Travis Truman 2016-08-12 15:13:40 -05:00
parent 388dfe10e4
commit 29668ca8f0
3 changed files with 36 additions and 15 deletions

3
.gitignore vendored
View File

@ -62,3 +62,6 @@ ChangeLog
# Files created by releasenotes build # Files created by releasenotes build
releasenotes/build releasenotes/build
# Vagrant testing artifacts
.vagrant

13
Vagrantfile vendored Normal file
View File

@ -0,0 +1,13 @@
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
end
config.vm.provision "shell", inline: <<-SHELL
sudo su -
cd /vagrant
apt-get update
./run_tests.sh
SHELL
end

View File

@ -15,24 +15,29 @@
set -euov set -euov
ROLE_NAME=$(basename $(pwd))
FUNCTIONAL_TEST=${FUNCTIONAL_TEST:-true} FUNCTIONAL_TEST=${FUNCTIONAL_TEST:-true}
pushd tests # prep the host
ansible-galaxy install \ if [ "$(which apt-get)" ]; then
--role-file=ansible-role-requirements.yml \ apt-get install -y build-essential python2.7 python-dev git-core libssl-dev
--ignore-errors \ fi
--force
ansible-playbook -i inventory \ # get pip, if necessary
--syntax-check \ if [ ! "$(which pip)" ]; then
--list-tasks \ curl --silent --show-error --retry 5 \
-e "rolename=${ROLE_NAME}" \ https://bootstrap.pypa.io/get-pip.py | sudo python2.7
test.yml fi
ansible-lint test.yml # install tox
pip install tox
if ${FUNCTIONAL_TEST}; then # run through each tox env and execute the test
ansible-playbook -i inventory -e "rolename=${ROLE_NAME}" test.yml for tox_env in $(awk -F= '/envlist/ {print $2}' tox.ini | sed 's/,/ /g'); do
if [ "${tox_env}" != "functional" ]; then
tox -e ${tox_env}
elif [ "${tox_env}" == "functional" ]; then
if ${FUNCTIONAL_TEST}; then
tox -e ${tox_env}
fi
fi fi
popd done