From 0f7da9394a4277ce8064e4f6cc4c1d2b1beb2401 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Mon, 29 Apr 2024 16:40:31 +0100 Subject: [PATCH] Combine 2 sctipts, add GCE image listing, add README --- README.md | 21 +++++++++++++++ do_sos_avocado.sh | 59 ++++++++++++++++++++++++++++++++++------- do_sos_testing.sh | 66 +--------------------------------------------- get_image_names.sh | 6 ++--- lxd_profile.yaml | 7 +++++ 5 files changed, 81 insertions(+), 78 deletions(-) create mode 100644 README.md mode change 100755 => 120000 do_sos_testing.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..268fad7 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +Some scripts to help with some simple auto testing + +# `do_sos_avocado.sh` + +Runs avocado tests on the latest commits in your folder on all the supported +distros + +# `do_sos_testing.sh` + +Runs a quick sos report on all distros from a PPA or a snap channel + +# `sos_collect_testing.sh` + +* Creates a new juju model +* Launches N number of ubuntu units +* Runs sos collect to test the functionality + +# `get_image_names.sh` + +Grabs image names for Cirrus CI testing purspoes, this ensures we can get +these quickly, rather than trawling on GCE UI diff --git a/do_sos_avocado.sh b/do_sos_avocado.sh index dec7684..a740836 100755 --- a/do_sos_avocado.sh +++ b/do_sos_avocado.sh @@ -2,9 +2,18 @@ #set -ax -latest_dev_series="noble" -latest_sup_series="mantic" -all_series="bionic focal jammy ${latest_sup_series} ${latest_dev_series}" +script_cmd=${0##*/} + +latest_dev_series="" +latest_sup_series="noble" +non_lts_releases="mantic" +all_series="bionic focal jammy noble ${non_lts_releases} ${latest_dev_series}" + +sos_type="deb" +sos_channel="latest/candidate" + +ppa_user="arif-ali" +ppa_name="sosreport-dev" project_name="sos-testing" project="--project ${project_name}" @@ -32,11 +41,14 @@ do ${lxc} launch ${image} ${inst_name} --vm -c limits.cpu=4 -c limits.memory=4GiB - cd ${sos_location} - find . -type f -name "*.pyc" -exec sudo rm -f {} \; - rm -rf .tox *.snap *.deb - tar cfz /tmp/sos.tgz . - cd - + + 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} " @@ -49,7 +61,9 @@ do echo done - ${lxc} file push /tmp/sos.tgz ${inst_name}/root/sos.tgz + 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} " @@ -63,7 +77,32 @@ do echo done - ${lxc_exec} ${inst_name} -- bash /root/run_avocado.sh + if [[ "${script_cmd}" == "do_sos_testing.sh" ]] ; 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 + 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 + 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 + fi ${lxc} stop ${inst_name} done diff --git a/do_sos_testing.sh b/do_sos_testing.sh deleted file mode 100755 index 9c53fb4..0000000 --- a/do_sos_testing.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/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/do_sos_testing.sh b/do_sos_testing.sh new file mode 120000 index 0000000..a0b7aa8 --- /dev/null +++ b/do_sos_testing.sh @@ -0,0 +1 @@ +do_sos_avocado.sh \ No newline at end of file diff --git a/get_image_names.sh b/get_image_names.sh index 6da1de3..d7572bd 100755 --- a/get_image_names.sh +++ b/get_image_names.sh @@ -21,7 +21,7 @@ do done -# Fpr testing for the next daily release depdning on LTS or non-LTS +# For testing for the next daily release depdning on LTS or non-LTS -#gcloud compute images list --project ubuntu-os-cloud-devel --filter="family:ubuntu-2410-amd64" -#gcloud compute images list --project ubuntu-os-cloud-devel --filter="family:ubuntu-2404-lts-amd64" +gcloud compute images list --project ubuntu-os-cloud-devel --filter="family:ubuntu-2410-amd64" +gcloud compute images list --project ubuntu-os-cloud-devel --filter="family:ubuntu-2404-lts-amd64" diff --git a/lxd_profile.yaml b/lxd_profile.yaml index 6823873..c050c64 100644 --- a/lxd_profile.yaml +++ b/lxd_profile.yaml @@ -48,6 +48,13 @@ config: echo "Running Stage Two Tests ..." tox -e stagetwo_tests + - path: /root/run_sos.sh + permissions: '0755' + owner: root:root + content: | + #!bin/bash + + sos report -a --all-logs --batch runcmd: - [ /root/setup.sh ]