elastic / elastic-agent-system-metrics

Apache License 2.0
0 stars 22 forks source link

Add a test framework for monitoring the host system from inside a container #140

Closed fearful-symmetry closed 2 months ago

fearful-symmetry commented 2 months ago

What does this PR do?

Closes https://github.com/elastic/beats/issues/38241

This adds a lightweight test framework that runs a set of system tests under a container with the goal of monitoring the host system. The goal with these tests is to catch the numerous edge cases that happen when the system metrics function from a /hostfs path inside a container.

The tests have a fairly large matrix of configurations, as we need to test both a wide variety of container permission settings, as well as differences in how linux distros will configure cgroups.

The framework here was designed with the goal of being relatively idiomatic; you can just run the framework with go test as you would normally.

You can run the tests yourself with go test -v ./tests

As you may have noticed, there's a non-zero amount of TODO statements here, since these tests were built to aggravate a bunch of existing bugs, so certain parts of the tests will remain un-implemented until those bugs are fixed.

Why is it important?

See https://github.com/elastic/beats/issues/38241, we really need test for this particular case.

List of bugs that are responsible for TODO statements in the tests:

Checklist