Comment 17 for bug 2008280

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

To test on the ubuntu-advantage-tools package we have created a script that calls the update API multiple times and checks if the results are consistent. Since the problem that affected update-manager was that the endpoint was interfering with the APT cache.

This is the script we have used to test it:

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

#!/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

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 setup_python_script {
    echo -e "\n-------------------------------------------"
    echo "** Setting up python3 environment"
    echo "-------------------------------------------"

    cat > python-apt-test.py << EOF
from uaclient.api.u.pro.packages.updates.v1 import updates
from uaclient.system import subp

result = updates()
print(result.summary)
result = updates()
print(result.summary)
result = updates()
print(result.summary)
EOF
    lxc file push python-apt-test.py $name/tmp/
    echo "-------------------------------------------"
}

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

echo -e "\n-------------------------------------------"
echo "** Verify apt cache is not consistent"
lxc exec $name -- apt-get update
lxc exec $name -- python3 /tmp/python-apt-test.py
echo "-------------------------------------------"

upgrade_to_proposed

echo -e "\n-------------------------------------------"
echo "** Verify apt cache is now consistent"
lxc exec $name -- python3 /tmp/python-apt-test.py
echo "-------------------------------------------"

cleanup

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