Skip to content

Conversation

@nielsbauman
Copy link
Contributor

These two tests were ineffective because the result of the countdown latch was ignored. Correctly asserting the output of the latch showed that the test was failing, which was due to missing test setup - the policies were not defined in the registry and the lifecycle runner didn't execute the cluster state steps due to a missing task queue. Finally, some test objects were constructed incorrectly likely due to typos.

These two tests were ineffective because the result of the countdown
latch was ignored. Correctly asserting the output of the latch showed
that the test was failing, which was due to missing test setup - the
policies were not defined in the registry and the lifecycle runner
didn't execute the cluster state steps due to a missing task queue.
Finally, some test objects were constructed incorrectly likely due to
typos.
@nielsbauman nielsbauman requested a review from dakrone June 14, 2025 17:30
@nielsbauman nielsbauman added >test Issues or PRs that are addressing/adding tests :Data Management/ILM+SLM Index and Snapshot lifecycle management labels Jun 14, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@elasticsearchmachine elasticsearchmachine added v9.1.0 Team:Data Management Meta label for data/management team labels Jun 14, 2025
@lukewhiting lukewhiting requested a review from Copilot June 16, 2025 09:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes test failures in IndexLifecycleServiceTests by correcting test object construction, fixing latch and exception assignment, and setting up cluster services properly.

  • Correct test object initialization by using the proper lifecycle phase and policy variables.
  • Update latch and exception configuration to target the correct mock step.
  • Enhance test setup by initializing cluster settings and a ClusterService to simulate the environment more faithfully.
Comments suppressed due to low confidence (3)

x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleServiceTests.java:441

  • [nitpick] The creation of cluster settings and the ClusterService is critical for simulating the environment. Consider refactoring this setup into a common helper if similar configuration is used in other tests to improve maintainability.
ClusterSettings clusterSettings = new ClusterSettings(
            settings,
            Sets.union(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS, Set.of(LifecycleSettings.LIFECYCLE_POLL_INTERVAL_SETTING))
        );

x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleServiceTests.java:382

  • The test object construction has been corrected to use the appropriate phase variable. Verify that mapping i2phase to policy2 is intended to reflect the right test scenario.
LifecyclePolicy i2policy = newTestLifecyclePolicy(policy2, Map.of(i2phase.getName(), i2phase));

x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleServiceTests.java:408

  • The assignment of the latch (and subsequent exception setting) to i2mockStep appears to be a correction from the previous misuse of i1mockStep. Please confirm that this change accurately simulates the intended cluster state action steps.
((IndexLifecycleRunnerTests.MockClusterStateActionStep) i2mockStep).setLatch(stepLatch);

Copy link
Contributor

@lukewhiting lukewhiting left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍🏻

@nielsbauman nielsbauman merged commit d384e2f into elastic:main Jun 16, 2025
17 of 18 checks passed
@nielsbauman nielsbauman deleted the fix-ilm-service-test branch June 16, 2025 10:03
@nielsbauman
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.19

Questions ?

Please refer to the Backport tool documentation

elasticsearchmachine pushed a commit that referenced this pull request Jun 17, 2025
These two tests were ineffective because the result of the countdown
latch was ignored. Correctly asserting the output of the latch showed
that the test was failing, which was due to missing test setup - the
policies were not defined in the registry and the lifecycle runner
didn't execute the cluster state steps due to a missing task queue.
Finally, some test objects were constructed incorrectly likely due to
typos.

(cherry picked from commit d384e2f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Data Management/ILM+SLM Index and Snapshot lifecycle management Team:Data Management Meta label for data/management team >test Issues or PRs that are addressing/adding tests v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants