-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for conditional Transient header propagation (#11490)
* Clear transient header from system context Signed-off-by: Gagan Juneja <gjjuneja@amazon.com> * Clear transient header from system context Signed-off-by: Gagan Juneja <gjjuneja@amazon.com> * Adds changelog Signed-off-by: Gagan Juneja <gjjuneja@amazon.com> * Update CHANGELOG.md Co-authored-by: Andriy Redko <drreta@gmail.com> Signed-off-by: Gagan Juneja <gagandeepjuneja@gmail.com> * Adds unit tests Signed-off-by: Gagan Juneja <gjjuneja@amazon.com> * Refactor code Signed-off-by: Gagan Juneja <gjjuneja@amazon.com> * Refactor code Signed-off-by: Gagan Juneja <gjjuneja@amazon.com> * Refactor code Signed-off-by: Gagan Juneja <gjjuneja@amazon.com> * Supress warning Signed-off-by: Gagan Juneja <gjjuneja@amazon.com> * Refactor code Signed-off-by: Gagan Juneja <gjjuneja@amazon.com> --------- Signed-off-by: Gagan Juneja <gjjuneja@amazon.com> Signed-off-by: Gagan Juneja <gagandeepjuneja@gmail.com> Co-authored-by: Gagan Juneja <gjjuneja@amazon.com> Co-authored-by: Andriy Redko <drreta@gmail.com> (cherry picked from commit 71f1fab) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
c76df2d
commit 71edb8d
Showing
9 changed files
with
193 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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
34 changes: 34 additions & 0 deletions
34
server/src/test/java/org/opensearch/tasks/TaskThreadContextStatePropagatorTests.java
This file contains 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,34 @@ | ||
/* | ||
* 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.tasks; | ||
|
||
import org.opensearch.test.OpenSearchTestCase; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.opensearch.tasks.TaskResourceTrackingService.TASK_ID; | ||
|
||
public class TaskThreadContextStatePropagatorTests extends OpenSearchTestCase { | ||
private final TaskThreadContextStatePropagator taskThreadContextStatePropagator = new TaskThreadContextStatePropagator(); | ||
|
||
public void testTransient() { | ||
Map<String, Object> transientHeader = new HashMap<>(); | ||
transientHeader.put(TASK_ID, "t_1"); | ||
Map<String, Object> transientPropagatedHeader = taskThreadContextStatePropagator.transients(transientHeader, false); | ||
assertEquals("t_1", transientPropagatedHeader.get(TASK_ID)); | ||
} | ||
|
||
public void testTransientForSystemContext() { | ||
Map<String, Object> transientHeader = new HashMap<>(); | ||
transientHeader.put(TASK_ID, "t_1"); | ||
Map<String, Object> transientPropagatedHeader = taskThreadContextStatePropagator.transients(transientHeader, true); | ||
assertEquals("t_1", transientPropagatedHeader.get(TASK_ID)); | ||
} | ||
} |
This file contains 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