Skip to content
Closed
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
daf3b2c
WIP on Handler naming and SSL
cwperks Mar 27, 2023
9c49d95
Add concept of extension shortname via settings
cwperks Mar 28, 2023
97d2a22
WIP on extension ssl
cwperks Mar 28, 2023
b5703ae
Merge branch 'main' into ssl-and-handler-naming
cwperks Mar 28, 2023
36b67cc
Get registry from runner
cwperks Mar 28, 2023
9238527
Read settings from extension config file
cwperks Mar 29, 2023
a9325d2
Update license headers
cwperks Mar 29, 2023
0a1425b
Run spotlessApply
cwperks Mar 29, 2023
0b634be
Remove authz changes and only keep TLS
cwperks Mar 29, 2023
38baa81
Remove authz changes and only keep TLS
cwperks Mar 29, 2023
d504ed8
Remove authz changes and only keep TLS
cwperks Mar 29, 2023
6826fef
Remove authz changes and only keep TLS
cwperks Mar 29, 2023
0825b74
Remove authz changes and only keep TLS
cwperks Mar 29, 2023
5afe8c8
Update cert generation documents
cwperks Mar 29, 2023
ef085ce
Merge branch 'setup-extension-tls' into ssl-and-handler-naming
cwperks Mar 29, 2023
4966514
Re-add authz changes for sample Hello world extension
cwperks Mar 29, 2023
b287fe5
Add ssl.transport.enabled in ExtensionsRunner
cwperks Mar 29, 2023
ff158f6
Name all HelloWorld extension routes
cwperks Mar 29, 2023
a80cae7
Run spotlessApply
cwperks Mar 29, 2023
636bcdc
Merge branch 'main' into setup-extension-tls
cwperks Mar 31, 2023
b08d018
Merge main into branch
cwperks Mar 31, 2023
1c23d9c
Merge branch 'setup-extension-tls' into ssl-and-handler-naming
cwperks Mar 31, 2023
e45ea0e
Add instructions for running in SSL only mode
cwperks Apr 2, 2023
10127c4
Merge branch 'main' into setup-extension-tls
cwperks Apr 3, 2023
1eeafe6
Add all SSL settings to extension settings
cwperks Apr 3, 2023
f4ab756
Merge branch 'setup-extension-tls' into ssl-and-handler-naming
cwperks Apr 3, 2023
66654ba
Update TestExtensionsRunner
cwperks Apr 3, 2023
df30efd
Set default enforce_hostname_verification
cwperks Apr 3, 2023
03025e4
Merge branch 'setup-extension-tls' into ssl-and-handler-naming
cwperks Apr 3, 2023
09a84a3
Merge branch 'main' into setup-extension-tls
cwperks Apr 10, 2023
9830335
Merge branch 'setup-extension-tls' into ssl-and-handler-naming
cwperks Apr 10, 2023
f7697b1
Merge branch 'main' into setup-extension-tls
cwperks Apr 22, 2023
6d7ec26
Run spotlessApply
cwperks Apr 22, 2023
8576654
Respond to code review feedback
cwperks Apr 22, 2023
8a93770
Merge branch 'setup-extension-tls' into ssl-and-handler-naming
cwperks Apr 22, 2023
bdea4ea
fix merge conflicts
cwperks Apr 22, 2023
ee09450
Fix typos in debug messages
cwperks Apr 26, 2023
a989151
Add docstrings
cwperks Apr 27, 2023
af084b4
Merge branch 'main' into setup-extension-tls
cwperks Apr 27, 2023
0b37c06
Merge branch 'setup-extension-tls' into ssl-and-handler-naming
cwperks Apr 27, 2023
c04bda1
Merge branch 'main' into setup-extension-tls
cwperks Apr 28, 2023
fb4f0bc
Merge branch 'setup-extension-tls' into ssl-and-handler-naming
cwperks Apr 28, 2023
15c82db
Merge branch 'main' into setup-extension-tls
cwperks May 1, 2023
54d057c
Address code review feedback
cwperks May 1, 2023
5fb6497
Merge branch 'setup-extension-tls' into ssl-and-handler-naming
cwperks May 1, 2023
81c25ce
Merge branch 'main' into ssl-and-handler-naming
cwperks May 2, 2023
0c5ce25
Remove duplicate
cwperks May 2, 2023
b880d93
Remove duplicate
cwperks May 2, 2023
ecf51e4
Merge branch 'main' into ssl-and-handler-naming
cwperks May 4, 2023
59f316c
Create ExtensionRouteHandlerFactory
cwperks May 5, 2023
93b6daf
Merge branch 'main' into ssl-and-handler-naming
cwperks May 5, 2023
326422c
Merge branch 'main' into ssl-and-handler-naming
cwperks May 8, 2023
a926392
Remove extension: from action naming
cwperks May 8, 2023
f42db71
Merge branch 'main' into ssl-and-handler-naming
cwperks May 8, 2023
06f8e98
Merge branch 'main' into ssl-and-handler-naming
cwperks May 19, 2023
024aace
Add javadoc
cwperks May 19, 2023
9658efe
Fix test compilation errors
cwperks May 19, 2023
7aeef67
Consolidate registerHandler
cwperks May 19, 2023
786f01b
Fix missed registerHandler usage
cwperks May 19, 2023
70d9088
Fix javadoc
cwperks May 19, 2023
80ba90c
Add method to check if class is initialized
cwperks May 19, 2023
1e06d01
Fix failing tests
cwperks May 19, 2023
e0df300
Update helloworld-settings
cwperks May 19, 2023
058f12a
Merge branch 'main' into ssl-and-handler-naming
cwperks Jun 7, 2023
433a42a
Run spotlessApply
cwperks Jun 7, 2023
20885c0
Merge branch 'main' into ssl-and-handler-naming
cwperks Jun 13, 2023
ba60cb7
Run spotlessApply
cwperks Jun 13, 2023
f460699
Add shortExtensionName to BaseExtensionRouteHandler
cwperks Jun 13, 2023
6d2ee04
Merge branch 'main' into ssl-and-handler-naming
cwperks Jun 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/main/java/org/opensearch/sdk/ExtensionRouteHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright OpenSearch Contributors
* 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.sdk;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If this class stays, it should not be in the base package. Probably would fit in the .rest subpackage.


