From b90f7be2af88f76344cbf9339f0ded0c877c8536 Mon Sep 17 00:00:00 2001 From: Dheyay Date: Thu, 22 Feb 2024 13:51:45 -0800 Subject: [PATCH] Added sru test for release-32 --- sru/release-32/test-user-config-created.sh | 59 ++++++++++++++++++++++ uaclient/files/user_config_file.py | 2 +- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 sru/release-32/test-user-config-created.sh diff --git a/sru/release-32/test-user-config-created.sh b/sru/release-32/test-user-config-created.sh new file mode 100644 index 0000000000..9d26933fba --- /dev/null +++ b/sru/release-32/test-user-config-created.sh @@ -0,0 +1,59 @@ +#!/bin/bash +set -e + +series=$1 +install_from=$2 # either path to a .deb, or 'staging', or 'proposed' + +name=$series-dev + +function cleanup { + lxc delete $name --force +} + +function on_err { + echo -e "Test Failed" + cleanup + exit 1 +} +trap on_err ERR + + +lxc launch ubuntu-daily:$series $name +sleep 5 + +# Install latest ubuntu-advantage-tools +lxc exec $name -- apt-get update > /dev/null +lxc exec $name -- apt-get install -y ubuntu-advantage-tools > /dev/null +echo -e "\n* Latest u-a-t is installed" +echo "###########################################" +lxc exec $name -- apt-cache policy ubuntu-advantage-tools +echo -e "###########################################\n" + +# Remove user-config.json and private/user-config.json +lxc exec $name -- sudo rm /var/lib/ubuntu-advantage/user-config.json +lxc exec $name -- sudo rm /var/lib/ubuntu-advantage/private/user-config.json + +# Verify that the files are deleted +lxc exec $name -- test ! -e /var/lib/ubuntu-advantage/user-config.json +lxc exec $name -- test ! -e /var/lib/ubuntu-advantage/private/user-config.json + +# ---------------------------------------------------------------- +if [ $install_from == 'staging' ]; then + lxc exec $name -- sudo add-apt-repository ppa:ua-client/staging -y > /dev/null + lxc exec $name -- apt-get update > /dev/null + lxc exec $name -- apt-get install ubuntu-advantage-tools -y > /dev/null +elif [ $install_from == 'proposed' ]; then + 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 > /dev/null +else + lxc file push $install_from $name/new-ua.deb + lxc exec $name -- dpkg -i /new-ua.deb > /dev/null +fi +# ---------------------------------------------------------------- + +# Verify that the files exist again +lxc exec $name -- test -e /var/lib/ubuntu-advantage/user-config.json +lxc exec $name -- test -e /var/lib/ubuntu-advantage/private/user-config.json + +cleanup \ No newline at end of file diff --git a/uaclient/files/user_config_file.py b/uaclient/files/user_config_file.py index b9c8a91e78..990dc3980a 100644 --- a/uaclient/files/user_config_file.py +++ b/uaclient/files/user_config_file.py @@ -3,7 +3,7 @@ import os from typing import Optional -from uaclient import defaults, event_logger, exceptions, util +from uaclient import defaults, event_logger, util from uaclient.data_types import ( BoolDataValue, DataObject,