-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
prospector: cache resolved glob patterns during init #4269
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
#!/usr/bin/env python | ||
"""Test the registrar""" | ||
|
||
import os | ||
import platform | ||
import time | ||
import shutil | ||
|
||
from filebeat import BaseTest | ||
from nose.plugins.skip import SkipTest | ||
|
||
|
@@ -323,7 +325,7 @@ def test_rotating_file_inode(self): | |
|
||
def test_restart_continue(self): | ||
""" | ||
Check that file readining continues after restart | ||
Check that file reading continues after restart | ||
""" | ||
self.render_config_template( | ||
path=os.path.abspath(self.working_dir) + "/log/input*", | ||
|
@@ -1396,3 +1398,8 @@ def test_registrar_files_with_prospector_level_processors(self): | |
"inode": stat.st_ino, | ||
"device": stat.st_dev, | ||
}, file_state_os) | ||
|
||
|
||
if __name__ == '__main__': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With this addition, can you directly "run" the file without prepending it with nosetests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, just need to |
||
import unittest | ||
unittest.main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,10 @@ | |
INTEGRATION_TESTS = os.environ.get('INTEGRATION_TESTS', False) | ||
|
||
|
||
class TimeoutError(Exception): | ||
pass | ||
|
||
|
||
class Proc(object): | ||
""" | ||
Slim wrapper on subprocess.Popen that redirects | ||
|
@@ -279,9 +283,8 @@ def wait_until(self, cond, max_timeout=10, poll_interval=0.1, name="cond"): | |
start = datetime.now() | ||
while not cond(): | ||
if datetime.now() - start > timedelta(seconds=max_timeout): | ||
raise Exception("Timeout waiting for '{}' to be true. " | ||
.format(name) + | ||
"Waited {} seconds.".format(max_timeout)) | ||
raise TimeoutError("Timeout waiting for '{}' to be true. ".format(name) + | ||
"Waited {} seconds.".format(max_timeout)) | ||
time.sleep(poll_interval) | ||
|
||
def get_log(self, logfile=None): | ||
|
@@ -351,6 +354,16 @@ def output_has(self, lines, output_file=None): | |
except IOError: | ||
return False | ||
|
||
def output_has_message(self, message, output_file=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That will become handy in other tests too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I tried working with the existing APIs but checking the length wasn't enough since when I restart I want to check for the different message to show up (length still 1) |
||
""" | ||
Returns true if the output has the given message field. | ||
""" | ||
try: | ||
return any(line for line in self.read_output(output_file=output_file, required_fields=["message"]) | ||
if line.get("message") == message) | ||
except (IOError, TypeError): | ||
return False | ||
|
||
def all_have_fields(self, objs, fields): | ||
""" | ||
Checks that the given list of output objects have | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filebeat must be stopped again here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done