From 952893411e54e270bade862bf81eaf48a8667e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9mi=20V=C3=A1nyi?= Date: Wed, 29 Jul 2020 14:02:47 +0200 Subject: [PATCH] Enable and fix Journalbeat integration tests (#20140) (#20154) (cherry picked from commit 2025662bade8710705361aaa150e54dfc7e452bc) --- journalbeat/Makefile | 2 +- journalbeat/input/input.go | 4 +- journalbeat/tests/system/input/test.journal | Bin 8388608 -> 8388608 bytes journalbeat/tests/system/input/test.registry | 6 +- journalbeat/tests/system/test_base.py | 72 ++++--------------- libbeat/tests/system/beat/beat.py | 15 ++++ 6 files changed, 33 insertions(+), 66 deletions(-) diff --git a/journalbeat/Makefile b/journalbeat/Makefile index 62bf3778d21..85049183d4e 100644 --- a/journalbeat/Makefile +++ b/journalbeat/Makefile @@ -1,6 +1,6 @@ BEAT_NAME=journalbeat BEAT_TITLE=Journalbeat -SYSTEM_TESTS=false +SYSTEM_TESTS=true TEST_ENVIRONMENT=false ES_BEATS?=.. diff --git a/journalbeat/input/input.go b/journalbeat/input/input.go index f8cbf1fbf73..b45b99d1816 100644 --- a/journalbeat/input/input.go +++ b/journalbeat/input/input.go @@ -79,7 +79,7 @@ func New( state := states[cfg.CheckpointID] r, err := reader.NewLocal(cfg, done, state, logger) if err != nil { - return nil, fmt.Errorf("error creating reader for local journal: %v", err) + return nil, fmt.Errorf("error creating reader for local journal: %+v", err) } readers = append(readers, r) } @@ -99,7 +99,7 @@ func New( state := states[cfg.CheckpointID] r, err := reader.New(cfg, done, state, logger) if err != nil { - return nil, fmt.Errorf("error creating reader for journal: %v", err) + return nil, fmt.Errorf("error creating reader for journal: %+v", err) } readers = append(readers, r) } diff --git a/journalbeat/tests/system/input/test.journal b/journalbeat/tests/system/input/test.journal index 887d49179056bdc21618db72fa1d6ddd2653418b..c42b825e62dcb7e934e0dc17cc218e46de463a66 100644 GIT binary patch delta 32275 zcmeHw3w%^XviAugFmjZQKmg_8@LUi`=KTPp3CRQkfy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_nvp} zx%d9gxxagFb#-<3YWS0<78f|I))K1*e%;_tn<&6<_t-0+&S)x}x~AtEm##Gbdc)qC^%-&fj~q~BXy+hiTRqEUB!i7WG5oVn2$ z?#szitC1O6>-4O^29h-`eOZ0QPwYb$t7@J@JT{gUnh*^KS-aFblQ;G$OVP-eT}k|S z*8TWEXqt-sdLk0^!9ogRYjWJr|C(51&>FZAdzn|jnhxD5u6Q4-18$2M52kQu&;SUA zQ##JPpS1u4!}4xiGr9l-L%WWvYGf?{w{_@Jw4D9`GXTOMn>c?1s{=y4ojZdr0ipgw zO^Z>li`VIw#f&>+Ms3z8?u%yD0WdLUUv9z)W&li#`8H=jmw;ecyOyg*x&XoOPM{aA zLz7&`rQy8}F%OzUiSL`*xoT_x2!`duxqW+B3qUX|n9tSW7=U0%DdJWiVJ!f`aB4iK z$CU$uVR`{qj|MkXCBSM&2vS@8$NV~x0EXgZ!6x&OjxpSpxND3-n#)MaOK#bBD6NZgTU4FHyZ{x}> z21Pr8>I=^)e~-yo$i18+}#c2myrBd(|nbTKZSl; zlj3fL=|K)DD_ey@#k9^?bJKSvyJ}ZacS3Tri`?J`N10=)eX`3o$x`IBy=}9U(CYOu zf!9HjDF?*togzc-7iMnjRrdGp=I6HPLQ&0tvaVn=-u~vmp9RIbP8xX1KkQ zDO>bqmuE^obGhhaj+FC%2t#Gs8Pu5~8pP4ot@(1Ab4rhUG&mtmVgzbUX9gDL`8sRz;9p$z=v?@)Fa8h zaCD9|CL~oRrlij9!-$o3udoi-R~Wf#}BY?F|a zk&~q+^$3#M1K$b;d@HDrj~-+BQw`e7PBp2diFjJbTe@PIH18>ni{xU7bh=R!6A$lv zWsgDZr2{rPDekO1eEt2g;j{IF3ilF^*cDHd-DWjw^g>p@gw@%d)o|k0?(tjSQ?sT@ zW_g49^7FI@qM9{I6OsseH4zh(-Rza1jPXEr0~ diff --git a/journalbeat/tests/system/input/test.registry b/journalbeat/tests/system/input/test.registry index 5c6680edb42..9b9dee108b3 100644 --- a/journalbeat/tests/system/input/test.registry +++ b/journalbeat/tests/system/input/test.registry @@ -1,6 +1,6 @@ update_time: 2018-09-11T10:06:50.895829905Z journal_entries: - path: /home/n/go/src/github.com/elastic/beats/journalbeat/tests/system/input/test.journal - cursor: s=7d22fd7aa0c7482d88c303f47d5f32dc;i=2fcb;b=902dc834f07d4f41ade064f6b2ef8b4f;m=1bf0ff5c6d;t=55913a25fe765;x=c7e6480eec30822b - realtime_timestamp: 1505315746998117 - monotonic_timestamp: 120007384173 + cursor: s=018329e08e3a45a0ae03694421c4f553;i=2015d;b=fa3c2e3080dc4cd5be5cb5a43e140d51;m=29102136a4;t=5ab0792b1dc62;x=84a1467480b8f1af + realtime_timestamp: 1595423897803874 + monotonic_timestamp: 176364271268 diff --git a/journalbeat/tests/system/test_base.py b/journalbeat/tests/system/test_base.py index a94d4a7473c..ad3c133a422 100644 --- a/journalbeat/tests/system/test_base.py +++ b/journalbeat/tests/system/test_base.py @@ -44,19 +44,14 @@ def test_start_with_journal_directory(self): ) journalbeat_proc = self.start_beat() - required_log_snippets = [ - # journalbeat can be started - "journalbeat is running", - # journalbeat can seek to the position defined in the cursor - "Tailing the journal file", - ] - for snippet in required_log_snippets: - self.wait_until(lambda: self.log_contains(snippet), - name="Line in '{}' Journalbeat log".format(snippet)) + self.wait_until(lambda: self.log_contains("journalbeat is running")) exit_code = journalbeat_proc.kill_and_wait() assert exit_code == 0 + # journalbeat is tailing an inactive journal + assert self.output_is_empty() + @unittest.skipUnless(sys.platform.startswith("linux"), "Journald only on Linux") def test_start_with_selected_journal_file(self): """ @@ -73,17 +68,7 @@ def test_start_with_selected_journal_file(self): ) journalbeat_proc = self.start_beat() - required_log_snippets = [ - # journalbeat can be started - "journalbeat is running", - # journalbeat can seek to the position defined in the cursor - "Reading from the beginning of the journal file", - # message can be read from test journal - "\"message\": \"thinkpad_acpi: unhandled HKEY event 0x60b0\"", - ] - for snippet in required_log_snippets: - self.wait_until(lambda: self.log_contains(snippet), - name="Line in '{}' Journalbeat log".format(snippet)) + self.wait_until(lambda: self.output_has(lines=23)) exit_code = journalbeat_proc.kill_and_wait() assert exit_code == 0 @@ -105,21 +90,14 @@ def test_start_with_selected_journal_file_with_cursor_fallback(self): ) 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 ibm-acpi-devel@lists.sourceforge.net\"", - ] - for snippet in required_log_snippets: - self.wait_until(lambda: self.log_contains(snippet), - name="Line in '{}' Journalbeat log".format(snippet)) + self.wait_until(lambda: self.log_contains("journalbeat is running")) exit_code = journalbeat_proc.kill_and_wait() assert exit_code == 0 + # journalbeat is tailing an inactive journal with no cursor data + assert self.output_is_empty() + @unittest.skipUnless(sys.platform.startswith("linux"), "Journald only on Linux") def test_read_events_with_existing_registry(self): """ @@ -142,19 +120,7 @@ def test_read_events_with_existing_registry(self): ) journalbeat_proc = self.start_beat() - required_log_snippets = [ - # journalbeat can be started - "journalbeat is running", - # journalbeat can seek to the position defined in the cursor - "Seeked to position defined in cursor", - # message can be read from test journal - "please report the conditions when this event happened to", - # only one event is read and published - 'journalbeat successfully published events\t{"event.count": 1}', - ] - for snippet in required_log_snippets: - self.wait_until(lambda: self.log_contains(snippet), - name="Line in '{}' Journalbeat log".format(snippet)) + self.wait_until(lambda: self.output_has(lines=9)) exit_code = journalbeat_proc.kill_and_wait() assert exit_code == 0 @@ -172,27 +138,13 @@ def test_read_events_with_include_matches(self): ], "seek": "head", "include_matches": [ - "syslog.priority=5", + "syslog.priority=6", ] }], ) journalbeat_proc = self.start_beat() - required_log_snippets = [ - # journalbeat can be started - "journalbeat is running", - # journalbeat can seek to the position defined in the cursor - "Added matcher expression", - # message can be read from test journal - "unhandled HKEY event 0x60b0", - "please report the conditions when this event happened to", - "unhandled HKEY event 0x60b1", - # Four events with priority 5 is publised - 'journalbeat successfully published events\t{"event.count": 4}', - ] - for snippet in required_log_snippets: - self.wait_until(lambda: self.log_contains(snippet), - name="Line in '{}' Journalbeat log".format(snippet)) + self.wait_until(lambda: self.output_has(lines=6)) exit_code = journalbeat_proc.kill_and_wait() assert exit_code == 0 diff --git a/libbeat/tests/system/beat/beat.py b/libbeat/tests/system/beat/beat.py index 65e0a6d5ad5..199f8b2c23a 100644 --- a/libbeat/tests/system/beat/beat.py +++ b/libbeat/tests/system/beat/beat.py @@ -488,6 +488,21 @@ def output_has(self, lines, output_file=None): except IOError: return False + def output_is_empty(self, output_file=None): + """ + Returns true if the output is empty. + """ + + # Init defaults + if output_file is None: + output_file = "output/" + self.beat_name + + try: + with open(os.path.join(self.working_dir, output_file, ), "r", encoding="utf_8") as f: + return len([1 for line in f]) == 0 + except IOError: + return True + def output_has_message(self, message, output_file=None): """ Returns true if the output has the given message field.