Files
sos_testing/do_sos_avocado.sh
2024-08-13 21:43:24 +01:00

121 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
#set -ax
script_cmd=${0##*/}
declare -A all_series
all_series=(
# ['bionic']="ubuntu:bionic"
['focal']="ubuntu:focal"
['jammy']="ubuntu:jammy"
['noble']="ubuntu:noble"
['oracular']="ubuntu-daily:devel"
)
latest_dev_series="oracular"
latest_sup_series="noble"
non_lts_releases="mantic"
sos_type="deb"
sos_channel="latest/candidate"
ppa_user="arif-ali"
ppa_name="sosreport-dev"
# this can be "ppa" or "proposed"
deb_type="proposed"
project_name="sos-testing"
project="--project ${project_name}"
lxc="lxc ${project}"
lxc_exec="${lxc} exec"
sos_location="$HOME/gitRepos/sos"
lxc project create ${project_name}
${lxc} profile edit default < lxd_profile.yaml
for distro in "${!all_series[@]}"
do
inst_name=sos-avocado-${distro}
${lxc} delete ${inst_name} --force
image="${all_series[${distro}]}"
${lxc} launch ${image} ${inst_name} --vm -c limits.cpu=4 -c limits.memory=4GiB
if [[ "${script_cmd}" == "do_sos_avocado.sh" ]] ; 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
echo -n "Checking VM status of ${inst_name} "
while true ; do
num_of_procs=$(${lxc} info ${inst_name} | yq .Resources.Processes)
[[ ${num_of_procs} -gt 0 ]] && break
sleep 3
echo -n "."
done
echo done
if [[ "${script_cmd}" == "do_sos_avocado.sh" ]] ; 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.sh" ]] ; 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}"
if [[ "\${sos_type}" == "deb" ]] ; then
apt -y install sosreport
elif [[ "\${sos_type}" == "snap" ]] ; then
snap install sosreport --channel ${sos_channel} --classic
fi
EOF
${lxc} file push setup_sos.sh ${inst_name}/root/setup_sos.sh
fi
if [[ "${script_cmd}" == "do_sos_avocado.sh" ]] ; then
${lxc_exec} ${inst_name} -- bash /root/run_avocado.sh | tee sos_run_avocado_${distro}.log
elif [[ "${script_cmd}" == "do_sos_testing.sh" ]] ; 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