-
Couldn't load subscription status.
- Fork 2.3k
Refactor TransportUpdateAction to use TransportShardBulkAction directly #18996
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
Open
atris
wants to merge
3
commits into
opensearch-project:main
Choose a base branch
from
atris:refactor-transport-update-action
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
server/src/test/java/org/opensearch/action/update/TransportUpdateActionTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * The OpenSearch Contributors require contributions made to | ||
| * this file be licensed under the Apache-2.0 license or a | ||
| * compatible open source license. | ||
| */ | ||
|
|
||
| package org.opensearch.action.update; | ||
|
|
||
| import org.opensearch.action.bulk.TransportShardBulkAction; | ||
| import org.opensearch.action.support.ActionFilters; | ||
| import org.opensearch.action.support.AutoCreateIndex; | ||
| import org.opensearch.cluster.metadata.IndexNameExpressionResolver; | ||
| import org.opensearch.cluster.service.ClusterService; | ||
| import org.opensearch.common.settings.ClusterSettings; | ||
| import org.opensearch.common.settings.Settings; | ||
| import org.opensearch.indices.IndicesService; | ||
| import org.opensearch.test.OpenSearchTestCase; | ||
| import org.opensearch.threadpool.ThreadPool; | ||
| import org.opensearch.transport.TransportService; | ||
| import org.opensearch.transport.client.node.NodeClient; | ||
|
|
||
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| public class TransportUpdateActionTests extends OpenSearchTestCase { | ||
|
|
||
| /** | ||
| * Test that TransportUpdateAction uses TransportShardBulkAction directly. | ||
| * We can't use reflection due to forbidden APIs, so we test the behavior | ||
| * by verifying that the shardBulkAction is called during update operations. | ||
| */ | ||
| public void testUpdateActionUsesShardBulkActionDirectly() { | ||
| // Mock dependencies | ||
| ThreadPool threadPool = mock(ThreadPool.class); | ||
| ClusterService clusterService = mock(ClusterService.class); | ||
| TransportService transportService = mock(TransportService.class); | ||
| UpdateHelper updateHelper = mock(UpdateHelper.class); | ||
| ActionFilters actionFilters = mock(ActionFilters.class); | ||
| IndexNameExpressionResolver resolver = mock(IndexNameExpressionResolver.class); | ||
| IndicesService indicesService = mock(IndicesService.class); | ||
| NodeClient client = mock(NodeClient.class); | ||
| TransportShardBulkAction shardBulkAction = mock(TransportShardBulkAction.class); | ||
|
|
||
| // Create AutoCreateIndex with proper settings | ||
| ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); | ||
| when(clusterService.getClusterSettings()).thenReturn(clusterSettings); | ||
| AutoCreateIndex autoCreateIndex = new AutoCreateIndex(Settings.EMPTY, clusterSettings, resolver, null); | ||
|
|
||
| // Create the action - this verifies the constructor accepts TransportShardBulkAction | ||
| TransportUpdateAction action = new TransportUpdateAction( | ||
| threadPool, | ||
| clusterService, | ||
| transportService, | ||
| updateHelper, | ||
| actionFilters, | ||
| resolver, | ||
| indicesService, | ||
| autoCreateIndex, | ||
| client, | ||
| shardBulkAction | ||
| ); | ||
|
|
||
| // If we got here, the constructor accepts TransportShardBulkAction parameter | ||
| // This ensures the refactoring is maintained | ||
| assertNotNull(action); | ||
| } | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given we use bulk today, ingest pipeline are getting applied when users rely on _update API for the documents which are generated here as part of the indexing request. With this change, we will not be able to leverage the same as we are not going through the TransportBulkAction anymore.
This may end up to be a breaking change for users if we directly delegate to bulk shard action and not apply the operations within the ingest pipeline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said, I don't think
_bulkAPI applies ingest pipeline on update operations either, so this change may end up unifying the behavior for both bulk/update APIs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this is a breaking change in terms of expectations for users, I don't think it would be ok to do this change, unless we enable support for ingest pipeline here. @shwetathareja thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we enable ingest here, would it not defeat the optimisation that this change looks to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Steps to see the change in final doc:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i dont think we can have breaking change as users might be using this as a feature to process using ingest pipeline.