forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cursor_seek_fallback option (elastic#9234)
New option is introduced to configure the fallback method of seek mode `"cursor"`. The option is named `cursor_seek_fallback`. The name is taken from the community Journalbeat: https://github.com/mheese/journalbeat/blob/master/config/journalbeat.yml#L3 By default it seeks to the beginning as before. But from now on it is possible to configure it to start reading from the end of the journal.
- Loading branch information
Showing
9 changed files
with
71 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,7 @@ def test_start_with_local_journal(self): | |
) | ||
journalbeat_proc = self.start_beat() | ||
|
||
self.wait_until(lambda: self.log_contains( | ||
"journalbeat is running"), max_timeout=10) | ||
self.wait_until(lambda: self.log_contains("journalbeat is running")) | ||
|
||
exit_code = journalbeat_proc.kill_and_wait() | ||
assert exit_code == 0 | ||
|
@@ -33,6 +32,7 @@ def test_start_with_journal_directory(self): | |
|
||
self.render_config_template( | ||
journal_path=self.beat_path + "/tests/system/input/", | ||
seek_method="tail", | ||
path=os.path.abspath(self.working_dir) + "/log/*" | ||
) | ||
journalbeat_proc = self.start_beat() | ||
|
@@ -78,6 +78,35 @@ def test_start_with_selected_journal_file(self): | |
exit_code = journalbeat_proc.kill_and_wait() | ||
assert exit_code == 0 | ||
|
||
@unittest.skipUnless(sys.platform.startswith("linux"), "Journald only on Linux") | ||
def test_start_with_selected_journal_file_with_cursor_fallback(self): | ||
""" | ||
Journalbeat is able to open a journal file and start to read it from the position configured by seek and cursor_seek_fallback. | ||
""" | ||
|
||
self.render_config_template( | ||
journal_path=self.beat_path + "/tests/system/input/test.journal", | ||
seek_method="cursor", | ||
cursor_seek_fallback="tail", | ||
path=os.path.abspath(self.working_dir) + "/log/*" | ||
) | ||
journalbeat_proc = self.start_beat() | ||
|
||
required_log_snippets = [ | ||
# journalbeat can be started | ||
"journalbeat is running", | ||
# journalbeat can seek to the position defined in cursor_seek_fallback. | ||
"Seeking method set to cursor, but no state is saved for reader. Starting to read from the end", | ||
# message can be read from test journal | ||
"\"message\": \"thinkpad_acpi: please report the conditions when this event happened to [email protected]\"", | ||
] | ||
for snippet in required_log_snippets: | ||
self.wait_until(lambda: self.log_contains(snippet), | ||
name="Line in '{}' Journalbeat log".format(snippet)) | ||
|
||
exit_code = journalbeat_proc.kill_and_wait() | ||
assert exit_code == 0 | ||
|
||
@unittest.skipUnless(sys.platform.startswith("linux"), "Journald only on Linux") | ||
def test_read_events_with_existing_registry(self): | ||
""" | ||
|