Description
Currently the examples in the Elasticsearch documentation are tested using the functionality described here: https://github.com/elastic/elasticsearch/tree/master/docs#snippet-testing
When the X-Pack code was merged into the OSS code, it seems that cleanup for the documentation tests was not carried over from the x-pack/docs folder to the docs folder. There seem to be structures created during testing (system indices, etc) that sometimes don’t get cleaned up and then cause problems with subsequent tests. As a result, cleanup has been added on an as-needed basis. For example:
https://github.com/elastic/x-pack-elasticsearch/issues/2818
#31450
#43271
#44123
Ideally the steps for cleaning up after documentation tests can be clarified or simplified so that it's easier to accomplish for new features and/or existing features (security, watcher) that are still lingering in the x-pack/docs due to testing issues.