Merge ~alfonsosanchezbeato/snappy-hwe-snaps/+git/modem-manager:test-on-uc20 into ~snappy-hwe-team/snappy-hwe-snaps/+git/modem-manager:snap-20

Proposed by Alfonso Sanchez-Beato
Status: Merged
Approved by: Alfonso Sanchez-Beato
Approved revision: 6a1f448ffee9268e75092c7b6718939f6de5314f
Merged at revision: 7e5f1f1a7199f32dc8435e94459a61f31ec94559
Proposed branch: ~alfonsosanchezbeato/snappy-hwe-snaps/+git/modem-manager:test-on-uc20
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/modem-manager:snap-20
Diff against target: 352 lines (+85/-110)
8 files modified
run-tests.sh (+50/-32)
spread.yaml (+4/-2)
tests/lib/prepare-all.sh (+3/-41)
tests/lib/prepare.sh (+8/-13)
tests/lib/restore-each.sh (+5/-11)
tests/lib/snap-names.sh (+1/-1)
tests/lib/utilities.sh (+9/-9)
tests/main/network-manager-autoconn/task.yaml (+5/-1)
Reviewer Review Type Date Requested Status
System Enablement Bot continuous-integration Approve
Review via email: mp+387327@code.launchpad.net

Commit message

tests: adapt to run on UC20

Description of the change

tests: adapt to run on UC20

