Comment 12 for bug 2007234

Revision history for this message
Lucas Albuquerque Medeiros de Moura (lamoura) wrote :

The following script was used to verify this issue:

----------------------------------

#!/bin/bash
set -e

series=$1

name=$series-test

function cleanup {
  lxc delete $name --force
}

function on_err {
  echo -e "Test Failed"
  cleanup
  exit 1
}

trap on_err ERR

if [ $series == "xenial" ]; then
    python_ver=3.5
    cpython_ver="35m"
elif [ $series == "bionic" ]; then
    python_ver=3.6
    cpython_ver="36m"
elif [ $series == "focal" ]; then
    python_ver=3.8
    cpython_ver="38"
elif [ $series == "jammy" ]; then
    python_ver=3.10
    cpython_ver="310"
elif [ $series == "kinetic" ]; then
    python_ver=3.10
    cpython_ver="310"
elif [ $series == "lunar" ]; then
    python_ver=3.11
    cpython_ver="311"
fi

function upgrade_to_latest {
    echo -e "\n-------------------------------------------"
    echo "** upgrading to 27.13.6"
    echo "-------------------------------------------"
    lxc exec $name -- apt-get update > /dev/null
    lxc exec $name -- apt-get install ubuntu-advantage-tools -y
    lxc exec $name -- apt-cache policy ubuntu-advantage-tools
    echo "-------------------------------------------"
}

function upgrade_to_proposed {
    echo -e "\n-------------------------------------------"
    echo "** upgrading to 27.14.3 from proposed"
    echo "-------------------------------------------"
    lxc exec $name -- sh -c "echo \"deb http://archive.ubuntu.com/ubuntu $series-proposed main\" | tee /etc/apt/sources.list.d/proposed.list"
    lxc exec $name -- apt-get update > /dev/null
    lxc exec $name -- apt-get install ubuntu-advantage-tools -y
    lxc exec $name -- apt-cache policy ubuntu-advantage-tools
    echo "-------------------------------------------"
}

function set_up_python3_env {
    echo -e "\n-------------------------------------------"
    echo "** Setting up python3 environment"
    echo "-------------------------------------------"
    lxc exec $name -- apt install python3-venv -y > /dev/null
    lxc exec $name -- python3 -m venv env
    lxc exec $name -- ln -s /usr/lib/python3/dist-packages/uaclient env/lib/python$python_ver/site-packages/uaclient
    lxc exec $name -- ln -s /usr/lib/python3/dist-packages/apt env/lib/python$python_ver/site-packages/apt
    lxc exec $name -- ln -s /usr/lib/python3/dist-packages/apt_pkg.cpython-$cpython_ver-x86_64-linux-gnu.so env/lib/python$python_ver/site-packages/apt_pkg.cpython-$cpython_ver-x86_64-linux-gnu.so
    echo "-------------------------------------------"
}

lxc launch ubuntu-daily:$series $name
sleep 5
upgrade_to_latest
set_up_python3_env

echo -e "\n-------------------------------------------"
echo "** Verify no yaml breaks esm-cache service"
lxc exec $name -- sh -c ". ./env/bin/activate && python /usr/lib/ubuntu-advantage/esm_cache.py" || true
lxc exec $name -- systemctl start esm-cache.service
lxc exec $name -- systemctl status esm-cache.service || true
echo "-------------------------------------------"

upgrade_to_proposed

echo -e "\n-------------------------------------------"
echo "** Verify python3 config no longer breaks esm-cache service"
lxc exec $name -- sh -c ". ./env/bin/activate && python /usr/lib/ubuntu-advantage/esm_cache.py" || true
lxc exec $name -- systemctl start esm-cache.service
lxc exec $name -- systemctl status esm-cache.service || true
echo "-------------------------------------------"

cleanup

--------------------------