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

[Stack Monitoring] Enable testing of latest package versions #146000

Closed
klacabane opened this issue Nov 22, 2022 · 6 comments
Closed

[Stack Monitoring] Enable testing of latest package versions #146000

klacabane opened this issue Nov 22, 2022 · 6 comments
Labels
Feature:Stack Monitoring Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services

Comments

@klacabane
Copy link
Contributor

klacabane commented Nov 22, 2022

Summary

We added integration tests for Agent based data in #119658. At this moment the tests work by loading a standard es-archiver bundle containing both static mappings of the metrics-* data streams and corresponding documents (example).

Ideally each update of the mappings in the packages should be reflected in the static archive in order to validate no regression were introduced as new versions are released.

  1. We could have a mostly manual, documented process to update static mappings with each package update.
  2. We could replace the static mappings created by installing the packages as a setup step to the test suite. This will require spawning a local package registry and hitting the fleet api. We'll likely have to bundle the packages in the kibana repo to avoid any network reliance. With such a setup in place, we'd only have to update the version of the package installed during test setup.
  3. (recommended) use xpack.fleet.developer.bundledPackageLocation to load local packages without spawning a local registry. Because loading packages can have side effects on test suites of the other kibana plugins we'll have a create a dedicated suite spawning its own kibana test server (fleet example). See [Stack Monitoring] install bundled package for tests #146355 for the blueprint

For 2. we'll have to:

AC

  • A process exists to validate the latest version of the package's mappings in Stack Monitoring integration tests
@klacabane klacabane added Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services Feature:Stack Monitoring labels Nov 22, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/infra-monitoring-ui (Team:Infra Monitoring UI)

@klacabane klacabane changed the title [Stack Monitoring] [Stack Monitoring] Enable testing of latest package versions Nov 22, 2022
@klacabane
Copy link
Contributor Author

There's a way to load packages bundled on the filesystem with the xpack.fleet.developer.bundledPackageLocation. This does not require a docker registry since bundled packages take precedence and ignore the registry request. This approach is cheaper to implement and maintain while perfectly matching our requirements.

This attempt #146355 to replace package mappings with preinstalled packages is fairly successful in that Stack Monitoring tests are green. However loading the packages on the test server used by every other plugin causes side effects, so we'd have to create a dedicated test server for monitoring api tests like fleet.
There's also a CI issue with the case of the package names, we could exclude the packages folder from the glob unless there is a way to bundle packages with different names.

@kpollich is there any counter indication using xpack.fleet.developer.bundledPackageLocation setting to load packages ?

@kpollich
Copy link
Member

@kpollich is there any counter indication using xpack.fleet.developer.bundledPackageLocation setting to load packages ?

Sorry I'm not sure I understand the question. Could you rephrase?

@klacabane
Copy link
Contributor Author

Is the setting safe to use and is it the recommended approach to load packages for automated testing purposes ?

@kpollich
Copy link
Member

Is the setting safe to use and is it the recommended approach to load packages for automated testing purposes ?

Thanks for clarifying. This setting will control from where Fleet loads its bundled packages. Note that bundled packages are not automatically installed - just available on disk. Bundled packages exist to support offline environments.

If you'd like to install some packages by default, then you can use xpack.fleet.packages in kibana.yml: https://www.elastic.co/guide/en/kibana/current/fleet-settings-kb.html#_preconfiguration_settings_for_advanced_use_cases

klacabane added a commit that referenced this issue Jan 3, 2023
### Summary

**Sets up the foundations for
#146000
- created a new test server under
`x-pack/test/monitoring_api_integration/` that allows loading of
packages at kibana startup
- a test runner utility which is a simple for loop executing the
supplied test twice, one time with `metricbeat` data and a second time
with `package` data
- a utility that allows transformation of package data into metricbeat
data

**Adds API tests for the beats package**
- created a test case for each API exposed
- removed the duplicates from
`x-pack/test/api_integration/apis/monitoring`

-----

_See the included
[README](https://github.com/elastic/kibana/blob/b55de5c1ccf2d654bd03cf5f856765fdc85c82f6/x-pack/test/monitoring_api_integration/README.md)
for additional details_

This directory defines a custom test server that provides bundled
integrations
packages to the spawned test Kibana. This allows us to install those
packages at
startup, with all their assets (index templates, ingest pipelines..),
without
having to reach a remote package registry.
With the packages and their templates already installed we don't have to
provide
the static mappings in the tests archives. This has the benefit of
reducing our
disk footprint and setup time but more importantly it enables an easy
upgrade path
of the mappings so we can verify no breaking changes were introduced by
bundling
the new versions of the packages.

_Note that while Stack Monitoring currently supports 3 collection modes,
the tests
in this directory only focus on metricbeat and elastic-agent data. Tests
for legacy
data are defined under `x-pack/test/api_integration/apis/monitoring`._

Since an elastic-agent integration spawns the corresponding metricbeat
module under
the hood (ie when an agent policy defines elasticsearch metrics data
streams,
a metricbeat process with the elasticsearch module will be spawned), the
output
documents are _almost_ identical. This means that we can easily
transform documents
from a source (elastic-agent) to another (metricbeat), and have the same
tests run
against both datasets.

Note that we don't have to install anything for the metricbeat data
since the mappings
are already installed by elasticseach at startup, and available at
`.monitoring-<component>-8-mb`
patterns. So we are always running the metricbeat tests against the
latest version of
the mappings.
We could have a similar approach for packages, for example by installing
the latest
packages versions from public EPR before the test suites run, instead of
using pinned
versions. Besides the questionable reliance on remote services for
running tests,
this is also dangerous given that packages are released in a continuous
model.
This means that whenever the test suite would execute against the latest
version
of packages it would be too late, as in already available to users.

Co-authored-by: kibanamachine <[email protected]>
@klacabane
Copy link
Contributor Author

Completed in #147755

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Stack Monitoring Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services
Projects
None yet
Development

No branches or pull requests

3 participants