Skip to content

Commit

Permalink
Merge pull request #174 from ruflin/system-tail-test
Browse files Browse the repository at this point in the history
Add multi append system test.
  • Loading branch information
tsg committed Nov 3, 2015
2 parents a8e0e04 + c4bb347 commit f666404
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/system/config/filebeat.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ filebeat:
harvester_buffer_size:
tail_on_rotate: {{tailOnRotate}}
spool_size:
idle_timeout: 5s
idle_timeout: 0.5s
tail_on_rotate:
registry_file: {{ fb.working_dir + '/' }}{{ registryFile|default(".filebeat")}}


Expand Down
46 changes: 46 additions & 0 deletions tests/system/test_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,52 @@ def test_new_line_on_existing_file(self):
output = self.read_output()
assert len(output) == 3

def test_multiple_appends(self):
"""
Test that filebeat keeps picking up new lines
after appending multiple times
"""

self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/*"
)
os.mkdir(self.working_dir + "/log/")

testfile = self.working_dir + "/log/test.log"

filebeat = self.start_filebeat()

# Write initial file
with open(testfile, 'w') as f:
f.write("hello world\n")
f.flush()

self.wait_until(
lambda: self.log_contains(
"Registrar: processing 1 events"),
max_timeout=15)

for n in range(3):
with open(testfile, 'a') as f:

for i in range(0, 20 + n):
f.write("hello world " + str(i) + " " + str(n) + "\n")

f.flush()

self.wait_until(
lambda: self.log_contains(
"Registrar: processing " + str(20 + n) + " events"),
max_timeout=15)


filebeat.kill_and_wait()

# Check that output file has the same number of lines as the log file
output = self.read_output()
assert len(output) == (3 * 20 + sum(range(0, 3)) + 1)


def test_new_line_on_open_file(self):
"""
Checks that filebeat follows future writes to the same
Expand Down

0 comments on commit f666404

Please sign in to comment.