Compare commits
4 Commits
dca9bbfac9
...
f72458db0d
Author | SHA1 | Date |
---|---|---|
Philip Meulengracht | f72458db0d | |
Philip Meulengracht | 684f4d25c8 | |
Philip Meulengracht | edcbc020fb | |
Philip Meulengracht | ee1d8dc924 |
|
@ -1320,9 +1320,6 @@ int server_flush_to_var(Server *s, bool require_flag_file) {
|
||||||
if (!IN_SET(s->storage, STORAGE_AUTO, STORAGE_PERSISTENT))
|
if (!IN_SET(s->storage, STORAGE_AUTO, STORAGE_PERSISTENT))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (s->namespace) /* Flushing concept does not exist for namespace instances */
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!s->runtime_journal) /* Nothing to flush? */
|
if (!s->runtime_journal) /* Nothing to flush? */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
../TEST-01-BASIC/Makefile
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
set -e
|
||||||
|
|
||||||
|
TEST_DESCRIPTION="test flushing log namespaces"
|
||||||
|
|
||||||
|
# shellcheck source=test/test-functions
|
||||||
|
. "${TEST_BASE_DIR:?}/test-functions"
|
||||||
|
|
||||||
|
do_test "$@"
|
|
@ -0,0 +1,13 @@
|
||||||
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
[Unit]
|
||||||
|
Description=TESTSUITE-77-FLUSH-LOG-NAMESPACES
|
||||||
|
Before=getty-pre.target
|
||||||
|
Wants=getty-pre.target
|
||||||
|
Wants=systemd-journald@foobar.socket systemd-journald-varlink@foobar.socket
|
||||||
|
After=systemd-journald@foobar.socket systemd-journald-varlink@foobar.socket
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStartPre=rm -f /failed /testok
|
||||||
|
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
|
||||||
|
Type=oneshot
|
||||||
|
LogTarget=foobar
|
|
@ -0,0 +1,56 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
# first test is to make sure that /var/log/journal is not created
|
||||||
|
# by starting a new journal namespace if the journald config has
|
||||||
|
# Storage=auto
|
||||||
|
cat << EOF > /etc/systemd/journald@foobar.conf
|
||||||
|
[Journal]
|
||||||
|
Storage=auto
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# for the above to work, we need to use a service drop-in to override
|
||||||
|
# the default LogsDirectory, otherwise Storage=auto will not work.
|
||||||
|
mkdir -p /etc/systemd/system/systemd-journald@foobar.service.d
|
||||||
|
cat << EOF > /etc/systemd/system/systemd-journald@foobar.service.d/00-test.conf
|
||||||
|
[Service]
|
||||||
|
LogsDirectory=
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# reload systemd to detect the new drop-in
|
||||||
|
systemctl daemon-reload
|
||||||
|
|
||||||
|
# ensure /var/log/journal does not exist
|
||||||
|
rm -rf /var/log/journal
|
||||||
|
|
||||||
|
systemd-run --wait -p LogNamespace=foobar echo "hello world"
|
||||||
|
if [[ -d /var/log/journal ]]; then
|
||||||
|
echo "/var/log/journal was created with Storage=auto" >/failed
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# now the runtime journal should exist, and when we create the
|
||||||
|
# persistent journal path /var/log/journal, the runtime journal
|
||||||
|
# should be flushed and moved out of /run
|
||||||
|
# expect /var/log/journal/%m.foobar
|
||||||
|
mkdir -p /var/log/journal
|
||||||
|
MACHINE_ID=$(cat /etc/machine-id)
|
||||||
|
|
||||||
|
# allow a few seconds for the flush to occur due to machine speeds
|
||||||
|
WAS_FLUSHED=false
|
||||||
|
# shellcheck disable=SC2034,SC2015
|
||||||
|
for i in {1..5}; do [ -d "/var/log/journal/$MACHINE_ID.foobar" ] && WAS_FLUSHED=true && break || sleep 1; done
|
||||||
|
if ! $WAS_FLUSHED; then
|
||||||
|
echo "/var/log/journal/$MACHINE_ID.foobar did not get created" >/failed
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# after the flush of the runtime journal it should have been cleaned up
|
||||||
|
if [[ -d "/run/log/journal/$MACHINE_ID.foobar" ]]; then
|
||||||
|
echo "/run/log/journal/$MACHINE_ID.foobar was not flushed" >/failed
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo OK >/testok
|
||||||
|
exit 0
|
Loading…
Reference in New Issue