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

filebeat: Fix flaky test case on macOS #39860

Merged
merged 5 commits into from
Jun 13, 2024
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
4 changes: 2 additions & 2 deletions filebeat/tests/system/test_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ def test_tail_files(self):
self.wait_until(
lambda: self.log_contains(
"Start next scan"),
max_timeout=5)
max_timeout=10)

with open(testfile, 'a') as f:
# write additional lines
Expand Down Expand Up @@ -596,7 +596,7 @@ def test_encodings(self):
# run filebeat
filebeat = self.start_beat()
self.wait_until(lambda: self.output_has(lines=len(encodings)),
max_timeout=15)
max_timeout=25)

# write another line in all files
for _, enc_py, text in encodings:
Expand Down
2 changes: 1 addition & 1 deletion filebeat/tests/system/test_harvester.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,6 @@ def test_debug_reader(self):

# 13 on unix, 14 on windows.
self.wait_until(lambda: self.log_contains(re.compile(
'Matching null byte found at offset (13|14)')), max_timeout=5)
'Matching null byte found at offset (13|14)')), max_timeout=10)

filebeat.check_kill_and_wait()
14 changes: 8 additions & 6 deletions filebeat/tests/system/test_registrar.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,11 @@ def test_registry_file_update_permissions(self):

self.assertEqual(self.file_permissions(os.path.join(registry_path, "log.json")), "0o600")

registry_home = "a/b/c/d/registry_x"
registry_path = os.path.join(registry_home, "filebeat")
self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/*",
registry_home="a/b/c/registry_x",
registry_home=registry_home,
registry_file_permissions=0o640
)

Expand All @@ -266,7 +268,7 @@ def test_registry_file_update_permissions(self):
# the logging and actual writing the file. Seems to happen on Windows.
self.wait_until(
lambda: self.has_registry(registry_path),
max_timeout=1)
max_timeout=10)

# Wait a moment to make sure registry is completely written
time.sleep(1)
Expand Down Expand Up @@ -950,7 +952,7 @@ def test_restart_state(self):
path=os.path.abspath(self.working_dir) + "/log/*",
close_inactive="200ms",
ignore_older="2000ms",
clean_inactive="3s",
clean_inactive="10s",
)

filebeat = self.start_beat()
Expand All @@ -976,7 +978,7 @@ def test_restart_state_reset(self):
self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/*",
clean_inactive="10s",
ignore_older="5s"
ignore_older="9s"
)
os.mkdir(self.working_dir + "/log/")

Expand All @@ -1003,7 +1005,7 @@ def test_restart_state_reset(self):
self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/test2.log",
clean_inactive="10s",
ignore_older="5s",
ignore_older="9s",
)

filebeat = self.start_beat(output="filebeat2.log")
Expand Down Expand Up @@ -1137,7 +1139,7 @@ def test_restart_state_reset_ttl_no_clean_inactive(self):
self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/test.log",
clean_inactive="10s",
ignore_older="5s"
ignore_older="9s"
)
os.mkdir(self.working_dir + "/log/")

Expand Down
8 changes: 7 additions & 1 deletion filebeat/tests/system/test_shutdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ def test_shutdown(self):
)
for i in range(1, 5):
proc = self.start_beat(logging_args=["-e", "-v"])
time.sleep(.5)

# Flaky on MacOS, see https://github.com/elastic/beats/issues/39613#issuecomment-2158812325
# we need to wait a bit longer for filebeat to start
if platform.system() == "Darwin":
time.sleep(10)
else:
time.sleep(.5)
proc.check_kill_and_wait()

@unittest.skip("Skipped as flaky: https://github.com/elastic/beats/issues/14647")
Expand Down
Loading