Commit graph

9 commits

Author SHA1 Message Date
Cristina Amico
966736e4b4
[Fleet] Add rate limiting to install by upload endpoint (#184036)
Fixes https://github.com/elastic/ingest-dev/issues/3217

## Summary

Add rate limiting to "install by upload" endpoint. 
Implemented with a cache that is set with the timestamp of each install
by upload, independently from the package name/version. If the time
elapsed since the last timestamp it's less than retry time (10s), the
endpoint will return `429 Too many requests`.

### Testing
- Upload a package with 
```
curl -XPOST -H 'content-type: application/zip' -H 'kbn-xsrf: true' http://localhost:5601/YOUR_PATH/api/fleet/epm/packages -u elastic:changeme --data-binary @PACKAGE_NAME.zip
```
- Upload another package shortly after. It can be the same one or
another one, as the rate limiting is applied across all uploads, no
matter the package name.
- If the second upload happens <10s after the first one, should return
error `429 Too Many Requests. Please wait 10s before uploading again.`

### Checklist

- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2024-06-06 17:13:52 +02:00
Pierre Gayvallet
148eeec0fe
Update supertest and superagent to latest version (#183587)
## Summary

Related to https://github.com/elastic/kibana/issues/7104

Update supertest, superagent, and the corresponding type package, to
their latest version.

(of course, types had some signature changes and we're massively using
supertest in all our FTR suites so the whole Kibana multiverse has to
review it)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-05-17 04:23:21 -07:00
Kevin Lacabane
b7f57a09cb
[Stack Monitoring] install packages before test suite runs (#165881)
## Summary

Closes https://github.com/elastic/kibana/issues/165043

Updates the approach to load packages in test suites by sending http
request before suite starts instead of using
`xpack.fleet.developer.bundledPackageLocation`

[Flaky test
runner](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3075)
2023-09-08 13:32:30 +02:00
Kevin Lacabane
bca80be144
[Stack Monitoring] fix beat api tests (#153466)
Closes https://github.com/elastic/kibana/issues/153123

### Summary
https://github.com/elastic/elasticsearch/pull/94400 added missing
aliases required by Stack Monitoring. Tests started to fail as they
expected the metrics related to these aliases to be empty since they
could not be queried, but now return associated data.
I've generated a new archive and updated the tests accordingly.

Tests use package build from
https://github.com/elastic/integrations/pull/5639.
2023-03-23 12:26:12 +01:00
Kevin Lacabane
e1579c8f4a
[Stack Monitoring] baseline kibana api tests for package and metricbeat data (#153184)
## Summary

Part of https://github.com/elastic/kibana/issues/148303

Port kibana api tests to the
[monitoring_api_integration](https://github.com/elastic/kibana/tree/main/x-pack/test/monitoring_api_integration)
suite. This reimplements all the existing tests with fresh data.

See [flaky test
run](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2002)
2023-03-20 13:49:20 +01:00
Kevin Lacabane
ab7c879c23
[Stack Monitoring] baseline logstash api tests for package and metricbeat data (#152575)
## Summary

Closes https://github.com/elastic/kibana/issues/151158
Part of https://github.com/elastic/kibana/issues/148303

Port logstash tests to the
[monitoring_api_integration](https://github.com/elastic/kibana/tree/main/x-pack/test/monitoring_api_integration)
suite. This reimplements all the existing tests (plus missing ones for
the pipeline api) with fresh data.

See [flaky test
run](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/1982)
2023-03-08 14:26:05 +01:00
Kevin Lacabane
d9adcca543
[Stack Monitoring] implement baseline elasticsearch api tests for package and metricbeat data (#149161)
### Summary

Part of https://github.com/elastic/kibana/issues/148303
Closes https://github.com/elastic/kibana/issues/146067
Closes https://github.com/elastic/kibana/issues/146068

I investigated the failing tests but couldn't get to the root cause
quickly enough so I took the opportunity to port the tests to the
[monitoring_api_integration](https://github.com/elastic/kibana/tree/main/x-pack/test/monitoring_api_integration)
suite. This reimplements all the existing tests (plus missing ones for
the `ml_jobs` api) with fresh data.
By using the new testing approach we can remove the archived mappings
which greatly reduce execution times.

### Testing
- The suite was executed against by the [flaky test
runner](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/1804)
multiple times with no failures
- Test data is bundled in two archives (one for metricbeat and one for
package data) and can be loaded to verify their content: `node
scripts/es_archiver.js load
x-pack/test/monitoring_api_integration/archives/elasticsearch/single_node/(package|metricbeat)
--es-url=http://elastic:changeme@localhost:9200
--kibana-url=http://elastic:changeme@localhost:5601`

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2023-01-30 17:01:00 +01:00
Kevin Lacabane
870f79df8c
[Stack Monitoring] support entsearch package (#148668)
### Summary

Update stack monitoring to read from data streams created by the
[enterprisesearch
package](https://github.com/elastic/integrations/pull/4926)

### Testing
- build [enterprisesearch
package](https://github.com/elastic/integrations/pull/4926)
- start stack: `elastic-package stack up -v -d --version
8.7.0-SNAPSHOT`; make sure your image contains [this
change](https://github.com/elastic/elastic-agent/pull/2121)
- start enterprisesearch service: `elastic-package service up -v`
- install elasticsearch integration with variables
- `hosts: http://host.docker.internal:9201; username: elastic; password:
changeme`
- install enterprisesearch integration with variables
- `hosts: http://host.docker.internal:3002; username: elastic; password:
changeme`
- connect [local
kibana](2d893bf40b/x-pack/plugins/monitoring/dev_docs/how_to/work_with_packages.md (connecting-a-local-kibana))
- navigate to Stack Monitoring on the local kibana, enterprise search
section shows up with populated graphs

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2023-01-30 13:43:13 +01:00
Kevin Lacabane
5c9df67e8d
[Stack Monitoring] Beats package integration tests (#147755)
### Summary

**Sets up the foundations for
https://github.com/elastic/kibana/issues/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](b55de5c1cc/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 <42973632+kibanamachine@users.noreply.github.com>
2023-01-03 16:20:17 +01:00