Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test case to reproduce panic on Filebeat shutdown #1454

Merged
merged 1 commit into from
Apr 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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