elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.57k stars 8.09k forks source link

Proactively improve robustness of FTR tests that use esArchiver #161882

Open gsoldevila opened 1 year ago

gsoldevila commented 1 year ago

There are multiple FTR tests that still rely on esArchiver to import test data into ES indices.

Some of the archives used by these tests are actually re-defining SO indices and documents.

When esArchiver.load(...) is called in the beginning of a test (usually in a before hook), multiple things happen:

All of that happens whilst Kibana is already running, and potentially issuing requests against these indices. Sometimes these requests happen right when esArchiver is re-creating the SO indices, causing different sorts of flakiness (as seen on https://github.com/elastic/kibana/issues/158918).

The aforementioned issue has been tackled in 2 stages: 1) Updating esArchiver so that it cleans up the SO indices whenever it detects that SO are defined in the data.json (without actually deleting the indices). (https://github.com/elastic/kibana/pull/159582) 2) Updating the archives related to the flaky tests as follows: (https://github.com/elastic/kibana/pull/159397)

In parallel, the esArchiver.load(...) was updated so that when it actually creates SO indices (for those tests that still define them in mappings.json), it does so in two separate steps: first create indices, and then create aliases. This helps circumvent some of the _no_shardserrors that happen when the index is still not ready to be queried. (https://github.com/elastic/kibana/pull/160584)

What's next ATM there are 7 other archives that are still defining "dynamic" SO indices, i.e. indices that aim at being at the latest version, by using the $KIBANA_PACKAGE_VERSION in the mappings.json. These should be easy to update, removing the corresponding definitions from the mappings.json, and ensuring they will not cause flakiness.

Also ATM, there are a total of 49 mappings.json files that presumably define SO indices (they contain the .kibana keyword). Even though they are not dynamic, they could also be updated to not cause SO indices to be deleted. But in order to do so, we must:

The goal of this issue is to proactively tackle the tests that are still defining SO indices, in order to:

### Tasks
- [ ] https://github.com/elastic/kibana/issues/168973
- [ ] https://github.com/elastic/kibana/issues/168969
- [ ] https://github.com/elastic/kibana/issues/168926
- [ ] https://github.com/elastic/kibana/issues/169075
gsoldevila commented 1 year ago

I created a script to locally update the data.json entries, leveraging the logic used by esArchiver to parse NDJSON.

elasticmachine commented 1 year ago

Pinging @elastic/kibana-core (Team:Core)

elasticmachine commented 8 months ago

Pinging @elastic/appex-qa (Team:QA)