From e72f698f19b90dc76dffbc3e01ff36f9a114dd0f Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Tue, 20 Feb 2024 12:39:50 +0000 Subject: [PATCH] Update to latest * Add do_sos_testing.sh, which allows testing from custom PPA * Update do_sos_avocado.sh, testing some simple avocado on 3 distros * Update lxd profile for the avocado testing --- do_sos_avocado.sh | 44 +++++++++++++++++----------- do_sos_testing.sh | 65 ++++++++++++++++++++++++++++++++++++++++++ lxd_profile.yaml | 8 ++++-- sos_collect_testing.sh | 2 +- 4 files changed, 99 insertions(+), 20 deletions(-) create mode 100755 do_sos_testing.sh diff --git a/do_sos_avocado.sh b/do_sos_avocado.sh index 110b235..67ade92 100755 --- a/do_sos_avocado.sh +++ b/do_sos_avocado.sh @@ -2,11 +2,16 @@ set -ax +latest_dev_series="noble" +latest_sup_series="mantic" +#all_series="bionic focal jammy ${latest_sup_series} ${latest_dev_series}" +all_series="jammy ${latest_sup_series} ${latest_dev_series}" + + project_name="sos-testing" project="--project ${project_name}" lxc="lxc ${project}" inst_name=sos-avocado01 -distros="focal jammy lunar mantic" sos_location="$HOME/gitRepos/sos" @@ -18,26 +23,33 @@ lxc project create ${project_name} ${lxc} profile edit default < lxd_profile.yaml -for distro in ${distros} +for distro in ${all_series} do -${lxc} delete ${inst_name}-${distro} --force -${lxc} launch ubuntu:${distro} ${inst_name}-${distro} + ${lxc} delete ${inst_name}-${distro} --force -cd $sos_location -tar cfz /tmp/sos.tgz . -cd - + if [[ "${distro}" == "${latest_dev_series}" ]] ; then + image="ubuntu-daily:devel" + else + image="ubuntu:${distro}" + fi -${lxc} file push /tmp/sos.tgz ${inst_name}-${distro}/root/sos.tgz + ${lxc} launch ${image} ${inst_name}-${distro} -while true ; do - status=$(${lxc_exec} ${inst_name}-${distro} -- cloud-init status | grep status | awk '{print $2}') - [[ "${status}" == "done" ]] && break - [[ "${status}" == "error" ]] && break - sleep 3 -done + cd $sos_location + tar cfz /tmp/sos.tgz . + cd - -${lxc_exec} ${inst_name}-${distro} -- bash /root/run_avocado.sh -${lxc} stop ${inst_name}-${distro} + ${lxc} file push /tmp/sos.tgz ${inst_name}-${distro}/root/sos.tgz + + while true ; do + status=$(${lxc_exec} ${inst_name}-${distro} -- cloud-init status | grep status | awk '{print $2}') + [[ "${status}" == "done" ]] && break + [[ "${status}" == "error" ]] && break + sleep 3 + done + + ${lxc_exec} ${inst_name}-${distro} -- bash /root/run_avocado.sh + ${lxc} stop ${inst_name}-${distro} done diff --git a/do_sos_testing.sh b/do_sos_testing.sh new file mode 100755 index 0000000..9c53fb4 --- /dev/null +++ b/do_sos_testing.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +latest_dev_series="noble" +latest_sup_series="mantic" +all_series="bionic focal jammy ${latest_sup_series} ${latest_dev_series}" +sos_type="deb" +sos_channel="latest/candidate" + +ppa_user="arif-ali" +ppa_name="sosreport-dev" + +for series in ${all_series} +do + + lxc_host=${series}01-sos + + # clean up any previous containers + lxc delete ${lxc_host} --force + + if [[ "${series}" == "${latest_dev_series}" ]] ; then + image=ubuntu-daily:devel + else + image=ubuntu:${series} + fi + + lxc launch ${image} ${lxc_host} -s virtual + + repo="sosreport-dev" + + ## need to wait for the instance to come up, and have networking + sleep 5 + + if [[ "${sos_type}" == "deb" ]] ; then + lxc exec ${lxc_host} -- sudo add-apt-repository -y ppa:${ppa_user}/${ppa_name} + + if [[ "${series}" == "${latest_dev_series}" ]] ; then + + filename="$(echo ${repo} | sed 's/\./_/g')" + + lxc exec ${lxc_host} -- sed -i s/i${latest_sup_series}/${latest_dev_series}/g /etc/apt/sources.list.d/${ppa_user}-ubuntu-${filename}-${latest_sup_series}.list + + fi + + fi + + cat > test_sos.sh << EOF +#!/bin/bash + +sos_type="${sos_type}" + +apt -y update +apt -y --purge --autoremove remove sosreport +if [[ "\${sos_type}" == "deb" ]] ; then + apt -y install sosreport +elif [[ "\${sos_type}" == "snap" ]] ; then + snap install sosreport --channel ${sos_channel} --classic +fi +sos report -a --all-logs --batch +EOF + + lxc file push test_sos.sh ${lxc_host}/root/test_sos.sh + lxc exec ${lxc_host} -- sudo bash /root/test_sos.sh + + lxc delete ${lxc_host} --force +done diff --git a/lxd_profile.yaml b/lxd_profile.yaml index 18fb83f..cd9e13a 100644 --- a/lxd_profile.yaml +++ b/lxd_profile.yaml @@ -25,7 +25,11 @@ config: codename=$(grep UBUNTU_CODENAME /etc/os-release | awk -F= '{print $2}') pip_extra="" - [[ "${codename}" == "mantic" ]] || [[ "${codename}" == "lunar" ]] && pip_extra="--break-system-packages" + case "${codename}" in + "mantic"|"noble") + pip_extra="--break-system-packages" + ;; + esac pip3 install avocado-framework==94.0 ${pip_extra} - path: /root/run_avocado.sh @@ -41,8 +45,6 @@ config: mkdir -p /etc/sos cp sos.conf /etc/sos/sos.conf - #pip3 install -r requirements.txt --break-system-packages - echo "Running Unit Tests ..." PYTHONPATH=. avocado run tests/unittests/ diff --git a/sos_collect_testing.sh b/sos_collect_testing.sh index 93a2f1a..e53bebb 100755 --- a/sos_collect_testing.sh +++ b/sos_collect_testing.sh @@ -14,7 +14,7 @@ cloudinit-userdata: | packages: - sosreport postruncmd: - - [ 'apt', 'install', '-y', 'sosreport/\$RELEASE-proposed' ] + - [ 'apt', 'install', '-y', 'sosreport/*-proposed' ] EOF