Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Aug 7, 2024
1 parent 76e8b04 commit 84a325d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import static org.hamcrest.Matchers.equalTo;

/**
* Test a rest action that sets special response headers
* Test to ensure that plugin execution context is set when plugin uses pluginNodeClient
*/
@ClusterScope(scope = Scope.SUITE, supportsDedicatedMasters = false, numDataNodes = 1)
public class ExecutionContextPluginGetIT extends HttpSmokeTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.common.logging.HeaderWarning;
import org.opensearch.common.settings.Settings;
import org.opensearch.plugins.Plugin;
import org.opensearch.test.OpenSearchTestCase;

import java.io.IOException;
Expand Down Expand Up @@ -73,6 +74,17 @@ public void testStashContext() {
assertEquals("1", threadContext.getHeader("default"));
}

public void testStashContextWithPluginInfo() {
ThreadContext threadContext = new ThreadContext(Settings.EMPTY);
threadContext.putHeader("foo", "bar");
try (ThreadContext.StoredContext ctx = threadContext.stashContext(Plugin.class)) {
assertNull(threadContext.getHeader("foo"));
assertEquals(Plugin.class.getCanonicalName(), threadContext.getHeader("_plugin_execution_context"));
}

assertNull(threadContext.getHeader("_plugin_execution_context"));
}

public void testStashContextWithPersistentHeaders() {
Settings build = Settings.builder().put("request.headers.default", "1").build();
ThreadContext threadContext = new ThreadContext(build);
Expand Down

0 comments on commit 84a325d

Please sign in to comment.