Fix flaky Elasticsearch/Opensearch exporter IT tests #36602
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors the integration tests for both the Elasticsearch and Opensearch exporters to improve test isolation, reliability, and cleanup. The main changes include switching test lifecycle hooks from per-class to per-method, enhancing cleanup routines, and improving template deletion logic to be more targeted and robust.
Test lifecycle and structure improvements:
Changed test classes (
ElasticsearchExporterIT
,OpensearchExporterIT
) from using@BeforeAll
/@AfterAll
and@TestInstance(Lifecycle.PER_CLASS)
to@BeforeEach
/@AfterEach
with the default per-method lifecycle for better test isolation. [1] [2] [3] [4] [5] [6] [7] [8]Moved exporter configuration and opening into each test setup to ensure a fresh exporter state per test. [1] [2]
Cleanup and resource management enhancements:
@AfterEach
to delete indices, index templates, and new component templates, and to close test clients after every test, ensuring no leftover state between tests. [1] [2]Template deletion logic improvements:
deleteIndexTemplates
and addeddeleteComponentTemplates
in bothTestClient
classes to only delete templates matching the current test's index prefix, and to gracefully handle 404 errors when templates do not exist. [1] [2]Exporter logic adjustment:
schemaManager
on every configuration change in the Elasticsearch exporter, as it is no longer needed with the new test structure.## DescriptionChecklist
Related issues
closes #