Adding Vagrantfile for local testing
Running `vagrant up` will emulate the gate tests Change-Id: I6d3df08a472b15f646ddfccf502c946b5b13d2e6
This commit is contained in:
parent
388dfe10e4
commit
29668ca8f0
3
.gitignore
vendored
3
.gitignore
vendored
@ -62,3 +62,6 @@ ChangeLog
|
||||
|
||||
# Files created by releasenotes build
|
||||
releasenotes/build
|
||||
|
||||
# Vagrant testing artifacts
|
||||
.vagrant
|
||||
|
13
Vagrantfile
vendored
Normal file
13
Vagrantfile
vendored
Normal 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
|
35
run_tests.sh
35
run_tests.sh
@ -15,24 +15,29 @@
|
||||
|
||||
set -euov
|
||||
|
||||
ROLE_NAME=$(basename $(pwd))
|
||||
FUNCTIONAL_TEST=${FUNCTIONAL_TEST:-true}
|
||||
|
||||
pushd tests
|
||||
ansible-galaxy install \
|
||||
--role-file=ansible-role-requirements.yml \
|
||||
--ignore-errors \
|
||||
--force
|
||||
# prep the host
|
||||
if [ "$(which apt-get)" ]; then
|
||||
apt-get install -y build-essential python2.7 python-dev git-core libssl-dev
|
||||
fi
|
||||
|
||||
ansible-playbook -i inventory \
|
||||
--syntax-check \
|
||||
--list-tasks \
|
||||
-e "rolename=${ROLE_NAME}" \
|
||||
test.yml
|
||||
# get pip, if necessary
|
||||
if [ ! "$(which pip)" ]; then
|
||||
curl --silent --show-error --retry 5 \
|
||||
https://bootstrap.pypa.io/get-pip.py | sudo python2.7
|
||||
fi
|
||||
|
||||
ansible-lint test.yml
|
||||
# install tox
|
||||
pip install tox
|
||||
|
||||
if ${FUNCTIONAL_TEST}; then
|
||||
ansible-playbook -i inventory -e "rolename=${ROLE_NAME}" test.yml
|
||||
# run through each tox env and execute the test
|
||||
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
|
||||
popd
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user