From 31a6dcd37f13bbdf85578f69ed70432d3b2b8d74 Mon Sep 17 00:00:00 2001 From: Antti Kervinen Date: Wed, 4 Aug 2021 11:23:06 +0300 Subject: [PATCH] e2e: add support for distro=sles --- demo/lib/distro.bash | 38 +++++++++++++++++++++++++++++++------- demo/lib/vm.bash | 12 ++++++++++++ test/e2e/run.sh | 5 +++++ 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/demo/lib/distro.bash b/demo/lib/distro.bash index 3bfb62957..c7460d309 100644 --- a/demo/lib/distro.bash +++ b/demo/lib/distro.bash @@ -25,6 +25,7 @@ distro-refresh-pkg-db() { distro-resolve "$@"; } distro-install-pkg() { distro-resolve "$@"; } distro-remove-pkg() { distro-resolve "$@"; } distro-setup-proxies() { distro-resolve "$@"; } +distro-install-utils() { distro-resolve "$@"; } distro-install-golang() { distro-resolve "$@"; } distro-install-containerd() { distro-resolve "$@"; } distro-config-containerd() { distro-resolve "$@"; } @@ -78,6 +79,7 @@ distro-resolve-fn() { centos*) candidates="$candidates fedora-$apifn rpm-$apifn";; fedora*) candidates="$candidates rpm-$apifn";; *suse*) candidates="$candidates rpm-$apifn";; + sles*) candidates="$candidates opensuse-$apifn rpm-$apifn";; esac case $apifn in *-pre|*-post) ;; @@ -398,11 +400,26 @@ EOF ########################################################################### # -# OpenSUSE 15.2 +# OpenSUSE 15.2 and SLES # ZYPPER="zypper --non-interactive --no-gpg-checks" +sles-image-url() { + echo "/DOWNLOAD-MANUALLY-TO-HOME/vms/images/SLES15-SP3-JeOS.x86_64-15.3-OpenStack-Cloud-GM.qcow2" +} + +sles-ssh-user() { + echo "sles" +} + +sles-install-utils() { + vm-command-q "$ZYPPER lr openSUSE-Oss >/dev/null" || { + distro-install-repo http://download.opensuse.org/distribution/leap/15.3/repo/oss/ openSUSE-Oss + } + distro-install-pkg sysvinit-tools psmisc +} + opensuse-image-url() { echo "https://download.opensuse.org/repositories/Cloud:/Images:/Leap_15.2/images/openSUSE-Leap-15.2-OpenStack.x86_64-0.0.4-Build8.25.qcow2" } @@ -438,12 +455,12 @@ opensuse-remove-pkg() { } opensuse-install-golang() { - opensuse-install-pkg wget tar gzip git-core + distro-install-pkg wget tar gzip git-core from-tarball-install-golang } opensuse-wait-for-zypper() { - vm-run-until --timeout 5 '( ! pidof zypper >/dev/null ) || ( killall zypper; sleep 1; exit 1 )' || + vm-run-until --timeout 5 '( ! pgrep zypper >/dev/null ) || ( pkill -9 zypper; sleep 1; exit 1 )' || error "Failed to stop zypper running in the background" } @@ -458,7 +475,7 @@ opensuse-install-containerd() { opensuse-install-repo https://download.opensuse.org/repositories/Virtualization:containers/openSUSE_Leap_15.2/Virtualization:containers.repo opensuse-refresh-pkg-db fi - opensuse-install-pkg --from Virtualization_containers containerd containerd-ctr + distro-install-pkg --from Virtualization_containers containerd containerd-ctr vm-command "ln -sf /usr/sbin/containerd-ctr /usr/sbin/ctr" cat < /proc/sys/net/ipv4/ip_forward" vm-command "zypper ls" if ! grep -q snappy <<< "$COMMAND_OUTPUT"; then - opensuse-install-repo "http://download.opensuse.org/repositories/system:/snappy/openSUSE_Leap_15.2 snappy" - opensuse-refresh-pkg-db - opensuse-install-pkg "snapd apparmor-profiles socat ebtables cri-tools conntrackd" + distro-install-repo "http://download.opensuse.org/repositories/system:/snappy/openSUSE_Leap_15.2 snappy" + distro-refresh-pkg-db + distro-install-pkg "snapd apparmor-profiles socat ebtables cri-tools conntrackd iptables ethtool" fi vm-install-containernetworking vm-command "systemctl enable --now snapd" @@ -642,6 +659,13 @@ EOF done } +default-install-utils() { + # $distro-install-utils() is responsible for installing common + # utilities, such as pidof and killall, that the test framework + # and tests in general can expect to be found on VM. + : +} + default-k8s-cni() { echo cilium } diff --git a/demo/lib/vm.bash b/demo/lib/vm.bash index 8f233f24f..5b15f887f 100644 --- a/demo/lib/vm.bash +++ b/demo/lib/vm.bash @@ -632,6 +632,18 @@ vm-install-pkg() { distro-install-pkg "$@" } +vm-setup-oneshot() { + local util + distro-refresh-pkg-db + distro-install-utils + # Verify that all required utilities exit on the VM. + for util in pidof killall; do + vm-command-q "command -v $util >/dev/null" || { + error "required command '$util' missing on VM, fix/implement $distro-install-utils()" + } + done +} + vm-install-golang() { distro-install-golang } diff --git a/test/e2e/run.sh b/test/e2e/run.sh index b8b8cf5c9..984c64c46 100755 --- a/test/e2e/run.sh +++ b/test/e2e/run.sh @@ -1161,6 +1161,11 @@ fi is-hooked "on_vm_online" && run-hook "on_vm_online" +if [ "$reinstall_oneshot" == "1" ] || ! vm-command-q "[ -f .vm-setup-oneshot ]"; then + vm-setup-oneshot + vm-command-q "touch .vm-setup-oneshot" +fi + if [ -n "$vm_files" ]; then install-files "$vm_files" fi