1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
summary: smoke test for the snaps-state tool
details: |
Check that the snaps-state tool allows packing and installing local snaps.
Verify that by default the tool tries to retrieve the snap from the local test,
and otherwise it tries from $TESTSLIB. Finally verifies that the confinement for
the current system can be checked
backends: [google, qemu]
prepare: |
snap set system experimental.parallel-instances=true
restore: |
snap set system experimental.parallel-instances=null
execute: |
SNAP_NAME=test-snapd-tools
SNAP_CLASSIC=test-snapd-classic-confinement
SNAP_DEVMODE=test-snapd-devmode
SNAP_JAILMODE=test-devmode-cgroup
# Check help
"$TESTSTOOLS"/snaps-state | MATCH "usage: pack-local <snap-name>"
"$TESTSTOOLS"/snaps-state -h | MATCH "usage: pack-local <snap-name>"
"$TESTSTOOLS"/snaps-state --help | MATCH "usage: pack-local <snap-name>"
# Pack a local snap by using the pack-local subcommand
snap_path=$("$TESTSTOOLS"/snaps-state pack-local "$SNAP_NAME")
snap install --dangerous "${snap_path}"
test-snapd-tools.echo test123 | MATCH "test123"
snap remove "$SNAP_NAME"
# Check the local snap file is already created
test -f "$TESTSLIB/snaps/${SNAP_NAME}/${SNAP_NAME}_1.0_all.snap"
rm -f "$TESTSLIB/snaps/${SNAP_NAME}/${SNAP_NAME}_1.0_all.snap"
# Try to pack a local snap which does not exist
"$TESTSTOOLS"/snaps-state pack-local SNAP_NO_EXIST 2>&1 | MATCH "snaps-state: can't pack SNAP_NO_EXIST, snap directory not found"
# Make and install a snap by using the install-local subcommand
snap_path=$("$TESTSTOOLS"/snaps-state install-local "$SNAP_NAME")
test-snapd-tools.echo test123 | MATCH "test123"
snap remove "$SNAP_NAME"
# Check the local snap file is already created
test -f "$TESTSLIB/snaps/${SNAP_NAME}/${SNAP_NAME}_1.0_all.snap"
# Make and install a snap when snap file is already created
snap_path=$("$TESTSTOOLS"/snaps-state install-local "$SNAP_NAME")
test-snapd-tools.echo test123 | MATCH "test123"
snap remove "$SNAP_NAME"
# Check the local snap file is already created
test -f "$TESTSLIB/snaps/${SNAP_NAME}/${SNAP_NAME}_1.0_all.snap"
rm -f "$TESTSLIB/snaps/${SNAP_NAME}/${SNAP_NAME}_1.0_all.snap"
# Make and install a snap by using the install-local-as subcommand
snap_path=$("$TESTSTOOLS"/snaps-state install-local-as "$SNAP_NAME" "$SNAP_NAME"_test)
test-snapd-tools_test.echo test123 | MATCH "test123"
snap remove "$SNAP_NAME"_test
rm -f "$TESTSLIB/snaps/${SNAP_NAME}/${SNAP_NAME}_test_1.0_all.snap"
# Make and install a snap by using the install-local subcommand with --devmode
snap_path=$("$TESTSTOOLS"/snaps-state install-local "$SNAP_DEVMODE" --devmode)
snap list "$SNAP_DEVMODE"
snap remove "$SNAP_DEVMODE"
rm -f "$TESTSLIB/snaps/${SNAP_DEVMODE}/${SNAP_DEVMODE}_1.0_all.snap"
# Make and install a snap by using the install-local subcommand with --classic
if snap debug sandbox-features --required=confinement-options:classic; then
snap_path=$("$TESTSTOOLS"/snaps-state install-local "$SNAP_CLASSIC" --classic)
snap list "$SNAP_CLASSIC" | MATCH 'classic$'
snap remove "$SNAP_CLASSIC"
rm -f "$TESTSLIB/snaps/${SNAP_CLASSIC}/${SNAP_CLASSIC}_1.0_all.snap"
fi
# Make and install a snap by using the install-local subcommand with --jailmode
if [ "$(snap debug confinement)" = strict ] ; then
snap_path=$("$TESTSTOOLS"/snaps-state install-local "$SNAP_JAILMODE" --jailmode)
snap list "$SNAP_JAILMODE" | MATCH 'jailmode$'
snap remove "$SNAP_JAILMODE"
rm -f "$TESTSLIB/snaps/${SNAP_JAILMODE}/${SNAP_JAILMODE}_1.0_all.snap"
fi
# Check the core, kernel and gadget snap name
core_name=$("$TESTSTOOLS"/snaps-state show-name core)
kernel_name=$("$TESTSTOOLS"/snaps-state show-name kernel)
gadget_name=$("$TESTSTOOLS"/snaps-state show-name gadget)
# Check the core revision
core_rev=$("$TESTSTOOLS"/snaps-state show-revision "$core_name")
snap info "$core_name" | grep "installed:" | MATCH "\($core_rev\)"
# Check the snap revision when it is not installed
"$TESTSTOOLS"/snaps-state show-revision not_installed 2>&1 | MATCH "snaps-state: the snap not_installed is not installed"
# Check the core, kernel and gadget snaps
snap list "$core_name"
if os.query is-core; then
snap list "$kernel_name"
snap list "$gadget_name"
else
test -z "$kernel_name"
test -z "$gadget_name"
fi
# check the command is-confinement-supported works
case "$SPREAD_SYSTEM" in
fedora-*)
not "$TESTSTOOLS"/snaps-state is-confinement-supported classic
not "$TESTSTOOLS"/snaps-state is-confinement-supported strict
"$TESTSTOOLS"/snaps-state is-confinement-supported devmode
;;
ubuntu-core-*)
not "$TESTSTOOLS"/snaps-state is-confinement-supported classic
"$TESTSTOOLS"/snaps-state is-confinement-supported strict
"$TESTSTOOLS"/snaps-state is-confinement-supported devmode
;;
ubuntu-*)
"$TESTSTOOLS"/snaps-state is-confinement-supported classic
"$TESTSTOOLS"/snaps-state is-confinement-supported strict
"$TESTSTOOLS"/snaps-state is-confinement-supported devmode
;;
esac
# Skip test repack when the sru validation is being executed, in this
# scenario the deb package used comes from the sru and repack is not done
if [ "$SRU_VALIDATION" = 1 ]; then
exit 0
fi
# Check the repack of the snapd deb into core and snapd snaps. This check is executed
# on ubuntu/debian systems where the snapd_*.deb is generated while the system is prepared
if ls "$GOHOME"/snapd_*.deb; then
"$TESTSTOOLS"/snaps-state repack-snapd-deb-into-snap core "$PWD"/core
test -e core/core-from-snapd-deb.snap
rm -rf core
cp "$GOHOME"/snapd_*.deb current_snapd.deb
"$TESTSTOOLS"/snaps-state repack-snapd-deb-into-snap core "$PWD"/core current_snapd.deb
test -e core/core-from-snapd-deb.snap
rm -rf core
"$TESTSTOOLS"/snaps-state repack-snapd-deb-into-snap core "$PWD"/core noexist.deb 2>&1 | MATCH "snaps-state: deb file used to repack not found: noexist.deb"
fi
# Check the repack of the core snap info snapd snap. This check is executed
# on any system with the core snap installed
if [ -d /snap/core/current ]; then
"$TESTSTOOLS"/snaps-state repack-core-snap-into-snapd-snap
test -e snapd-from-core.snap
rm snapd-from-core.snap
fi
snap download core --basename=core --edge
"$TESTSTOOLS"/snaps-state repack-core-snap-into-snapd-snap core.snap
test -e snapd-from-core.snap
rm snapd-from-core.snap
"$TESTSTOOLS"/snaps-state repack-core-snap-into-snapd-snap noexist.snap 2>&1 | MATCH "snaps-state: core snap used to repack not found: noexist.snap"
|