Documentation ¶
Overview ¶
Package fake implements a journal writer for testing which is decoupled from the system's journald.
The systemd project does not have any facilities to support testing of journal reader clients (although it has been requested: https://github.com/systemd/systemd/issues/14120) so we have to get creative. The systemd-journal-remote command reads serialized journal entries in the Journal Export Format and writes them to journal files. This format is well-documented and straightforward to generate.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCommandNotFound = errors.New("systemd-journal-remote command not found")
ErrCommandNotFound is returned when the systemd-journal-remote command could not be located at the well-known paths or $PATH.
Functions ¶
func JournalRemoteCmdPath ¶
JournalRemoteCmdPath searches for the systemd-journal-remote command in well-known paths and the directories named in the $PATH environment variable.
Types ¶
type Sender ¶
type Sender struct { CmdName string OutputPath string // Clock for timestamping sent messages. Clock clock.Clock // Whether to assign the event's realtime timestamp to the time // specified by the SYSLOG_TIMESTAMP variable value. This is roughly // analogous to journald receiving the event and assigning it a // timestamp in zero time after the SYSLOG_TIMESTAMP value was set, // which is highly unrealistic in practice. AssignEventTimestampFromSyslogTimestamp bool // Boot ID for journal entries. Required by systemd-journal-remote as of // https://github.com/systemd/systemd/commit/1eede158519e4e5ed22738c90cb57a91dbecb7f2 // (systemd 255). BootID uuid.UUID // When set, Send will act as a test helper and redirect // systemd-journal-remote command output to the test log. TB testing.TB }
Sender fakes github.com/coreos/go-systemd/v22/journal.Send, writing journal entries to an arbitrary journal file without depending on a running journald process.
func New ¶
New constructs a new Sender which will write journal entries to outpath. The file name must end in '.journal' and the directory must already exist. The journal file will be created if it does not exist. An existing journal file will be appended to.