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
|
summary: Test journal.persistent core config option is honored by journal namespaces
details: |
In Ubuntu Core systems journal.persistent core config option can be used to
enable and disable the journal persistence. If persistent journals were previously
enabled by this setting, changing the value to false will delete all saved logs.
This test verifies that when journal.persistent core config is set to true, the
journal logs are written and those are deleted when the config is set to false.
Also it is verified that a journal quota group can be created, and the presence
of its corresponding namespace log.
# these systems do not support journal quota groups due to their old systemd versions.
# requires systemd v245+
systems:
- -ubuntu-core-16-*
- -ubuntu-core-18-*
prepare: |
"$TESTSTOOLS"/snaps-state install-local test-snapd-journal-quota
snap set system experimental.quota-groups=true
tests.cleanup defer snap unset system experimental.quota-groups
restore: |
# Stop test service and cleanup
snap stop test-snapd-journal-quota.logger || true
snap remove-quota group-one || true
# disable persistent journal and reload the journal
rm -rf /var/log/journal
systemctl kill --signal=SIGUSR1 systemd-journald
execute: |
echo "Wait for first boot to be done"
snap wait system seed.loaded
echo "Precondition check, persistent journal is not available by default"
not test -e /var/log/journal
echo "Check that persistent journal can be enabled"
snap set core journal.persistent=true
test -e /var/log/journal/
test -e /var/log/journal/.snapd-created
# Create a journal quota group and set arbitrary limits
echo "Create a journal namespace with the logger snap in it"
snap set-quota group-one --journal-size=16MB --journal-rate-limit=100/10ms test-snapd-journal-quota
# this check relies on *anything* getting logged; enabling persistent
# journal writes an entry about journal size, which should be sufficient.
MACHINE_ID=$(cat /etc/machine-id)
retry -n 30 --wait 1 test -e "/var/log/journal/$MACHINE_ID"
echo "Starting service to fill namespace with logs"
snap start test-snapd-journal-quota.logger
# Verify the presence of the namespace log, and do this with retries as
# the logger writes onces every second
retry -n 5 sh -c "test -e /var/log/journal/$MACHINE_ID.snap-group-one"
echo "Check that persistent journal can be disabled"
snap set core journal.persistent=false
not test -e /var/log/journal
# Verify that, over a few seconds, nothing is created
# to make sure the namespace is not recreating the path
if retry -n 2 sh -c "test -e /var/log/journal"; then
echo "Journal path was recreated, it shouldn't have happened"
exit 1
fi
# Restart the journal namespace service to make sure that the
# folder is not recreated once systemd starts it. See LP1912173
# for details.
systemctl restart systemd-journald@snap-group-one.service
# Verify the path was not recreated, this should have happened
# immediately, so no need for retries here
not test -e /var/log/journal/"$MACHINE_ID".snap-group-one
|