import org.opensearch.rest.RestRequest;
import org.opensearch.extensions.rest.ExtensionRestResponse;
import org.opensearch.extensions.rest.RouteHandler;

import java.util.function.Function;

public class ExtensionRouteHandler extends RouteHandler {

public ExtensionRouteHandler(
String handlerName,
RestRequest.Method method,
String path,
Function<RestRequest, ExtensionRestResponse> handler
) {
super(ExtensionRouteHandlerFactory.getInstance().generateRouteName(handlerName), method, path, handler);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm trying to understand why we need an entire (sub)class just to call a generator function for one parameter. I don't think this class is necessary; we should just stick in an appropriate (probably static) method that does this name generation whenever we call new RouteHandler() from an extension.

}
}
30 changes: 30 additions & 0 deletions src/main/java/org/opensearch/sdk/ExtensionRouteHandlerFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.opensearch.sdk;

import org.opensearch.OpenSearchException;

public class ExtensionRouteHandlerFactory {
private static ExtensionRouteHandlerFactory INSTANCE;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you think we can use Guice here to achieve this?

@cwperks cwperks May 19, 2023

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That would be great. I'll look into it. The main problem I was facing was that I needed to have the shortName of the extension available in the REST Handler (i.e. inside of RestHelloAction for the sample extension). The way I went about doing that was to create a singleton class that could be fetched throughout the SDK but if there is a better way to do it then I will switch to using that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if there is a better way to do it then I will switch to using that.

Extensions are always initialized with their settings. getExtensionSettings() must be implemented on the Extension interface. (The BaseExtension class offers the convenience of either a settings object or yml file.)

Any method on the mainExtension class ought to be able to call getExtensionSettings().getShortExtensionName() to access this value without any factory/singletons.

In the AD Extension we usually pass the ExtensionsRunner class to every REST handler, and we have a getter on the runner for the extension. So all the AD REST handlers can do runner.getExtension().getExtensionSettings().getShortExtensionName().


private String extensionShortName;

private ExtensionRouteHandlerFactory() { }

public static ExtensionRouteHandlerFactory getInstance() {
if(INSTANCE == null) {
INSTANCE = new ExtensionRouteHandlerFactory();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are we trying to create SINGLETON object for INSTANCE here? if yes is it multithreaded safe?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, the problem I was facing is that I needed the extensions shortName (abbreviation) inside the RestHandler classes like RestHelloAction in the sample extension. Instead of passing the value as a constructor arg or passing that extension runner into those classes, I thought it would be better to have singular place where its registered and can be used throughout.

Do you know how I can test if this is multi-threaded safe?


return INSTANCE;
}

public void init(String extensionShortName) {
if (this.extensionShortName != null) {
throw new OpenSearchException("ExtensionRouteHandlerFactory was previously initialized");
}
this.extensionShortName = extensionShortName;
}

public String generateRouteName(String handlerName) {
return extensionShortName + ":" + handlerName;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This method call doesn't check whether extensionShortName has been initialized. ExtensionRouteHandlerFactory.getInstance().generateRouteName() will throw an exception.

There's no documentation in this method that it requires initialization first.

This seems like a whole lot of class overhead, initializations, and initialization checks to create a factory object whose only purpose seems to be to prepend one string to another, that seems to be possible with a simple static method somewhere.

}
}
26 changes: 22 additions & 4 deletions src/main/java/org/opensearch/sdk/ExtensionSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public class ExtensionSettings {
private String hostPort;
private String opensearchAddress;
private String opensearchPort;
private String shortName;
private Map<String, String> securitySettings;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this also be final?


public static final Set<String> SECURITY_SETTINGS_KEYS = Set.of(
"path.home", // TODO Find the right place to put this setting
Expand All @@ -79,8 +81,6 @@ public class ExtensionSettings {
SSL_TRANSPORT_TRUSTSTORE_TYPE
);

private Map<String, String> securitySettings;

/**
* Jackson requires a no-arg constructor.
*/
Expand All @@ -93,14 +93,23 @@ private ExtensionSettings() {
* Instantiate this class using the specified parameters.
*
* @param extensionName The extension name. Provided to OpenSearch as a response to initialization query. Must match the defined extension name in OpenSearch.
* @param shortName The shortened name for the extension
* @param hostAddress The IP Address to bind this extension to.
* @param hostPort The port to bind this extension to.
* @param opensearchAddress The IP Address on which OpenSearch is running.
* @param opensearchPort The port on which OpenSearch is running.
*/
public ExtensionSettings(String extensionName, String hostAddress, String hostPort, String opensearchAddress, String opensearchPort) {
public ExtensionSettings(
String extensionName,
String shortName,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
String shortName,
String shortExtensionName,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll update it, I was torn between different names for this variable. One of the naming ideas was extensionAbbr, but I didn't know if was appropriate to use an abbreviation in a variable name signifying that this variable is an abbreviation. It felt like it was a crossword puzzle clue.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated

String hostAddress,
String hostPort,
String opensearchAddress,
String opensearchPort
) {
super();
this.extensionName = extensionName;
this.shortName = shortName;
this.hostAddress = hostAddress;
this.hostPort = hostPort;
this.opensearchAddress = opensearchAddress;
Expand All @@ -112,6 +121,7 @@ public ExtensionSettings(String extensionName, String hostAddress, String hostPo
* Instantiate this class using the specified parameters.
*
* @param extensionName The extension name. Provided to OpenSearch as a response to initialization query. Must match the defined extension name in OpenSearch.
* @param shortName The shortened name for the extension
* @param hostAddress The IP Address to bind this extension to.
* @param hostPort The port to bind this extension to.
* @param opensearchAddress The IP Address on which OpenSearch is running.
Expand All @@ -120,20 +130,25 @@ public ExtensionSettings(String extensionName, String hostAddress, String hostPo
*/
public ExtensionSettings(
String extensionName,
String shortName,
String hostAddress,
String hostPort,
String opensearchAddress,
String opensearchPort,
Map<String, String> securitySettings
) {
this(extensionName, hostAddress, hostPort, opensearchAddress, opensearchPort);
this(extensionName, shortName, hostAddress, hostPort, opensearchAddress, opensearchPort);
this.securitySettings = securitySettings;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This constructor overloading seems off somehow. Setting something and also calling another constructor seems unusual. Is there a way we can make this the primary constructor (that sets All The Things) and have all the other constructors delegate to it with defaults for the missing parameters?

}

public String getExtensionName() {
return extensionName;
}

public String getShortName() {
return shortName;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This getter should have a test in TestExtensionSettings.java

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This has been added to a few different tests to verify its behavior


public String getHostAddress() {
return hostAddress;
}
Expand Down Expand Up @@ -166,6 +181,8 @@ public Map<String, String> getSecuritySettings() {
public String toString() {
return "ExtensionSettings{extensionName="
+ extensionName
+ ", shortName="
+ shortName
+ ", hostAddress="
+ hostAddress
+ ", hostPort="
Expand Down Expand Up @@ -205,6 +222,7 @@ public static ExtensionSettings readSettingsFromYaml(String extensionSettingsPat
}
return new ExtensionSettings(
extensionMap.get("extensionName").toString(),
extensionMap.get("shortName").toString(),
extensionMap.get("hostAddress").toString(),
extensionMap.get("hostPort").toString(),
extensionMap.get("opensearchAddress").toString(),
Expand Down
21 changes: 20 additions & 1 deletion src/main/java/org/opensearch/sdk/ExtensionsRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.opensearch.extensions.proto.ExtensionRequestProto;
import org.opensearch.extensions.rest.ExtensionRestRequest;
import org.opensearch.extensions.rest.RegisterRestActionsRequest;
import org.opensearch.extensions.rest.RouteHandler;
import org.opensearch.extensions.settings.RegisterCustomSettingsRequest;
import org.opensearch.common.settings.Setting;
import org.opensearch.common.settings.Settings;
Expand All @@ -36,6 +37,7 @@
import org.opensearch.extensions.UpdateSettingsRequest;
import org.opensearch.extensions.action.ExtensionActionRequest;
import org.opensearch.index.IndicesModuleRequest;
import org.opensearch.rest.RestHandler;
import org.opensearch.sdk.action.SDKActionModule;
import org.opensearch.sdk.handlers.AcknowledgedResponseHandler;
import org.opensearch.sdk.api.ActionExtension;
Expand Down Expand Up @@ -195,6 +197,12 @@ protected ExtensionsRunner(Extension extension) throws IOException {
logger.info("SSL is " + sslText + " for transport");
this.settings = settingsBuilder.build();

if (extensionSettings.getShortName() != null) {
// initialize ExtensionRouteHandlerFactory
ExtensionRouteHandlerFactory factory = ExtensionRouteHandlerFactory.getInstance();
factory.init(extensionSettings.getShortName());
}

final List<ExecutorBuilder<?>> executorBuilders = extension.getExecutorBuilders(settings);

this.runnableTaskListener = new AtomicReference<>();
Expand Down Expand Up @@ -255,7 +263,18 @@ protected ExtensionsRunner(Extension extension) throws IOException {
if (extension instanceof ActionExtension) {
// store REST handlers in the registry
for (ExtensionRestHandler extensionRestHandler : ((ActionExtension) extension).getExtensionRestHandlers()) {
extensionRestPathRegistry.registerHandler(extensionRestHandler);
for (RestHandler.Route route : extensionRestHandler.routes()) {
if (route instanceof RouteHandler && ((RouteHandler) route).name() != null) {
extensionRestPathRegistry.registerHandler(
route.getMethod(),
route.getPath(),
((RouteHandler) route).name(),
extensionRestHandler
);
} else {
extensionRestPathRegistry.registerHandler(route.getMethod(), route.getPath(), extensionRestHandler);
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import java.util.List;
import java.util.Optional;
import java.util.Set;

import org.opensearch.extensions.rest.RouteHandler;
import org.opensearch.rest.BaseRestHandler;
import static org.opensearch.rest.RestStatus.INTERNAL_SERVER_ERROR;
import static org.opensearch.rest.RestStatus.NOT_FOUND;
Expand Down Expand Up @@ -206,36 +208,6 @@ protected final String unrecognized(
return BaseRestHandler.unrecognizedStrings(request, invalids, candidates, detail);
}

/**
* A subclass of {@link Route} that includes a handler method for that route.
*/
public static class RouteHandler extends Route {

private final Function<RestRequest, ExtensionRestResponse> responseHandler;

/**
* Handle the method and path with the specified handler.
*
* @param method The {@link Method} to handle.
* @param path The path to handle.
* @param handler The method which handles the method and path.
*/
public RouteHandler(Method method, String path, Function<RestRequest, ExtensionRestResponse> handler) {
super(method, path);
this.responseHandler = handler;
}

/**
* Executes the handler for this route.
*
* @param request The request to handle
* @return the {@link ExtensionRestResponse} result from the handler for this route.
*/
public ExtensionRestResponse handleRequest(RestRequest request) {
return responseHandler.apply(request);
}
}

/**
* A subclass of {@link DeprecatedRoute} that includes a handler method for that route.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void registerHandler(ExtensionRestHandler restHandler) {
* @param handler The handler to actually execute
* @param method GET, POST, etc.
*/
private void registerHandler(Method method, String path, ExtensionRestHandler extensionRestHandler) {
public void registerHandler(Method method, String path, ExtensionRestHandler extensionRestHandler) {
pathTrie.insertOrUpdate(
path,
new SDKMethodHandlers(path, extensionRestHandler, method),
Expand Down Expand Up @@ -133,6 +133,24 @@ private void registerWithDeprecatedHandler(
registerAsDeprecatedHandler(deprecatedMethod, deprecatedPath, handler, deprecationMessage);
}

/**
* Register a REST handler to handle a method and route in this extension's path registry.
*
* @param method The method to register.
* @param path The path to register. May include named wildcards.
* @param name An optional name of the REST handler
* @param extensionRestHandler The RestHandler to handle this route
*/
public void registerHandler(Method method, String path, String name, ExtensionRestHandler extensionRestHandler) {
pathTrie.insertOrUpdate(
path,
new SDKMethodHandlers(path, extensionRestHandler, method),
(mHandlers, newMHandler) -> mHandlers.addMethods(extensionRestHandler, method)
);
String restPathWithName = restPathToString(method, path, name);
registeredPaths.add(restPathWithName);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We are missing adding paths to deprecated paths here. One way to handle this would be to merge both the registerHandler methods and add a check for name.

}

/**
* Get the registered REST handler for the specified method and path.
*
Expand Down Expand Up @@ -176,4 +194,16 @@ public List<String> getRegisteredDeprecatedPaths() {
public static String restPathToString(Method method, String path) {
return method.name() + " " + path;
}

/**
* Converts a REST method and path to a space delimited string to be used as a map lookup key.
*
* @param method the method.
* @param path the path.
* @param name the name.
* @return A string appending the method and path.
*/
public static String restPathToString(Method method, String path, String name) {
return method.name() + " " + path + " " + name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.common.xcontent.json.JsonXContent;
import org.opensearch.extensions.rest.ExtensionRestResponse;
import org.opensearch.extensions.rest.RouteHandler;
import org.opensearch.rest.RestRequest;
import org.opensearch.sdk.ExtensionRouteHandlerFactory;
import org.opensearch.sdk.rest.BaseExtensionRestHandler;
import org.opensearch.sdk.rest.ExtensionRestHandler;
import org.opensearch.sdk.ExtensionRouteHandler;
import java.io.IOException;
import java.net.URLDecoder;
import java.nio.ByteBuffer;
Expand Down Expand Up @@ -50,13 +53,21 @@ public class RestHelloAction extends BaseExtensionRestHandler {
private List<String> worldAdjectives = new ArrayList<>();
private Random rand = new Random();

/**
* Instantiate this action
*
* @param runner The ExtensionsRunner instance
*/
public RestHelloAction() {
}

@Override
public List<RouteHandler> routeHandlers() {
return List.of(
new RouteHandler(GET, "/hello", handleGetRequest),
new RouteHandler(POST, "/hello", handlePostRequest),
new RouteHandler(PUT, "/hello/{name}", handlePutRequest),
new RouteHandler(DELETE, "/goodbye", handleDeleteRequest)
new ExtensionRouteHandler("greet", GET, "/hello", handleGetRequest),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This appears to be the only case where we are actually using the new ExtensionRouteHandler class.

This method signature is an override that only exists if we are extending BaseExtensionRestHandler so it seems to me we could add all this logic in that superclass. The BaseExtensionRestHandler class could fetch the shortname from the settings and then just expose a protected routePrefix(String name) method that returns "shortname:name". Then this line would just be new RouteHandler(routePrefix("greet"), GET, ...) and you'd save a ton of intermediate objects and initialization checking, etc.

new ExtensionRouteHandler("greet_with_adjective", POST, "/hello", handlePostRequest),
new ExtensionRouteHandler("greet_with_name", PUT, "/hello/{name}", handlePutRequest),
new ExtensionRouteHandler("goodbye", DELETE, "/goodbye", handleDeleteRequest)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.opensearch.extensions.ExtensionsManager;
import org.opensearch.extensions.action.RemoteExtensionActionResponse;
import org.opensearch.extensions.rest.ExtensionRestResponse;
import org.opensearch.extensions.rest.RouteHandler;
import org.opensearch.rest.RestRequest;
import org.opensearch.sdk.ExtensionsRunner;
import org.opensearch.sdk.SDKClient;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/sample/helloworld-settings.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
extensionName: hello-world
shortName: hw
hostAddress: 127.0.0.1
hostPort: 4532
opensearchAddress: 127.0.0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.junit.jupiter.api.Test;
import org.opensearch.common.bytes.BytesArray;
import org.opensearch.extensions.rest.ExtensionRestResponse;
import org.opensearch.extensions.rest.RouteHandler;
import org.opensearch.rest.RestHandler.Route;
import org.opensearch.rest.RestRequest;
import org.opensearch.rest.RestRequest.Method;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class TestHelloWorldExtension extends OpenSearchTestCase {
private Injector injector;
private SDKClient sdkClient;
private SDKRestClient sdkRestClient;
private final ExtensionSettings extensionSettings = new ExtensionSettings("", "", "", "localhost", "9200");
private final ExtensionSettings extensionSettings = new ExtensionSettings("", "hw", "", "", "localhost", "9200");

static class UnregisteredAction extends ActionType<SampleResponse> {
public static final String NAME = "helloworld/unregistered";
Expand Down Expand Up @@ -105,7 +105,7 @@ public void tearDown() throws Exception {
public void testExtensionSettings() {
// This effectively tests the Extension interface helper method
ExtensionSettings extensionSettings = extension.getExtensionSettings();
ExtensionSettings expected = new ExtensionSettings("hello-world", "127.0.0.1", "4532", "127.0.0.1", "9200");
ExtensionSettings expected = new ExtensionSettings("hello-world", "hw", "127.0.0.1", "4532", "127.0.0.1", "9200");
assertEquals(expected.getExtensionName(), extensionSettings.getExtensionName());
assertEquals(expected.getHostAddress(), extensionSettings.getHostAddress());
assertEquals(expected.getHostPort(), extensionSettings.getHostPort());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class TestRestHelloAction extends OpenSearchTestCase {
@BeforeEach
public void setUp() throws Exception {
super.setUp();
restHelloAction = new RestHelloAction();
restHelloAction = new RestHelloAction("hw");
}

@Test
Expand Down