Files
snapd/tests/main/listing/task.yaml
Sergio Cazzolato 79f717ba8c tests: moving out google machines from us-east1-b (#13992)
* tests: moving out google machines from us-east1-b

The region us-east1 is shared among project. In order to avoid reaching
the instances quota we are moving out to europe regions.
The idea of moving to europe is because the CI is in the UK.

From now, we will have 5 regions for snapd (4 in europe and 1 in the USA
for sru and nested)

* update checks in tests

check the name google is in SPREAD_BACKEND
2024-05-22 23:07:57 +02:00

95 lines
3.5 KiB
YAML

summary: Check snap listings
details: |
Check the output of command `snap list` is the expected based on the current systems
prepare: |
"$TESTSTOOLS"/snaps-state install-local test-snapd-sh
snap set system experimental.parallel-instances=true
"$TESTSTOOLS"/snaps-state install-local-as test-snapd-sh test-snapd-sh_foo
restore: |
snap set system experimental.parallel-instances=null
execute: |
echo "List prints core snap version"
# most core versions should be like "16-2", so [0-9]{2}-[0-9.]+
# but edge will have a timestamp in there, "16.2+201701010932", so add an optional \+[0-9]+ to the end
# *current* edge also has .git. and a hash snippet, so add an optional .git.[0-9a-f]+ to the already optional timestamp
# Expressions for version and revision
NUMERIC_VERSION="[0-9]+(\.[0-9]+)*"
CORE_GIT_VERSION="[0-9]{2}-[0-9.]+(~[a-z0-9]+)?(\\+git[0-9]+\\.[0-9a-f]+)?"
SNAPD_GIT_VERSION="+[0-9.]+(~[a-z0-9]+)?(\\+git[0-9]+\\.[0-9a-z]+)?(-dirty)?"
FINAL_VERSION="[0-9]{2}-[0-9.]+(~[a-z0-9]+)?(\\+[0-9]+\\.[0-9a-f]+)?"
SIDELOAD_REV="x[0-9]+"
NUMBER_REV="[0-9]+"
# Default values
NAME=core
VERSION=$CORE_GIT_VERSION
REV=$NUMBER_REV
PUBLISHER="canonical\\*\\*"
TRACKING=-
NOTES=core
#shellcheck disable=SC2166
if [[ "$SPREAD_BACKEND" =~ google ]] || [ "$SPREAD_BACKEND" == "qemu" ] && os.query is-core16; then
echo "With customized images the core snap is sideloaded"
REV=$SIDELOAD_REV
PUBLISHER=-
elif [[ "$SPREAD_BACKEND" =~ google ]] || [ "$SPREAD_BACKEND" == "qemu" ] && os.query is-core-ge 18; then
echo "With customized images the snapd snap is sideloaded"
NAME=snapd
VERSION=$SNAPD_GIT_VERSION
REV=$SIDELOAD_REV
PUBLISHER=-
NOTES=snapd
elif [ "$SRU_VALIDATION" = "1" ] || [ -n "$PPA_VALIDATION_NAME" ]; then
echo "When either sru or ppa validation is done the core snap is installed from the store"
VERSION=$FINAL_VERSION
TRACKING="(latest/)?stable"
elif [ "$SPREAD_BACKEND" = "external" ] && os.query is-core16; then
echo "On the external device the core snap tested could be in any track"
TRACKING="(latest/)?(edge|beta|candidate|stable)"
elif [ "$SPREAD_BACKEND" = "external" ] && os.query is-core-ge 18; then
echo "On the external device the snapd snap tested could be in any track"
NAME=snapd
VERSION=$SNAPD_GIT_VERSION
TRACKING="(latest/)?(edge|beta|candidate|stable)"
NOTES=snapd
else
TRACKING="(latest/)?$CORE_CHANNEL"
fi
expected="^$NAME +$VERSION +$REV +$TRACKING +$PUBLISHER +$NOTES.*$"
snap list --unicode=never | MATCH "$expected"
echo "List prints installed snaps and versions"
snap list | MATCH "^test-snapd-sh +$NUMERIC_VERSION +$SIDELOAD_REV +- +- +- *$"
snap list | MATCH "^test-snapd-sh_foo +$NUMERIC_VERSION +$SIDELOAD_REV +- +- +- *$"
echo "Install test-snapd-sh again"
"$TESTSTOOLS"/snaps-state install-local test-snapd-sh
echo "And run snap list --all"
output=$(snap list --all | grep 'test-snapd-sh ')
if [ "$(grep -c test-snapd-sh <<< "$output")" != "2" ]; then
echo "Expected two test-snapd-sh in the output, got:"
echo "$output"
exit 1
fi
if [ "$(grep -c disabled <<< "$output")" != "1" ]; then
echo "Expected one disabled line in in the output, got:"
echo "$output"
exit 1
fi
snap list --all | MATCH 'test-snapd-sh_foo '