self = <test_registrar.Test testMethod=test_rotating_file>
def test_rotating_file(self):
"""
Checks that the registry is properly updated after a file is rotated
"""
self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/*",
close_inactive="1s"
)
os.mkdir(self.working_dir + "/log/")
testfile_path = self.working_dir + "/log/test.log"
filebeat = self.start_beat()
with open(testfile_path, 'w') as testfile:
testfile.write("offset 9\n")
self.wait_until(lambda: self.output_has(lines=1),
max_timeout=10)
testfilerenamed = self.working_dir + "/log/test.1.log"
os.rename(testfile_path, testfilerenamed)
with open(testfile_path, 'w') as testfile:
testfile.write("offset 10\n")
self.wait_until(lambda: self.output_has(lines=2),
max_timeout=10)
# Wait until rotation is detected
self.wait_until(
lambda: self.log_contains(
"Updating state for renamed file"),
> max_timeout=10)
tests/system/test_registrar.py:311:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <test_registrar.Test testMethod=test_rotating_file>
cond = <function Test.test_rotating_file.<locals>.<lambda> at 0x10e648ef0>
max_timeout = 10, poll_interval = 0.1, name = 'cond'
def wait_until(self, cond, max_timeout=10, poll_interval=0.1, name="cond"):
"""
Waits until the cond function returns true,
or until the max_timeout is reached. Calls the cond
function every poll_interval seconds.
If the max_timeout is reached before cond() returns
true, an exception is raised.
"""
start = datetime.now()
while not cond():
if datetime.now() - start > timedelta(seconds=max_timeout):
raise TimeoutError("Timeout waiting for '{}' to be true. ".format(name) +
> "Waited {} seconds.".format(max_timeout))
E beat.beat.TimeoutError: Timeout waiting for 'cond' to be true. Waited 10 seconds.
../libbeat/tests/system/beat/beat.py:363: TimeoutError
Flaky Test
beats/filebeat/tests/system/test_registrar.py
Line 278 in 6347d45
Stack Trace