Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: import changes from snapd-testing-tools #14528

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions tests/lib/external/snapd-testing-tools/spread.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ backends:
- centos-9-64:
storage: preserve-size
- opensuse-15.5-64:
- opensuse-15.6-64:
- opensuse-tumbleweed-64:

google-nested:
Expand All @@ -53,14 +54,18 @@ backends:
HTTPS_PROXY: 'http://squid.internal:3128'
NO_PROXY: 'canonical.com'
systems:
- ubuntu-20.04-64:
image: ubuntu-focal-20.04-amd64
- ubuntu-22.04-64:
image: ubuntu-jammy-22.04-amd64
- centos-9-64:
- debian-12-64:
image: snapd-spread/ubuntu-22.04-64
- ubuntu-24.04-64:
image: snapd-spread/ubuntu-24.04-64
- fedora-40-64:
image: snapd-spread/fedora-40-64
- opensuse-15.5-64:
image: snapd-spread/opensuse-15.5-64
- centos-9-64:
image: snapd-spread/centos-9-64
- debian-12-64:
image: snapd-spread/debian-12-64

path: /root/snapd-testing-tools

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ execute: |
os.query is-classic
! os.query is-core
;;

fedora-39-64)
os.query is-fedora
os.query is-fedora 39
Expand Down Expand Up @@ -149,6 +148,12 @@ execute: |
os.query is-classic
! os.query is-core
;;
opensuse-15.6-64)
os.query is-opensuse
os.query is-opensuse 15.6
os.query is-classic
! os.query is-core
;;
opensuse-tumbleweed-64)
os.query is-opensuse
os.query is-opensuse tumbleweed
Expand Down
19 changes: 19 additions & 0 deletions tests/lib/external/snapd-testing-tools/tests/tests.pkgs/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,25 @@ execute: |
not tests.pkgs is-installed test-snapd-pkg-1
not tests.pkgs is-installed test-snapd-pkg-2

# Download 2 packages, trusty does not support apt download
PKG1="grep"
PKG2="curl"
MAXDEPTH=1
if os.query is-opensuse; then
MAXDEPTH=4
fi
if os.query is-arch-linux || os.query is-fedora || os.query is-opensuse; then
PKG2="vi"
fi

if not os.query is-trusty; then
tests.pkgs download "$PKG1" "$PKG2"
if os.query is-opensuse; then
find . -maxdepth "$MAXDEPTH" -name "$PKG1*"
find . -maxdepth "$MAXDEPTH" -name "$PKG2*"
fi
fi

# Check the message when a command is not supported
tests.pkgs noexist test-snapd-pkg-1 2>&1 | MATCH 'tests.pkgs: unknown command noexist'
tests.pkgs -install test-snapd-pkg-1 2>&1 | MATCH 'tests.pkgs: unknown option -install'
Expand Down
12 changes: 11 additions & 1 deletion tests/lib/external/snapd-testing-tools/tools/tests.pkgs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
show_help() {
echo "usage: tests.pkgs install [--no-install-recommends] [PACKAGE...]"
echo " tests.pkgs remove [PACKAGE...]"
echo " tests.pkgs download [PACKAGE...]"
echo " tests.pkgs is-installed [PACKAGE]"
echo " tests.pkgs query [PACKAGE]"
echo " tests.pkgs list-installed"
Expand All @@ -27,6 +28,11 @@ cmd_install_local() {
unsupported
}

cmd_download() {
# This is re-defined by the backend file.
unsupported
}

cmd_is_installed() {
# This is re-defined by the backend file.
unsupported
Expand Down Expand Up @@ -120,7 +126,7 @@ main() {
shift
break
;;
install|remove|query|is-installed|list-installed)
install|remove|query|is-installed|list-installed|download)
action="$1"
shift
break # consume remaining arguments
Expand Down Expand Up @@ -154,6 +160,10 @@ main() {
# shellcheck disable=SC2046
cmd_remove $(remap_many "$@")
;;
download)
# shellcheck disable=SC2046
cmd_download $(remap_many "$@")
;;
*)
echo "tests.pkgs: unknown action $action" >&2
exit 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,7 @@ cmd_remove() {
# shellcheck disable=SC2086
apt-get remove --yes $REMOVE_FLAGS "$@"
}

cmd_download() {
apt download -q "$@" >/dev/null
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,11 @@ cmd_remove() {
yum remove -y $@
fi
}

cmd_download() {
if [ "$(command -v dnf)" != "" ]; then
dnf download -q "$@"
else
yum reinstall --downloadonly -q -y --downloaddir "${PWD:-.}" "$@"
fi
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ cmd_list_installed() {
}

cmd_remove() {
pacman -Rnsc --noconfirm "$@"
}

cmd_download() {
# shellcheck disable=SC2068
pacman -Rnsc --noconfirm $@
pacman -Sw --noconfirm --cachedir "${PWD:-.}" -q "$@" >/dev/null
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ cmd_list_installed() {
}

cmd_remove() {
# shellcheck disable=SC2068
zypper remove -y $@
zypper remove -y "$@"
}

cmd_download() {
zypper --pkg-cache-dir "${PWD:-.}" -q download "$@"
}
Loading