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

[libbeat] Fix / clarify the module reload logic #16440

Merged
merged 14 commits into from
Feb 26, 2020
Prev Previous commit
fix flaky reloader tests
  • Loading branch information
faec committed Feb 26, 2020
commit fdf2c030ddb127e176bf38dad5f42ba27158530d
7 changes: 5 additions & 2 deletions heartbeat/tests/system/test_reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def test_config_add(self):
"""
self.setup_dynamic()

# Wait until the beat is running and has performed its first load of
# the config directory.
self.wait_until(lambda: self.log_contains(
"Starting reload procedure, current runners: 0"))

Expand All @@ -77,9 +79,10 @@ def test_config_add(self):
self.write_dyn_config(
"test.yml", self.http_cfg("myid", "http://localhost:{}".format(server.server_port)))

# The beat should recognize there is a new runner to start.
self.wait_until(lambda: self.log_contains(
"Starting reload procedure, current runners: 1"),
max_timeout=15)
"Start list: 1, Stop list: 0"),
max_timeout=10)

self.wait_until(lambda: self.output_lines() > 0)

Expand Down
12 changes: 5 additions & 7 deletions metricbeat/tests/system/test_reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ def test_reload(self):

@unittest.skipUnless(re.match("(?i)win|linux|darwin|freebsd|openbsd", sys.platform), "os")
def test_start_stop(self):
def reload_line(
num_runners): return "Starting reload procedure, current runners: %d" % num_runners
"""
Test if module is properly started and stopped
"""
Expand All @@ -61,7 +59,7 @@ def reload_line(

# Ensure no modules are loaded
self.wait_until(
lambda: self.log_contains(reload_line(0)),
lambda: self.log_contains("Start list: 0, Stop list: 0"),
max_timeout=10)

systemConfig = """
Expand All @@ -73,17 +71,17 @@ def reload_line(
with open(config_path, 'w') as f:
f.write(systemConfig)

# Ensure the module was successfully loaded
# Ensure the module is started
self.wait_until(
lambda: self.log_contains(reload_line(1)),
lambda: self.log_contains("Start list: 1, Stop list: 0"),
max_timeout=10)

# Remove config again
os.remove(config_path)

# Ensure the module was successfully unloaded
# Ensure the module is stopped
self.wait_until(
lambda: self.log_contains(reload_line(0)),
lambda: self.log_contains("Start list: 0, Stop list: 1"),
max_timeout=10)

time.sleep(1)
Expand Down