Skip to content

Commit

Permalink
Add test case to reproduce panic on Filebeat shutdown
Browse files Browse the repository at this point in the history
The test is skipped until elastic#964 is addressed.
  • Loading branch information
andrewkroh committed Apr 19, 2016
1 parent 79bd08a commit 811bf08
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 2 deletions.
1 change: 1 addition & 0 deletions filebeat/tests/files/logs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Ignore all temp files
tmp*
nasa-50k.log
Binary file added filebeat/tests/files/logs/nasa-50k.log.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion filebeat/tests/system/config/filebeat.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ output:
path: {{ output_file_path|default(beat.working_dir + "/output") }}
filename: "{{ output_file_filename|default("filebeat") }}"
rotate_every_kb: 1000
#number_of_files: 7
number_of_files: 2

{% if filter_enabled %}

Expand Down
39 changes: 39 additions & 0 deletions filebeat/tests/system/test_shutdown.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from filebeat import BaseTest
import gzip
import os
import time
import unittest

"""
Tests that Filebeat shuts down cleanly.
"""

class Test(BaseTest):
@unittest.skip("Needs fix from #964")
def test_shutdown(self):
"""
Test starting and stopping Filebeat under load.
"""

# Uncompress the nasa log file.
nasa_log = '../files/logs/nasa-50k.log'
if not os.path.isfile(nasa_log):
with gzip.open('../files/logs/nasa-50k.log.gz', 'rb') as infile:
with open(nasa_log, 'w') as outfile:
for line in infile:
outfile.write(line)

self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/*",
ignoreOlder="1h"
)

os.mkdir(self.working_dir + "/log/")
self.copy_files(["logs/nasa-50k.log"],
source_dir="../files",
target_dir="log")

for i in range(1,5):
proc = self.start_beat(logging_args=["-e", "-v"])
time.sleep(.5)
proc.check_kill_and_wait()
2 changes: 1 addition & 1 deletion libbeat/tests/system/beat/beat.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Proc(object):

def __init__(self, args, outputfile):
self.args = args
self.output = open(outputfile, "wb")
self.output = open(outputfile, "ab")

def start(self):
self.stdin_read, self.stdin_write = os.pipe()
Expand Down

0 comments on commit 811bf08

Please sign in to comment.