To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 6a1f448ffee9268e75092c7b6718939f6de5314f

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/1342/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/run-tests.sh b/run-tests.sh
index 04c3b9f..7f827b6 100755
--- a/run-tests.sh
+++ b/run-tests.sh
@@ -1,4 +1,4 @@
1#!/bin/sh1#!/bin/bash
2#2#
3# Copyright (C) 2016 Canonical Ltd3# Copyright (C) 2016 Canonical Ltd
4#4#
@@ -17,63 +17,81 @@
17set -e17set -e
1818
19TESTS_EXTRAS_URL="https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/stack-snaps-tools"19TESTS_EXTRAS_URL="https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/stack-snaps-tools"
20TESTS_EXTRAS_PATH="stack-snaps-tools"20TESTS_EXTRAS_PATH="tests-extras"
2121
22# Display help.
23# This has to be in sync with the tests-extras/test-runner.sh script
24# functionalities as the parameters to this one are passed directly there
25# this function will quit the script because of the 'exec' keyword
26show_help() {22show_help() {
27 exec cat <<'EOF'23 exec cat <<'EOF'
28Usage: run-tests.sh [OPTIONS]24Usage: run-tests.sh [OPTIONS]
2925
30This is fetch & forget script and what it does is to fetch the26This is fetch & forget script and what it does is to fetch the
31tests-extras repository and execute the run-tests.sh script from27stack-snaps-tools repository and execute the run-tests.sh script from
32there passing arguments as-is.28there passing arguments as-is.
3329
34optional arguments:30When you see this message you don't have the tests-extras folder
35 --help Show this help message and exit31successfully populated in your workspace yet. Please rerun without
36 --channel Select another channel to build the base image from (default: stable)32specifying --help to proceed with the initial clone of the git repository.
37 --snap Extra snap to install
38 --debug Enable verbose debugging output
39 --test-from-channel Pull network-manager snap from the specified channel instead of building it from source
40 --force-new-image Force generating a new image used for testing
41EOF33EOF
42}34}
4335
44# Clone the tests-extras repository36# Clone the stack-snaps-tools repository
45clone_tests_extras() {37clone_tests_extras() {
46 echo "INFO: Fetching tests-extras scripts into $TESTS_EXTRAS_PATH ..."38 echo "INFO: Fetching stack-snaps-tools scripts into $TESTS_EXTRAS_PATH ..."
47 git clone -b master $TESTS_EXTRAS_URL $TESTS_EXTRAS_PATH >/dev/null 2>&139 if ! git clone -b master $TESTS_EXTRAS_URL $TESTS_EXTRAS_PATH >/dev/null 2>&1; then
48 if [ $? -ne 0 ]; then40 echo "ERROR: Failed to fetch the $TESTS_EXTRAS_URL repo, exiting.."
49 echo "ERROR: Failed to fetch the $TESTS_EXTRAS_URL repo, exiting.."41 exit 1
50 exit 142 fi
51 fi
52}43}
5344
54# Make sure the already cloned tests-extras repository is in a known and update45# Make sure the already cloned stack-snaps-tools repository is in a known and update
55# state before it is going to be used.46# state before it is going to be used.
56restore_and_update_tests_extras() {47restore_and_update_tests_extras() {
57 echo "INFO: Restoring and updating $TESTS_EXTRAS_PATH"48 echo "INFO: Restoring and updating $TESTS_EXTRAS_PATH"
58 cd $TESTS_EXTRAS_PATH && git reset --hard && git clean -dfx && git pull49 cd $TESTS_EXTRAS_PATH && git reset --hard && git clean -dfx && git pull
59 cd -50 cd -
60}51}
6152
62# ==============================================================================53# ==============================================================================
63# This is fetch & forget script and what it does is to fetch the tests-extras54# This is fetch & forget script and what it does is to fetch the stack-snaps-tools
64# repo and execute the run-tests.sh script from there passing arguments as-is.55# repo and execute the run-tests.sh script from there passing arguments as-is.
65#56#
66# The tests-extras repository ends up checked out in the snap tree but as a57# The stack-snaps-tools repository ends up checked out in the snap tree but as a
67# hidden directory which is re-used since then.58# hidden directory which is re-used since then.
6859
69# Display help w/o fetching anything and exit60# Find snap to use in the tests
70[ "$1" = "--help" ] && show_help61snaps=$(find . -maxdepth 1 -type f -name \
62 "*_*_$(dpkg-architecture -q DEB_HOST_ARCH).snap")
63while read -r snap_file; do
64 if [ -n "$snap" ]; then
65 printf "More than one snap revision in the folder\n"
66 exit 1
67 fi
68 snap=$PWD/${snap_file#*/}
69done < <(printf "%s\n" "$snaps")
70
71[ ! -d "$TESTS_EXTRAS_PATH" ] && [ "$1" = "--help" ] && show_help
7172
72if [ -d "$TESTS_EXTRAS_PATH" ]; then73if [ -d "$TESTS_EXTRAS_PATH" ]; then
73 restore_and_update_tests_extras74 restore_and_update_tests_extras
74else75else
75 clone_tests_extras76 clone_tests_extras
77fi
78
79# Any project-specific options for test-runner should be specified in
80# .tests_config under EXTRA_ARGS
81if [ -f ".tests_config" ]; then
82 # shellcheck disable=SC1091
83 . .tests_config
76fi84fi
7785
86# Get backends
87backends="--backends="
88separator=""
89while read -r be; do
90 backends=$backends$separator${be##*.}
91 separator=,
92done < <(yq r spread.yaml --printMode p 'backends.qemu.systems[*].*')
93
78echo "INFO: Executing tests runner"94echo "INFO: Executing tests runner"
79cd $TESTS_EXTRAS_PATH && ./tests-runner.sh "$@"95# shellcheck disable=SC2086
96cd $TESTS_EXTRAS_PATH &&
97 ./tests-runner.sh "$@" --snap="$snap" "$backends" $EXTRA_ARGS
diff --git a/spread.yaml b/spread.yaml
index 1368084..9a775ca 100644
--- a/spread.yaml
+++ b/spread.yaml
@@ -28,8 +28,10 @@ environment:
2828
29backends:29backends:
30 qemu:30 qemu:
31 memory: 4G
31 systems:32 systems:
32 - ubuntu-core-16:33 - ubuntu-core-20:
34 bios: /usr/share/OVMF/OVMF_CODE.fd
33 username: test35 username: test
34 password: test36 password: test
3537
@@ -55,7 +57,7 @@ suites:
55 tests/main/:57 tests/main/:
56 summary: Full-system tests for ModemManager58 summary: Full-system tests for ModemManager
57 systems:59 systems:
58 - ubuntu-core-1660 - ubuntu-core-20
59 prepare: |61 prepare: |
60 . $TESTSLIB/prepare.sh62 . $TESTSLIB/prepare.sh
61 restore-each: |63 restore-each: |
diff --git a/tests/lib/prepare-all.sh b/tests/lib/prepare-all.sh
index 979e57d..08ae20a 100644
--- a/tests/lib/prepare-all.sh
+++ b/tests/lib/prepare-all.sh
@@ -1,42 +1,4 @@
1#!/bin/sh1#!/bin/bash -x
22
3# We don't have to build a snap when we should use one from a channel3# Nothing to do here for the moment
4if [ -n "$SNAP_CHANNEL" ] ; then4exit 0
5 exit 0
6fi
7
8# If there is a snap prebuilt for us, lets take that one to speed things up
9if [ -e $PROJECT_PATH/${SNAP_NAME}_*_${SNAP_ARCH}.snap ] ; then
10 exit 0
11fi
12
13
14# Setup classic snap and build the snap in there
15snap install --devmode --beta classic
16cat <<-EOF > /home/test/build-snap.sh
17#!/bin/sh
18set -ex
19
20export DEBIAN_FRONTEND=noninteractive
21
22# FIXME: Enable propose for now until problems with conflicting systemd
23# packages between the Ubuntu Core image ppa and the archive are fixed.
24echo "deb http://archive.ubuntu.com/ubuntu/ xenial-proposed restricted main universe" > /etc/apt/sources.list.d/ubuntu-proposed.list
25echo "deb http://ppa.launchpad.net/snappy-dev/image/ubuntu xenial main" > /etc/apt/sources.list.d/ubuntu-image-ppa.list
26
27# Ensure we have the latest updates installed as the core snap
28# may be a bit out of date.
29apt update
30apt -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' full-upgrade -y --force-yes
31
32apt install -y --force-yes snapcraft
33cd $PROJECT_PATH
34snapcraft clean
35snapcraft
36EOF
37chmod +x /home/test/build-snap.sh
38sudo classic /home/test/build-snap.sh
39snap remove classic
40
41# Make sure we have a snap build
42test -e $PROJECT_PATH/${SNAP_NAME}_*_${SNAP_ARCH}.snap
diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh
index 185bacb..cdf9213 100644
--- a/tests/lib/prepare.sh
+++ b/tests/lib/prepare.sh
@@ -1,6 +1,7 @@
1#!/bin/sh1#!/bin/bash -ex
22
3. $TESTSLIB/utilities.sh3# shellcheck source=tests/lib/utilities.sh
4. "$TESTSLIB"/utilities.sh
45
5echo "Wait for firstboot change to be ready"6echo "Wait for firstboot change to be ready"
6while ! snap changes | grep -q "Done"; do7while ! snap changes | grep -q "Done"; do
@@ -10,9 +11,10 @@ while ! snap changes | grep -q "Done"; do
10done11done
1112
12echo "Ensure fundamental snaps are still present"13echo "Ensure fundamental snaps are still present"
13. $TESTSLIB/snap-names.sh14# shellcheck source=tests/lib/snap-names.sh
14for name in $gadget_name $kernel_name $core_name; do15. "$TESTSLIB"/snap-names.sh
15 if ! snap list | grep -q $name ; then16for name in "$gadget_name" "$kernel_name" "$core_name"; do
17 if ! snap list | grep -q "$name" ; then
16 echo "Not all fundamental snaps are available, all-snap image not valid"18 echo "Not all fundamental snaps are available, all-snap image not valid"
17 echo "Currently installed snaps:"19 echo "Currently installed snaps:"
18 snap list20 snap list
@@ -22,13 +24,6 @@ done
2224
23install_snap_under_test25install_snap_under_test
2426
25# Snapshot of the current snapd state for a later restore
26if [ ! -f $SPREAD_PATH/snapd-state.tar.gz ] ; then
27 systemctl stop snapd.service snapd.socket
28 tar czf $SPREAD_PATH/snapd-state.tar.gz /var/lib/snapd /etc/netplan
29 systemctl start snapd.socket
30fi
31
32# For debugging dump all snaps and connected slots/plugs27# For debugging dump all snaps and connected slots/plugs
33snap list28snap list
34snap interfaces29snap connections --all
diff --git a/tests/lib/restore-each.sh b/tests/lib/restore-each.sh
index 5b62c4b..deea076 100644
--- a/tests/lib/restore-each.sh
+++ b/tests/lib/restore-each.sh
@@ -1,12 +1,13 @@
1#!/bin/sh1#!/bin/bash -ex
22
3. $TESTSLIB/snap-names.sh3# shellcheck source=tests/lib/snap-names.sh
4. "$TESTSLIB"/snap-names.sh
45
5# Remove all snaps not being the core, gadget, kernel or snap we're testing6# Remove all snaps not being the core, gadget, kernel or snap we're testing
6for snap in /snap/*; do7for snap in /snap/*; do
7 snap="${snap:6}"8 snap="${snap:6}"
8 case "$snap" in9 case "$snap" in
9 "bin" | "$gadget_name" | "$kernel_name" | core* | "$SNAP_NAME" )10 README | bin | "$gadget_name" | "$kernel_name" | core* | snapd | "$SNAP_NAME")
10 ;;11 ;;
11 *)12 *)
12 snap remove "$snap"13 snap remove "$snap"
@@ -16,16 +17,9 @@ done
1617
17# Cleanup all configuration files from ModemManager so that we have18# Cleanup all configuration files from ModemManager so that we have
18# a fresh start for the next test19# a fresh start for the next test
20systemctl stop snap.modem-manager.modemmanager
19rm -rf /var/snap/modem-manager/common/*21rm -rf /var/snap/modem-manager/common/*
20rm -rf /var/snap/modem-manager/current/*22rm -rf /var/snap/modem-manager/current/*
21systemctl stop snap.modem-manager.modemmanager
22
23# Ensure we have the same state for snapd as we had before
24systemctl stop snapd.service snapd.socket
25rm -rf /var/lib/snapd/*
26$(cd / && tar xzf $SPREAD_PATH/snapd-state.tar.gz)
27rm -rf /root/.snap
28systemctl start snapd.service snapd.socket
2923
30# Bringup ModemManager again now that the system is restored24# Bringup ModemManager again now that the system is restored
31systemctl start snap.modem-manager.modemmanager25systemctl start snap.modem-manager.modemmanager
diff --git a/tests/lib/snap-names.sh b/tests/lib/snap-names.sh
index 71c9628..f15b09a 100644
--- a/tests/lib/snap-names.sh
+++ b/tests/lib/snap-names.sh
@@ -1,4 +1,4 @@
1#!/bin/sh1#!/bin/bash
2gadget_name=$(snap list | sed -n 's/^\(pc\|pi[23]\|dragonboard\) .*/\1/p')2gadget_name=$(snap list | sed -n 's/^\(pc\|pi[23]\|dragonboard\) .*/\1/p')
3kernel_name=$gadget_name-kernel3kernel_name=$gadget_name-kernel
4core_name=$(snap list | awk '/^(ubuntu-)?core / {print $1; exit}')4core_name=$(snap list | awk '/^(ubuntu-)?core / {print $1; exit}')
diff --git a/tests/lib/utilities.sh b/tests/lib/utilities.sh
index f756f66..f0aa6d7 100644
--- a/tests/lib/utilities.sh
+++ b/tests/lib/utilities.sh
@@ -8,7 +8,7 @@ wait_for_modem_manager() {
8}8}
99
10stop_after_first_reboot() {10stop_after_first_reboot() {
11 if [ $SPREAD_REBOOT -eq 1 ] ; then11 if [ "$SPREAD_REBOOT" -eq 1 ] ; then
12 exit 012 exit 0
13 fi13 fi
14}14}
@@ -18,22 +18,22 @@ install_snap_under_test() {
18 # without any network connectivity after reboot.18 # without any network connectivity after reboot.
19 if [ -n "$SNAP_CHANNEL" ] ; then19 if [ -n "$SNAP_CHANNEL" ] ; then
20 # Don't reinstall if we have it installed already20 # Don't reinstall if we have it installed already
21 if ! snap list | grep $SNAP_NAME ; then21 if ! snap list | grep "$SNAP_NAME"; then
22 snap install --$SNAP_CHANNEL $SNAP_NAME22 snap install --"$SNAP_CHANNEL" "$SNAP_NAME"
23 fi23 fi
24 else24 else
25 # Install first from store to avoid error when performing the connection25 # Install first from store to avoid error when performing the connection
26 snap install $SNAP_NAME26 snap install "$SNAP_NAME"
27 # Install prebuilt snap27 # Install prebuilt snap
28 snap install --dangerous ${PROJECT_PATH}/${SNAP_NAME}_*_${SNAP_ARCH}.snap28 snap install --dangerous "$PROJECT_PATH"/"$SNAP_NAME"_*_"$SNAP_ARCH".snap
29 if [ -n "$SNAP_AUTO_ALIASES" ]; then29 if [ -n "$SNAP_AUTO_ALIASES" ]; then
30 snapd_version=$(snap version | awk '/^snapd / {print $2; exit}')30 snapd_version=$(snap version | awk '/^snapd / {print $2; exit}')
31 for alias in $SNAP_AUTO_ALIASES ; do31 for alias in $SNAP_AUTO_ALIASES ; do
32 target=$SNAP_NAME.$alias32 target="$SNAP_NAME".$alias
33 if dpkg --compare-versions $snapd_version lt 2.25 ; then33 if dpkg --compare-versions "$snapd_version" lt 2.25 ; then
34 target=$SNAP_NAME34 target="$SNAP_NAME"
35 fi35 fi
36 snap alias $target $alias36 snap alias "$target" "$alias"
37 done37 done
38 fi38 fi
39 fi39 fi
diff --git a/tests/main/network-manager-autoconn/task.yaml b/tests/main/network-manager-autoconn/task.yaml
index 7092b7f..23cff72 100644
--- a/tests/main/network-manager-autoconn/task.yaml
+++ b/tests/main/network-manager-autoconn/task.yaml
@@ -6,8 +6,12 @@ execute: |
6 # Service should be up an running6 # Service should be up an running
7 wait_for_modem_manager7 wait_for_modem_manager
88
9 snap install network-manager9 snap install --channel=20/beta network-manager
1010
11 # Ensure all necessary plugs/slots are connected11 # Ensure all necessary plugs/slots are connected
12 snap interfaces | grep -Ezq "modem-manager:service .*modem-manager:mmcli"12 snap interfaces | grep -Ezq "modem-manager:service .*modem-manager:mmcli"
13 snap interfaces | grep -Ezq "modem-manager:service .*network-manager:modem-manager"13 snap interfaces | grep -Ezq "modem-manager:service .*network-manager:modem-manager"
14
15 # Set renderer back to networkd
16 snap set network-manager defaultrenderer=false
17 sleep 2

Subscribers

People subscribed via source and target branches