Fix the diskimage-create tox "build" environment

The recently added tox "build" environment had a few problems:
1. It was not honoring the DIB_* environment variables which meant
in always built a master branch image.
2. It also failed to run repeatedly due to a cache directory path issue.
3. The built images were stored in a hidden folder ".amp_tox_test".

This patch fixes those issues, resolves a confusing
"dpkg Broken pipe" message, and adds a "Successfully built" message
at the end of the built that highlights which branch the image was
built against (master, stable/stein, etc.).

Change-Id: I826c5f753f159b2d5dee97d4e2922826444ea6da
This commit is contained in:
Michael Johnson 2019-08-29 16:21:39 -07:00 committed by Adam Harwell
parent a498823789
commit fbe328397b
2 changed files with 12 additions and 4 deletions

View File

@ -207,6 +207,9 @@ AMP_ARCH=${AMP_ARCH:-"amd64"}
AMP_BACKEND=${AMP_BACKEND:-"haproxy-octavia"}
AMP_CACHEDIR=${AMP_CACHEDIR:-"$HOME/.cache/image-create"}
# Make sure we have an absolute path for the cache location
mkdir -p $AMP_CACHEDIR
AMP_CACHEDIR="$( cd "$AMP_CACHEDIR" && pwd )"
AMP_BASEOS=${AMP_BASEOS:-"ubuntu-minimal"}
@ -307,7 +310,7 @@ fi
if [ "$platform" = 'NAME="Ubuntu"' ]; then
PKG_LIST="qemu-utils git kpartx debootstrap"
for pkg in $PKG_LIST; do
if ! dpkg --get-selections | grep -q "^$pkg[[:space:]]*install$" >/dev/null; then
if ! dpkg --get-selections 2> /dev/null | grep -q "^$pkg[[:space:]]*install$" >/dev/null; then
echo "Required package " $pkg " is not installed. Exiting."
echo "Binary dependencies on this platform are: ${PKG_LIST}"
exit 1
@ -436,3 +439,9 @@ disk-image-create $AMP_LOGFILE $dib_trace_arg -a $AMP_ARCH -o $AMP_OUTPUTFILENAM
popd > /dev/null # out of $TEMP
rm -rf $TEMP
if [ -z "$DIB_REPOREF_amphora_agent" ]; then
echo "Successfully built the amphora image using amphora-agent from the master branch."
else
echo "Successfully built the amphora using the $DIB_REPOREF_amphora_agent amphora-agent."
fi

View File

@ -7,7 +7,7 @@ skipsdist = True
basepython = python3
envdir = {toxworkdir}/venv
setenv = VIRTUAL_ENV={envdir}
passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY DIB_* CLOUD_INIT_DATASOURCES OCTAVIA_REPO_PATH
install_command = pip install -U {opts} {packages}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
@ -27,8 +27,7 @@ commands = bashate diskimage-create.sh
[testenv:build]
# NOTE: specify cache directory explicitly with -c as the `diskimage-create.sh`
# default is based off of `$HOME` which is not passed on in a `tox` environment.
commands = mkdir -p {toxinidir}/.amp_tox_test
./diskimage-create.sh -o {toxinidir}/.amp_tox_test/amphora-x64-haproxy -w {toxworkdir} -c {toxworkdir}/.cache
commands = ./diskimage-create.sh -o {toxinidir}/amphora-x64-haproxy -w {toxworkdir} -c {toxworkdir}/.cache
[testenv:test]
# Work around tox limitations with command pipes