Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encapsulate IndexShard/IndexService closing in tests #107974

Merged

Conversation

DaveCTurner
Copy link
Contributor

Closing an IndexShard or an IndexService requires some parameters
that are not really important in tests. This commit encapsulates these
calls into utility methods to populate those parameters with sensible
values. Moreover it reduces some unnecessary noise in a follow-up PR
which will make this closing process a little more complicated in
production code without affecting all these tests.

Relates #107952

Closing an `IndexShard` or an `IndexService` requires some parameters
that are not really important in tests. This commit encapsulates these
calls into utility methods to populate those parameters with sensible
values. Moreover it reduces some unnecessary noise in a follow-up PR
which will make this closing process a little more complicated in
production code without affecting all these tests.

Relates elastic#107952
@DaveCTurner DaveCTurner added :Distributed/Engine Anything around managing Lucene and the Translog in an open shard. >refactoring v8.15.0 labels Apr 26, 2024
@elasticsearchmachine elasticsearchmachine added the Team:Distributed Meta label for distributed team label Apr 26, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

@DaveCTurner
Copy link
Contributor Author

Extracted from #107952 to reduce noise in that PR for easier reviewing.

@DaveCTurner DaveCTurner merged commit 35600c5 into elastic:main Apr 29, 2024
14 checks passed
@DaveCTurner DaveCTurner deleted the 2024/04/26/IndexShard-test-close branch April 29, 2024 11:33
Copy link
Member

@ywangd ywangd left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -363,7 +363,7 @@ public void testTranslogRecoveryWorksWithIMC() throws IOException {
for (int i = 0; i < 100; i++) {
indexDoc(shard, Integer.toString(i), "{\"foo\" : \"bar\"}", XContentType.JSON, null);
}
shard.close("simon says", false);
Copy link
Member

Choose a reason for hiding this comment

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

Bah I wish we could have preserved this great reason! :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's still there in org.elasticsearch.indices.IndicesLifecycleListenerSingleNodeTests :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed/Engine Anything around managing Lucene and the Translog in an open shard. >refactoring Team:Distributed Meta label for distributed team v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants