Comment 1 for bug 1924766

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

For this SRU bug I have created the following test script:

-----------------------------------
#!/bin/sh
set -x

series=hirsute
name=$series-dev

function update-notifier-ua-not-installed () {
    # Expects this output
    # x packages can be updated.
    # x of these updates are security updates.
    echo "-----------------------------------------------------------"
    echo "$series: ua not installed"
    lxc exec $name -- /usr/lib/update-notifier/apt-check --human-readable
    echo "-----------------------------------------------------------"
}

function update-notifier-ua-not-attached-esm () {
    # x updates can be installed immediately.
    # x of these updates are security updates.
    #
    # Enable UA Apps: ESM to receive x additional security updates.
    # See https://ubuntu.com/security/esm or run: sudo ua status
    echo "-----------------------------------------------------------"
    echo "$series esm: ua not attached"
    lxc exec $name -- /usr/lib/update-notifier/apt-check --human-readable
    echo "-----------------------------------------------------------"
}

function update-notifier-ua-not-attached () {
    # Expects this output
    # UA Infra: Extended Security Maintenance (ESM) is not enabled.
    #
    # x updates can be installed immediately.
    # x of these updates are security updates.
    echo "-----------------------------------------------------------"
    echo "$series non-esm: ua not attached"
    lxc exec $name -- /usr/lib/update-notifier/apt-check --human-readable
    echo "-----------------------------------------------------------"
}

function update-notifier-ua-attached-esm () {
    # Expects this output
    # x updates can be installed immediately.
    # x of these updates are fixed through UA Apps: ESM.
    # x of these updates are security updates.
    # To see these additional updates run: apt list --upgradable
    echo "-----------------------------------------------------------"
    echo "$series esm: ua attached"
    lxc exec $name -- /usr/lib/update-notifier/apt-check --human-readable
    echo "-----------------------------------------------------------"
}

function update-notifier-ua-attached () {
    # Expects this output
    # x updates can be installed immediately.
    # x of these updates are fixed through UA Apps: ESM.
    # x of these updates are security updates.
    # To see these additional updates run: apt list --upgradable
    echo "-----------------------------------------------------------"
    echo "$series non-esm: ua attached"
    lxc exec $name -- /usr/lib/update-notifier/apt-check --human-readable
    echo "-----------------------------------------------------------"
}

function turn-distro-into-esm-mode() {
    # guarantee that xenial distro is on ESM mode
    lxc exec $name -- sed -i 's/is_esm_supported and is_not_currently_supported/True #comment/' /usr/lib/update-notifier/apt-check
}

function turn-distro-into-non-esm-mode() {
    # guarantee that xenial distro is on ESM mode
    lxc exec $name -- sed -i 's/True #comment/False/' /usr/lib/update-notifier/apt-check
}

function setup-update-notifier() {
    lxc exec $name -- add-apt-repository ppa:lamoura/update-notifier-test-ppa -y
    lxc exec $name -- apt update
    lxc exec $name -- apt install update-notifier-common -y
}

function install-ua() {
    lxc exec $name -- add-apt-repository ppa:ua-client/daily -y
    lxc exec $name -- sudo apt-get update
    lxc exec $name -- sudo apt-get install ubuntu-advantage-tools -y
    lxc exec $name -- ua version
    lxc exec $name -- sudo apt-get update
}

function ua-attach() {
    lxc exec $name -- sed -i 's/contracts.can/contracts.staging.can/' /etc/ubuntu-advantage/uaclient.conf
    lxc exec $name -- ua attach $UACLIENT_BEHAVE_CONTRACT_TOKEN_STAGING
}

function ua-detach() {
    lxc exec $name -- ua detach --assume-yes
}

lxc delete --force $name
lxc launch ubuntu-daily:$series $name
sleep 10

setup-update-notifier
update-notifier-ua-not-installed
install-ua
turn-distro-into-esm-mode
update-notifier-ua-not-attached-esm
ua-attach
update-notifier-ua-attached-esm
turn-distro-into-non-esm-mode
ua-detach
update-notifier-ua-not-attached
ua-attach
update-notifier-ua-attached

set +x
------------------------------------

I have used it to verify the behavior of the updated package on xenial and hirsute. The packages used to perform such testing are found on this ppa:
https://launchpad.net/~lamoura/+archive/ubuntu/update-notifier-test-ppa