Skip to content

Commit

Permalink
Fix test for libsystemd v250 (#101)
Browse files Browse the repository at this point in the history
The latest libsystemd can read some corrupted entries without
errors.

Since libsystemd v250, it's specification against journal file
corruption changed.

https://github.com/systemd/systemd/blob/v250/NEWS#L807-L808

In AlmaLinux9 (libsystemd v250):

    require "systemd"
    require "systemd/journal"
    journal = Systemd::Journal.new(path: "test/fixture/corrupt")
    entries = journal.to_a # Succeeds without errors
    entries[2] # Before v250, it couldn't read this entry.
    => #<Systemd::JournalEntry:0x000000000003ba60 priority: '6',
    _boot_id: '4737ffc504774b3ba67020bc947f1bc0', _machine_id:
    'bb9d0a52a41243829ecd729b40ac0bce', _hostname: 'arch',
    _source_monotonic_timestamp: '0', _transport: 'kernel',
    syslog_identifier: 'kernel'>

Assuming both old and new libsystemd, it would be good to fix 
the test in this way.

Signed-off-by: Daijiro Fukuda <fukuda@clear-code.com>
  • Loading branch information
daipom committed Oct 16, 2023
1 parent 3ec3769 commit 67000f6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/plugin/test_in_systemd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,10 @@ def test_journal_not_present
end

def test_reading_from_a_journal_with_corrupted_entries
# One corrupted entry exists in 461 entries. (The 3rd entry is corrupted.)
d = create_driver(corrupt_entries_config)
d.run(expect_emits: 460)
assert_equal 460, d.events.size
# Since libsystemd v250, it can read this corrupted record.
assert { d.events.size == 460 or d.events.size == 461 }
end
end

0 comments on commit 67000f6

Please sign in to comment.