Files
sos_testing/do_sos_avocado.sh
T
2026-04-09 15:59:17 +01:00

154 lines
4.0 KiB
Bash
Executable File

#!/bin/bash
#set -ax
script_cmd=${0##*/}
. functions.sh
declare -A all_series
if [[ "${script_cmd}" == *"_rh.sh" ]]; then
all_series=(
#['fedora38']="fedora/38/cloud"
#['fedora39']="fedora/39/cloud"
['fedora40']="fedora/40/cloud"
#['alma8']="almalinux/8/cloud"
#['alma9']="almalinux/9/cloud"
#['rocky8']="rockylinux/8/cloud"
#['rocky9']="rockylinux/9/cloud"
#['centos8']="centos/8-Stream/cloud"
#['centos9']="centos/9-Stream/cloud"
)
project_name="sos-testing-rh"
lxd_profile="lxd_profile_rh.yaml"
image_pre="images:"
sos_type="dnf"
else
all_series=(
# ['bionic']="ubuntu:bionic"
# ['focal']="ubuntu:focal"
# ['jammy']="ubuntu:jammy"
# ['noble']="ubuntu:noble"
# ['plucky']="ubuntu:plucky"
['questing']="ubuntu:questing"
# ['resolute']="ubuntu-daily:resolute"
)
project_name="sos-testing-ubuntu"
lxd_profile="lxd_profile_ubuntu.yaml"
image_pre=""
latest_dev_series="questing"
latest_sup_series="noble"
non_lts_releases="oracular plucky"
snap_channel="latest/candidate"
ppa_user="arif-ali"
ppa_name="sosreport-dev"
# this can be "deb" or "snap"
sos_type="deb"
# this can be "ppa" or "proposed"
deb_type="proposed"
fi
# general variables
project="--project ${project_name}"
lxc="lxc ${project}"
lxc_exec="${lxc} exec"
lxc_extra_args="-s virtual"
sos_location="$HOME/gitRepos/sos"
lxc project create ${project_name}
${lxc} profile edit default < ${lxd_profile}
for distro in "${!all_series[@]}"
do
inst_name=sos-avocado-${distro}
${lxc} delete ${inst_name} --force
image="${image_pre}${all_series[${distro}]}"
${lxc} launch ${image} ${inst_name} --vm -c limits.cpu=4 -c limits.memory=4GiB ${lxc_extra_args}
if [[ "${script_cmd}" == "do_sos_avocado"* ]] ; then
cd ${sos_location}
find . -type f -name "*.pyc" -exec sudo rm -f {} \;
rm -rf .tox *.snap *.deb
tar cfz /tmp/sos.tgz .
cd -
fi
check_vm_status ${inst_name} ${project_name}
if [[ "${script_cmd}" == "do_sos_avocado"* ]] ; then
${lxc} file push /tmp/sos.tgz ${inst_name}/root/sos.tgz
fi
echo -n "Checking cloud-init status of ${inst_name} "
while true ; do
status=$(${lxc_exec} ${inst_name} -- cloud-init status | grep status | awk '{print $2}')
[[ "${status}" == "done" ]] && break
[[ "${status}" == "error" ]] && break
sleep 3
echo -n "."
done
echo " done"
if [[ "${script_cmd}" == "do_sos_testing"* ]] ; then
if [[ "${deb_type}" == "ppa" ]] ; then
${lxc_exec} ${inst_name} -- sudo add-apt-repository -y ppa:${ppa_user}/${ppa_name}
if [[ "${distro}" == "${latest_dev_series}" ]] ; then
filename="$(echo ${ppa_name} | sed 's/\./_/g')"
${lxc_exec} ${inst_name} -- 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
elif [[ "${deb_type}" == "proposed" ]] ; then
${lxc_exec} ${inst_name} -- bash /root/enable_proposed.sh
fi
cat > setup_sos.sh << EOF
#!/bin/bash
sos_type="${sos_type}"
deb_type="${deb_type}"
distro="${distro}"
proposed=""
if [[ "\${sos_type}" == "deb" ]] ; then
if [[ "\${deb_type}" == "proposed" ]] ; then
proposed="/\${distro}-proposed"
fi
apt -y install sosreport\${proposed}
elif [[ "\${sos_type}" == "snap" ]] ; then
snap install sosreport --channel ${snap_channel} --classic
elif [[ "\${sos_type}" == "dnf" ]] ; then
dnf -y install sos
fi
EOF
${lxc} file push setup_sos.sh ${inst_name}/root/setup_sos.sh
fi
sleep_time=120
# Waiting 60 seconds for some logs to be created
echo Waiting ${sleep_time} for logs and VM to settle ...
sleep ${sleep_time}
if [[ "${script_cmd}" == "do_sos_avocado"* ]] ; then
${lxc_exec} ${inst_name} -- bash /root/run_avocado.sh | tee sos_run_avocado_${distro}.log
elif [[ "${script_cmd}" == "do_sos_testing"* ]] ; then
${lxc_exec} ${inst_name} -- bash /root/setup_sos.sh
${lxc_exec} ${inst_name} -- bash /root/run_sos.sh | tee sos_run_base_${distro}.log
fi
${lxc} stop ${inst_name}
done