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
|
summary: |
Test that configuration defaults are only applied once.
details: |
Checks that configuration defaults are only applied once, and
those are not applied when a snap is installed, which could
trigger system defaults to be reapplied.
# it is not yet possible to install snapd on UC16
# TODO:UC20: enable for UC20, currently fails because there is no seed.yaml in
# the same place as UC18
systems: [ubuntu-core-18-*]
environment:
GADGET_FILE: gadget-defaults.yaml
prepare: |
if [ "$TRUST_TEST_KEYS" = "false" ]; then
echo "This test needs test keys to be trusted"
exit
fi
#shellcheck source=tests/lib/core-config.sh
. "$TESTSLIB"/core-config.sh
systemctl stop snapd.service snapd.socket
clean_snapd_lib
# Configure the pc snap
unpack_pc_snap
# Update the gadget config file
cat "$GADGET_FILE" >> squashfs-root/meta/gadget.yaml
pack_pc_snap
# Generic setup for test account
# shellcheck disable=SC2119
prepare_and_manip_seed
prepare_test_account developer1
prepare_testrootorg_store
# kick first boot again
systemctl start snapd.service snapd.socket
# wait for first boot to be done
wait_for_first_boot_change
restore: |
if [ "$TRUST_TEST_KEYS" = "false" ]; then
echo "This test needs test keys to be trusted"
exit
fi
#shellcheck source=tests/lib/core-config.sh
. "$TESTSLIB"/core-config.sh
# XXX: this should work once it is possible to install snapd on core
SNAP=snapd
SERVICES="ssh rsyslog"
if os.query is-core18; then
# a core18 already has a snapd snap, verify whether installation of core
# does not break the configuration
SNAP=core
SERVICES=ssh
fi
echo "Undo the service disable"
rm -f /etc/ssh/sshd_not_to_be_run
for service in $SERVICES; do
systemctl unmask "$service.service" || true
systemctl enable "$service.service" || true
systemctl start "$service.service" || true
done
systemctl stop snapd.service snapd.socket
clean_snapd_lib
# Restore pc snap configuration
restore_pc_snap
REVNO="$(readlink /snap/$SNAP/current)"
sysp=$(systemd-escape --path "/snap/$SNAP/$REVNO.mount")
if systemctl status "$sysp"; then
systemctl stop "$sysp"
rm -f "/etc/systemd/system/$sysp"
rm -f "/etc/systemd/system/multi-user.target.wants/$sysp"
rm -f "/etc/systemd/system/snapd.mounts.target.wants/$sysp"
rm -f "/var/lib/snapd/snaps/${SNAP}"_*.snap
rm -rf "/snap/$SNAP"
systemctl daemon-reload
fi
rm -f "/var/lib/snapd/seed/snaps/${SNAP}"_*.snap
rm -f "/var/lib/snapd/seed/assertions/${SNAP}"_*.assert
# Generic restore for test account
restore_updated_seed
restore_test_account developer1
restore_testrootorg_store
# kick first boot again
systemctl start snapd.service snapd.socket
# wait for first boot to be done
wait_for_first_boot_change
execute: |
if [ "$TRUST_TEST_KEYS" = "false" ]; then
echo "This test needs test keys to be trusted"
exit
fi
# XXX: this should work once it is possible to install snapd on core
SNAP=snapd
SERVICES="ssh rsyslog"
if os.query is-core18; then
# a core18 already has a snapd snap, verify whether installation of core
# does not break the configuration
SNAP=core
SERVICES=ssh
fi
echo "The defaults are applied"
for service in $SERVICES; do
snap get system "service.$service.disable" | MATCH true
systemctl status "$service.service" | MATCH '(inactive|masked)'
done
MATCH "SSH has been disabled by snapd system configuration" < /etc/ssh/sshd_not_to_be_run
for service in $SERVICES; do
snap set system "service.$service.disable"=false
done
# install a snap that could trigger system defaults to be reapplied
snap install "$SNAP"
# services are still not-disabled
for service in $SERVICES; do
snap get system "service.$service.disable" | MATCH false
done
test ! -e /etc/ssh/sshd_not_to_be_run
# Unmask rsyslog service on core18
if os.query is-core18; then
systemctl unmask rsyslog
fi
|