Skip to content

Instantly share code, notes, and snippets.

@dosaboy
Last active October 25, 2018 14:04
Show Gist options
  • Select an option

  • Save dosaboy/0058c2e761fb3c3a8830454ba1529be1 to your computer and use it in GitHub Desktop.

Select an option

Save dosaboy/0058c2e761fb3c3a8830454ba1529be1 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Run Openstack unit tests in lxc container by installing deps from package
# instead of using the repo requirements file which is often out of step.
#
# NOTE: this needs to be run as two parts. First create the container and
# drop into bash prompt. Then execute the rest inside the container.
export SERIES=trusty
export OS_RELEASE=mitaka
export OS_PROJECT=nova
export GIT_BRANCH=${OS_RELEASE}-eol # could also be stable/$OS_RELEASE or just master
# Create container
lxc launch ubuntu:${SERIES} ${SERIES}-${OS_RELEASE}-ut
lxc exec ${SERIES}-${OS_RELEASE}-ut bash
# Now (that you are inside the container back prompt) execute the following inside the container
# install apt cache if you have one e.g.
#cat << EOF > /etc/apt/apt.conf.d/99-local-apt-cache
#Acquire::http::Proxy "http://my.apt.cache:3142";
#Acquire::https::Proxy "http://my.apt.cache:3142";
#EOF
export SERIES=trusty
export OS_RELEASE=mitaka
export OS_PROJECT=nova
export GIT_BRANCH=${OS_RELEASE}-eol
apt update
nohup add-apt-repository cloud-archive:${OS_RELEASE} -y
sed -i 's/#\s*deb-src/deb-src/g' /etc/apt/sources.list.d/cloudarchive-${OS_RELEASE}.list
apt update
nohup apt install devscripts dpkg-dev git equivs python-pip -y
sudo su - ubuntu
export SERIES=trusty
export OS_RELEASE=mitaka
export OS_PROJECT=nova
export GIT_BRANCH=${OS_RELEASE}-eol
apt-get source $OS_PROJECT
d=`ls -d ${OS_PROJECT}-*`; cd $d
sudo mk-build-deps --install --tool='apt-get --yes'
cd
git clone https://github.com/openstack/$OS_PROJECT -b $GIT_BRANCH --depth 1
sudo pip install tox
f=`mktemp`; grep hacking test-requirements.txt > $f; pip install -r $f; rm $f
cd $OS_PROJECT
# disable deps installation
sed -i -r -e 's/^deps /#deps /g' -e 's/^install_command /#install_command /g' tox.ini
# now you can run specific tests e.g.
tox -epy27 --sitepackages nova.tests.unit.network.test_manager.NetworkManagerNoDBTestCase.test_release_fixed_ip_no_mac
# if tox doesn't work you can try running it manually:
rm -rf .testrepository
testr init
TEMP_REZ=`mktemp -t`
testr run --subunit --parallel tests.unit| tee $$TEMP_REZ | subunit2pyunit
rm -f $TEMP_REZ
#NOTE: the debian package disables some tests so if you run them all you might get some errors that would not occur during a debian package build run of the same tests.
# Here are some examples of patches i had to add to get things working:
# mitaka
git apply ~/nova-13.1.4/debian/patches/disable-websockify-tests.patch
# ocata
# queens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment