[Flaky Test] metricbeat.module.mongodb.test_mongodb.Test test_status
- Dominant language
- Go
- Stars
- 12.7k
- Forks
- 5k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 364
Description
## Flaky Test
* **Test Name:** test_status
* **Scope:** metricbeat.module.mongodb.test_mongodb.Test
* **File:** metricbeat/module/mongodb/test_mongodb.py
* **Location:** metricbeat/module/mongodb/test_mongodb.py:14
* **Buildkite Link:** https://buildkite.com/organizations/elastic/analytics/suites/beats/tests/909a48a3-25bc-80f0-9d76-d0128170a833
* **Flaky Instances:** 1
* **Latest Occurrence:** 2026-07-28T05:41:13.784Z
### Details
```json
{
"id": "909a48a3-25bc-80f0-9d76-d0128170a833",
"web_url": "https://buildkite.com/organizations/elastic/analytics/suites/beats/tests/909a48a3-25bc-80f0-9d76-d0128170a833",
"scope": "metricbeat.module.mongodb.test_mongodb.Test",
"name": "test_status",
"location": "metricbeat/module/mongodb/test_mongodb.py:14",
"file_name": "metricbeat/module/mongodb/test_mongodb.py",
"instances": 1,
"latest_occurrence_at": "2026-07-28T05:41:13.784Z",
"most_recent_instance_at": "2026-07-28T05:41:13.784Z",
"last_resolved_at": null,
"ownership_team_ids": [],
"failure_examples_count": 1
}
```
### Failure Examples
**Example 1:**
**Run:** https://api.buildkite.com/v2/analytics/organizations/elastic/suites/beats/runs/ada91483-5e5d-88f0-a551-f451abf1112e
**Time:** 2026-07-28T04:10:24.657Z
**Stacktrace:**
```
cls =
@classmethod
def setUpClass(cls): # pylint: disable=invalid-name
"""
initializes the Test class
"""
if not hasattr(cls, 'beat_name'):
cls.beat_name = "metricbeat"
if not hasattr(cls, 'beat_path'):
cls.beat_path = os.path.abspath(
os.path.join(os.path.dirname(__file__), "../../"))
> super().setUpClass()
tests/system/metricbeat.py:42:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../libbeat/tests/system/beat/beat.py:204: in setUpClass
cls.compose_up_with_retries()
../libbeat/tests/system/beat/beat.py:222: in compose_up_with_retries
raise ex
../libbeat/tests/system/beat/beat.py:218: in compose_up_with_retries
cls.compose_up()
../libbeat/tests/system/beat/compose.py:103: in compose_up
cls._run_compose(
../libbeat/tests/system/beat/compose.py:53: in _run_compose
return subprocess.run(cmd, env=env, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
input = None, capture_output = False, timeout = None, check = True
popenargs = (['docker', 'compose', '-p', 'mongodb_7918a246f6f8', '-f', '/go/src/github.com/elastic/beats/metricbeat/module/mongodb/docker-compose.yml', ...],)
kwargs = {'env': {'BEATS_INSIDE_INTEGRATION_TEST_ENV': 'true', 'BEAT_STRICT_PERMS': 'false', 'DOCKER_COMPOSE_PROJECT_NAME': 'metricbeat_9_6_0_15238e966f-snapshot', 'ES_PASS': 'testing', ...}}
process = , stdout = None, stderr = None, retcode = 17
def run(*popenargs,
input=None, capture_output=False, timeout=None, check=False, **kwargs):
"""Run command with arguments and return a CompletedProcess instance.
The returned instance will have attributes args, returncode, stdout and
stderr. By default, stdout and stderr are not captured, and those attributes
will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them,
or pass capture_output=True to capture both.
If check is True and the exit code was non-zero, it raises a
CalledProcessError. The CalledProcessError object will have the return code
in the returncode attribute, and output & stderr attributes if those streams
were captured.
If timeout is given, and the process takes too long, a TimeoutExpired
exception will be raised.
There is an optional argument "input", allowing you to
pass bytes or a string to the subprocess's stdin. If you use this argument
you may not also use the Popen constructor's "stdin" argument, as
it will be used internally.
By default, all communication is in bytes, and therefore any "input" should
be bytes, and the stdout and stderr will be bytes. If in text mode, any
"input" should be a string, and stdout and stderr will be strings decoded
according to locale encoding, or by "encoding" if set. Text mode is
triggered by setting any of text, encoding, errors or universal_newlines.
The other arguments are the same as for the Popen constructor.
"""
if input is not None:
if kwargs.get('stdin') is not None:
raise ValueError('stdin and input arguments may not both be used.')
kwargs['stdin'] = PIPE
if capture_output:
if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
raise ValueError('stdout and stderr arguments may not be used '
'with capture_output.')
kwargs['stdout'] = PIPE
kwargs['stderr'] = PIPE
with Popen(*popenargs, **kwargs) as process:
try:
stdout, stderr = process.communicate(input, timeout=timeout)
except TimeoutExpired as exc:
process.kill()
if _mswindows:
# Windows accumulates the output in a single blocking
# read() call run on child threads, with the timeout
# being done in a join() on those threads. communicate()
# _after_ kill() is required to collect that and add it
# to the exception.
exc.stdout, exc.stderr = process.communicate()
else:
# POSIX _communicate already populated the output so
# far into the TimeoutExpired exception.
process.wait()
raise
except: # Including KeyboardInterrupt, communicate handled that.
process.kill()
# We don't call process.wait() as .__exit__ does that for us.
raise
retcode = process.poll()
if check and retcode:
> raise CalledProcessError(retcode, process.args,
output=stdout, stderr=stderr)
E subprocess.CalledProcessError: Command '['docker', 'compose', '-p', 'mongodb_7918a246f6f8', '-f', '/go/src/github.com/elastic/beats/metricbeat/module/mongodb/docker-compose.yml', 'up', '-d', '--force-recreate', '--timeout', '30', 'mongodb']' returned non-zero exit status 17.
/usr/lib/python3.11/subprocess.py:571: CalledProcessError
```
Contributor guide
Research direction
Start with metricbeat/module/mongodb/test_mongodb.py and the Test.setUpClass path shown in the stack trace, then inspect metricbeat/module/mongodb/docker-compose.yml and reproduce the Docker Compose command from the failure. Trace why the mongodb service returns status 17 and verify that test_status runs reliably; done means the test passes without intermittent compose startup failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, mongodb, python
- Domain
- databases, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 48/100