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

Fixes metricbeat system test flakyness with better expectations #8052

Merged
merged 1 commit into from
Aug 23, 2018
Merged
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
22 changes: 11 additions & 11 deletions metricbeat/tests/system/test_reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ 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 @@ -57,6 +59,11 @@ def test_start_stop(self):
config_path = self.working_dir + "/configs/system.yml"
proc = self.start_beat()

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

systemConfig = """
- module: system
metricsets: ["cpu"]
Expand All @@ -66,28 +73,21 @@ def test_start_stop(self):
with open(config_path, 'w') as f:
f.write(systemConfig)

# Wait until offset for new line is updated
# Ensure the module was successfully loaded
self.wait_until(
lambda: self.log_contains("Starting runner: system [metricsets=1]"),
lambda: self.log_contains(reload_line(1)),
max_timeout=10)

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

# Remove config again
os.remove(config_path)

# Wait until offset for new line is updated
# Ensure the module was successfully unloaded
self.wait_until(
lambda: self.log_contains("Stopping runner: system [metricsets=1]"),
lambda: self.log_contains(reload_line(0)),
max_timeout=10)

lines = self.output_lines()

time.sleep(1)

# Make sure no new lines were added since stopping
assert lines == self.output_lines()

proc.check_kill_and_wait()

@unittest.skipUnless(re.match("(?i)win|linux|darwin|freebsd|openbsd", sys.platform), "os")
Expand Down