From fafa4fc941d8708ed4e1d6f8f1bd58b2b9b8f71d Mon Sep 17 00:00:00 2001 From: Nick Knize Date: Fri, 12 Mar 2021 11:53:55 -0600 Subject: [PATCH] [Rename] Refactor ES and Elasticsearch classes in server module bootstrap package (#197) This commit refactors the heavily used ESPolicy, Elasticsearch (main class), and Elasticsearch prefixed test classes used in the bootstrap package under the server module. Refactoring the namespace will come in a separate commit. Signed-off-by: Nicholas Knize --- ...sts.java => OpenSearchExceptionTests.java} | 2 +- .../src/bin/elasticsearch-service.bat | 2 +- distribution/src/bin/elasticsearch.bat | 2 +- ...ts.java => OpenSearchPolicyUnitTests.java} | 4 +-- .../elasticsearch/bootstrap/Bootstrap.java | 14 ++++---- .../bootstrap/BootstrapChecks.java | 4 +-- .../elasticsearch/bootstrap/JNANatives.java | 2 +- .../{Elasticsearch.java => OpenSearch.java} | 36 +++++++++---------- .../{ESPolicy.java => OpenSearchPolicy.java} | 8 ++--- ...> OpenSearchUncaughtExceptionHandler.java} | 4 +-- .../org/elasticsearch/bootstrap/Security.java | 4 +-- ...s.java => OpenSearchNodeCommandTests.java} | 2 +- .../rest/BytesRestResponseTests.java | 2 +- .../bootstrap/BootstrapForTesting.java | 14 ++++---- ...ts.java => OpenSearchAssertionsTests.java} | 2 +- 15 files changed, 51 insertions(+), 51 deletions(-) rename client/rest-high-level/src/test/java/org/elasticsearch/client/tasks/{ElasticsearchExceptionTests.java => OpenSearchExceptionTests.java} (97%) rename qa/evil-tests/src/test/java/org/opensearch/bootstrap/{ESPolicyUnitTests.java => OpenSearchPolicyUnitTests.java} (95%) rename server/src/main/java/org/elasticsearch/bootstrap/{Elasticsearch.java => OpenSearch.java} (85%) rename server/src/main/java/org/elasticsearch/bootstrap/{ESPolicy.java => OpenSearchPolicy.java} (96%) rename server/src/main/java/org/elasticsearch/bootstrap/{ElasticsearchUncaughtExceptionHandler.java => OpenSearchUncaughtExceptionHandler.java} (94%) rename server/src/test/java/org/elasticsearch/cluster/coordination/{ElasticsearchNodeCommandTests.java => OpenSearchNodeCommandTests.java} (98%) rename test/framework/src/test/java/org/elasticsearch/test/hamcrest/{ElasticsearchAssertionsTests.java => OpenSearchAssertionsTests.java} (99%) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/tasks/ElasticsearchExceptionTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/tasks/OpenSearchExceptionTests.java similarity index 97% rename from client/rest-high-level/src/test/java/org/elasticsearch/client/tasks/ElasticsearchExceptionTests.java rename to client/rest-high-level/src/test/java/org/elasticsearch/client/tasks/OpenSearchExceptionTests.java index 95a88227c52..bcd95507917 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/tasks/ElasticsearchExceptionTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/tasks/OpenSearchExceptionTests.java @@ -26,7 +26,7 @@ import org.elasticsearch.common.xcontent.XContentType; import java.io.IOException; import java.util.Collections; -public class ElasticsearchExceptionTests extends AbstractResponseTestCase { @Override diff --git a/distribution/src/bin/elasticsearch-service.bat b/distribution/src/bin/elasticsearch-service.bat index 0b9300e9de6..7ba657b28de 100644 --- a/distribution/src/bin/elasticsearch-service.bat +++ b/distribution/src/bin/elasticsearch-service.bat @@ -207,7 +207,7 @@ if not "%SERVICE_USERNAME%" == "" ( set SERVICE_PARAMS=%SERVICE_PARAMS% --ServiceUser "%SERVICE_USERNAME%" --ServicePassword "%SERVICE_PASSWORD%" ) ) -"%EXECUTABLE%" //IS//%SERVICE_ID% --Startup %ES_START_TYPE% --StopTimeout %ES_STOP_TIMEOUT% --StartClass org.elasticsearch.bootstrap.Elasticsearch --StartMethod main ++StartParams --quiet --StopClass org.elasticsearch.bootstrap.Elasticsearch --StopMethod close --Classpath "%ES_CLASSPATH%" --JvmMs %JVM_MS% --JvmMx %JVM_MX% --JvmSs %JVM_SS% --JvmOptions %OTHER_JAVA_OPTS% ++JvmOptions %ES_PARAMS% %LOG_OPTS% --PidFile "%SERVICE_ID%.pid" --DisplayName "%SERVICE_DISPLAY_NAME%" --Description "%SERVICE_DESCRIPTION%" --Jvm "%JAVA_HOME%%JVM_DLL%" --StartMode jvm --StopMode jvm --StartPath "%ES_HOME%" %SERVICE_PARAMS% ++Environment HOSTNAME="%%COMPUTERNAME%%" +"%EXECUTABLE%" //IS//%SERVICE_ID% --Startup %ES_START_TYPE% --StopTimeout %ES_STOP_TIMEOUT% --StartClass org.elasticsearch.bootstrap.OpenSearch --StartMethod main ++StartParams --quiet --StopClass org.elasticsearch.bootstrap.OpenSearch --StopMethod close --Classpath "%ES_CLASSPATH%" --JvmMs %JVM_MS% --JvmMx %JVM_MX% --JvmSs %JVM_SS% --JvmOptions %OTHER_JAVA_OPTS% ++JvmOptions %ES_PARAMS% %LOG_OPTS% --PidFile "%SERVICE_ID%.pid" --DisplayName "%SERVICE_DISPLAY_NAME%" --Description "%SERVICE_DESCRIPTION%" --Jvm "%JAVA_HOME%%JVM_DLL%" --StartMode jvm --StopMode jvm --StartPath "%ES_HOME%" %SERVICE_PARAMS% ++Environment HOSTNAME="%%COMPUTERNAME%%" if not errorlevel 1 goto installed echo Failed installing '%SERVICE_ID%' service diff --git a/distribution/src/bin/elasticsearch.bat b/distribution/src/bin/elasticsearch.bat index eff3646445e..61be39687c9 100644 --- a/distribution/src/bin/elasticsearch.bat +++ b/distribution/src/bin/elasticsearch.bat @@ -101,7 +101,7 @@ ECHO.!KEYSTORE_PASSWORD!| %JAVA% %ES_JAVA_OPTS% -Delasticsearch ^ -Des.path.home="%ES_HOME%" -Des.path.conf="%ES_PATH_CONF%" ^ -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" ^ -Des.bundled_jdk="%ES_BUNDLED_JDK%" ^ - -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" !newparams! + -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.OpenSearch" !newparams! endlocal endlocal diff --git a/qa/evil-tests/src/test/java/org/opensearch/bootstrap/ESPolicyUnitTests.java b/qa/evil-tests/src/test/java/org/opensearch/bootstrap/OpenSearchPolicyUnitTests.java similarity index 95% rename from qa/evil-tests/src/test/java/org/opensearch/bootstrap/ESPolicyUnitTests.java rename to qa/evil-tests/src/test/java/org/opensearch/bootstrap/OpenSearchPolicyUnitTests.java index 72250a64fb4..834867ec830 100644 --- a/qa/evil-tests/src/test/java/org/opensearch/bootstrap/ESPolicyUnitTests.java +++ b/qa/evil-tests/src/test/java/org/opensearch/bootstrap/OpenSearchPolicyUnitTests.java @@ -37,7 +37,7 @@ import java.util.Collections; * Unit tests for ESPolicy: these cannot run with security manager, * we don't allow messing with the policy */ -public class ESPolicyUnitTests extends OpenSearchTestCase { +public class OpenSearchPolicyUnitTests extends OpenSearchTestCase { /** * Test policy with null codesource. *

@@ -78,7 +78,7 @@ public class ESPolicyUnitTests extends OpenSearchTestCase { final ESPolicy policy = new ESPolicy(Collections.emptyMap(), noPermissions, Collections.emptyMap(), true, new Permissions()); assertFalse( policy.implies( - new ProtectionDomain(ESPolicyUnitTests.class.getProtectionDomain().getCodeSource(), noPermissions), + new ProtectionDomain(OpenSearchPolicyUnitTests.class.getProtectionDomain().getCodeSource(), noPermissions), new SocketPermission("localhost:" + randomFrom(0, randomIntBetween(49152, 65535)), "listen"))); } diff --git a/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java b/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java index 20169659a81..dba09f4a3df 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java @@ -91,7 +91,7 @@ final class Bootstrap { // bail out } } - }, "elasticsearch[keepAlive/" + Version.CURRENT + "]"); + }, "opensearch[keepAlive/" + Version.CURRENT + "]"); keepAliveThread.setDaemon(false); // keep this thread alive (non daemon thread) until we shutdown Runtime.getRuntime().addShutdownHook(new Thread() { @@ -108,7 +108,7 @@ final class Bootstrap { // check if the user is running as root, and bail if (Natives.definitelyRunningAsRoot()) { - throw new RuntimeException("can not run elasticsearch as root"); + throw new RuntimeException("can not run opensearch as root"); } // enable system call filter @@ -333,7 +333,7 @@ final class Bootstrap { } /** - * This method is invoked by {@link Elasticsearch#main(String[])} to startup elasticsearch. + * This method is invoked by {@link OpenSearch#main(String[])} to startup opensearch. */ static void init( final boolean foreground, @@ -358,7 +358,7 @@ final class Bootstrap { if (JavaVersion.current().compareTo(JavaVersion.parse("11")) < 0) { final String message = String.format( Locale.ROOT, - "future versions of Elasticsearch will require Java 11; " + + "future versions of OpenSearch will require Java 11; " + "your Java version from [%s] does not meet this requirement", System.getProperty("java.home")); DeprecationLogger.getLogger(Bootstrap.class).deprecate("java_version_11_required", message); @@ -388,7 +388,7 @@ final class Bootstrap { // install the default uncaught exception handler; must be done before security is // initialized as we do not want to grant the runtime permission // setDefaultUncaughtExceptionHandler - Thread.setDefaultUncaughtExceptionHandler(new ElasticsearchUncaughtExceptionHandler()); + Thread.setDefaultUncaughtExceptionHandler(new OpenSearchUncaughtExceptionHandler()); INSTANCE.setup(true, environment); @@ -402,7 +402,7 @@ final class Bootstrap { INSTANCE.start(); // We don't close stderr if `--quiet` is passed, because that - // hides fatal startup errors. For example, if Elasticsearch is + // hides fatal startup errors. For example, if OpenSearch is // running via systemd, the init script only specifies // `--quiet`, not `-d`, so we want users to be able to see // startup errors via journalctl. @@ -463,7 +463,7 @@ final class Bootstrap { private static void checkLucene() { if (Version.CURRENT.luceneVersion.equals(org.apache.lucene.util.Version.LATEST) == false) { - throw new AssertionError("Lucene version mismatch this version of Elasticsearch requires lucene version [" + throw new AssertionError("Lucene version mismatch this version of OpenSearch requires lucene version [" + Version.CURRENT.luceneVersion + "] but the current lucene version is [" + org.apache.lucene.util.Version.LATEST + "]"); } } diff --git a/server/src/main/java/org/elasticsearch/bootstrap/BootstrapChecks.java b/server/src/main/java/org/elasticsearch/bootstrap/BootstrapChecks.java index d128c51a4b8..08d89dd8da6 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/BootstrapChecks.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/BootstrapChecks.java @@ -386,7 +386,7 @@ final class BootstrapChecks { } /** - * Bootstrap check that the maximum file size is unlimited (otherwise Elasticsearch could run in to an I/O exception writing files). + * Bootstrap check that the maximum file size is unlimited (otherwise OpenSearch could run in to an I/O exception writing files). */ static class MaxFileSizeCheck implements BootstrapCheck { @@ -507,7 +507,7 @@ final class BootstrapChecks { /** * Checks if the serial collector is in use. This collector is single-threaded and devastating - * for performance and should not be used for a server application like Elasticsearch. + * for performance and should not be used for a server application like OpenSearch. */ static class UseSerialGCCheck implements BootstrapCheck { diff --git a/server/src/main/java/org/elasticsearch/bootstrap/JNANatives.java b/server/src/main/java/org/elasticsearch/bootstrap/JNANatives.java index 232da7e2534..2d9fe1e8515 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/JNANatives.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/JNANatives.java @@ -51,7 +51,7 @@ class JNANatives { // otherwise they are only inherited for new threads (ES app threads) static boolean LOCAL_SYSTEM_CALL_FILTER_ALL = false; // set to the maximum number of threads that can be created for - // the user ID that owns the running Elasticsearch process + // the user ID that owns the running OpenSearch process static long MAX_NUMBER_OF_THREADS = -1; static long MAX_SIZE_VIRTUAL_MEMORY = Long.MIN_VALUE; diff --git a/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java b/server/src/main/java/org/elasticsearch/bootstrap/OpenSearch.java similarity index 85% rename from server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java rename to server/src/main/java/org/elasticsearch/bootstrap/OpenSearch.java index 13a3d58c939..687e26a4601 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/OpenSearch.java @@ -30,8 +30,8 @@ import org.opensearch.cli.Terminal; import org.opensearch.cli.UserException; import org.elasticsearch.common.logging.LogConfigurator; import org.elasticsearch.env.Environment; -import org.elasticsearch.monitor.jvm.JvmInfo; -import org.elasticsearch.node.NodeValidationException; +import org.opensearch.monitor.jvm.JvmInfo; +import org.opensearch.node.NodeValidationException; import java.io.IOException; import java.nio.file.Path; @@ -41,9 +41,9 @@ import java.util.Arrays; import java.util.Locale; /** - * This class starts elasticsearch. + * This class starts opensearch. */ -class Elasticsearch extends EnvironmentAwareCommand { +class OpenSearch extends EnvironmentAwareCommand { private final OptionSpecBuilder versionOption; private final OptionSpecBuilder daemonizeOption; @@ -51,12 +51,12 @@ class Elasticsearch extends EnvironmentAwareCommand { private final OptionSpecBuilder quietOption; // visible for testing - Elasticsearch() { - super("Starts Elasticsearch", () -> {}); // we configure logging later so we override the base class from configuring logging + OpenSearch() { + super("Starts OpenSearch", () -> {}); // we configure logging later so we override the base class from configuring logging versionOption = parser.acceptsAll(Arrays.asList("V", "version"), - "Prints Elasticsearch version information and exits"); + "Prints OpenSearch version information and exits"); daemonizeOption = parser.acceptsAll(Arrays.asList("d", "daemonize"), - "Starts Elasticsearch in the background") + "Starts OpenSearch in the background") .availableUnless(versionOption); pidfileOption = parser.acceptsAll(Arrays.asList("p", "pidfile"), "Creates a pid file in the specified path on start") @@ -70,7 +70,7 @@ class Elasticsearch extends EnvironmentAwareCommand { } /** - * Main entry point for starting elasticsearch + * Main entry point for starting opensearch */ public static void main(final String[] args) throws Exception { overrideDnsCachePolicyProperties(); @@ -88,18 +88,18 @@ class Elasticsearch extends EnvironmentAwareCommand { }); LogConfigurator.registerErrorListener(); - final Elasticsearch elasticsearch = new Elasticsearch(); - int status = main(args, elasticsearch, Terminal.DEFAULT); + final OpenSearch opensearch = new OpenSearch(); + int status = main(args, opensearch, Terminal.DEFAULT); if (status != ExitCodes.OK) { - final String basePath = System.getProperty("es.logs.base_path"); + final String basePath = System.getProperty("opensearch.logs.base_path"); // It's possible to fail before logging has been configured, in which case there's no point // suggesting that the user look in the log file. if (basePath != null) { Terminal.DEFAULT.errorPrintln( - "ERROR: Elasticsearch did not exit normally - check the logs at " + "ERROR: OpenSearch did not exit normally - check the logs at " + basePath + System.getProperty("file.separator") - + System.getProperty("es.logs.cluster_name") + ".log" + + System.getProperty("opensearch.logs.cluster_name") + ".log" ); } exit(status); @@ -108,7 +108,7 @@ class Elasticsearch extends EnvironmentAwareCommand { private static void overrideDnsCachePolicyProperties() { for (final String property : new String[] {"networkaddress.cache.ttl", "networkaddress.cache.negative.ttl" }) { - final String overrideProperty = "es." + property; + final String overrideProperty = "opensearch." + property; final String overrideValue = System.getProperty(overrideProperty); if (overrideValue != null) { try { @@ -122,8 +122,8 @@ class Elasticsearch extends EnvironmentAwareCommand { } } - static int main(final String[] args, final Elasticsearch elasticsearch, final Terminal terminal) throws Exception { - return elasticsearch.main(args, terminal); + static int main(final String[] args, final OpenSearch opensearch, final Terminal terminal) throws Exception { + return opensearch.main(args, terminal); } @Override @@ -181,7 +181,7 @@ class Elasticsearch extends EnvironmentAwareCommand { * http://commons.apache.org/proper/commons-daemon/procrun.html * * NOTE: If this method is renamed and/or moved, make sure to - * update elasticsearch-service.bat! + * update opensearch-service.bat! */ static void close(String[] args) throws IOException { Bootstrap.stop(); diff --git a/server/src/main/java/org/elasticsearch/bootstrap/ESPolicy.java b/server/src/main/java/org/elasticsearch/bootstrap/OpenSearchPolicy.java similarity index 96% rename from server/src/main/java/org/elasticsearch/bootstrap/ESPolicy.java rename to server/src/main/java/org/elasticsearch/bootstrap/OpenSearchPolicy.java index 7e4fc79c93d..376be256e47 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/ESPolicy.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/OpenSearchPolicy.java @@ -36,7 +36,7 @@ import java.util.Map; import java.util.function.Predicate; /** custom policy for union of static and dynamic permissions */ -final class ESPolicy extends Policy { +final class OpenSearchPolicy extends Policy { /** template policy file, the one used in tests */ static final String POLICY_RESOURCE = "security.policy"; @@ -50,8 +50,8 @@ final class ESPolicy extends Policy { final PermissionCollection dataPathPermission; final Map plugins; - ESPolicy(Map codebases, PermissionCollection dynamic, Map plugins, boolean filterBadDefaults, - PermissionCollection dataPathPermission) { + OpenSearchPolicy(Map codebases, PermissionCollection dynamic, Map plugins, boolean filterBadDefaults, + PermissionCollection dataPathPermission) { this.template = Security.readPolicy(getClass().getResource(POLICY_RESOURCE), codebases); this.dataPathPermission = dataPathPermission; this.untrusted = Security.readPolicy(getClass().getResource(UNTRUSTED_RESOURCE), Collections.emptyMap()); @@ -102,7 +102,7 @@ final class ESPolicy extends Policy { } // The FilePermission to check access to the path.data is the hottest permission check in - // Elasticsearch, so we check it first. + // OpenSearch, so we check it first. if (permission instanceof FilePermission && dataPathPermission.implies(permission)) { return true; } diff --git a/server/src/main/java/org/elasticsearch/bootstrap/ElasticsearchUncaughtExceptionHandler.java b/server/src/main/java/org/elasticsearch/bootstrap/OpenSearchUncaughtExceptionHandler.java similarity index 94% rename from server/src/main/java/org/elasticsearch/bootstrap/ElasticsearchUncaughtExceptionHandler.java rename to server/src/main/java/org/elasticsearch/bootstrap/OpenSearchUncaughtExceptionHandler.java index 9f2d2a8c6bf..5f788fccd7a 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/ElasticsearchUncaughtExceptionHandler.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/OpenSearchUncaughtExceptionHandler.java @@ -28,8 +28,8 @@ import java.io.IOError; import java.security.AccessController; import java.security.PrivilegedAction; -class ElasticsearchUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler { - private static final Logger logger = LogManager.getLogger(ElasticsearchUncaughtExceptionHandler.class); +class OpenSearchUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler { + private static final Logger logger = LogManager.getLogger(OpenSearchUncaughtExceptionHandler.class); @Override public void uncaughtException(Thread thread, Throwable t) { diff --git a/server/src/main/java/org/elasticsearch/bootstrap/Security.java b/server/src/main/java/org/elasticsearch/bootstrap/Security.java index 48739d4dc50..2f5634bad33 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/Security.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/Security.java @@ -118,14 +118,14 @@ final class Security { // enable security policy: union of template and environment-based paths, and possibly plugin permissions Map codebases = getCodebaseJarMap(JarHell.parseClassPath()); - Policy.setPolicy(new ESPolicy(codebases, createPermissions(environment), getPluginPermissions(environment), filterBadDefaults, + Policy.setPolicy(new OpenSearchPolicy(codebases, createPermissions(environment), getPluginPermissions(environment), filterBadDefaults, createRecursiveDataPathPermission(environment))); // enable security manager final String[] classesThatCanExit = new String[]{ // SecureSM matches class names as regular expressions so we escape the $ that arises from the nested class name - ElasticsearchUncaughtExceptionHandler.PrivilegedHaltAction.class.getName().replace("$", "\\$"), + OpenSearchUncaughtExceptionHandler.PrivilegedHaltAction.class.getName().replace("$", "\\$"), Command.class.getName()}; System.setSecurityManager(new SecureSM(classesThatCanExit)); diff --git a/server/src/test/java/org/elasticsearch/cluster/coordination/ElasticsearchNodeCommandTests.java b/server/src/test/java/org/elasticsearch/cluster/coordination/OpenSearchNodeCommandTests.java similarity index 98% rename from server/src/test/java/org/elasticsearch/cluster/coordination/ElasticsearchNodeCommandTests.java rename to server/src/test/java/org/elasticsearch/cluster/coordination/OpenSearchNodeCommandTests.java index 9848ddf9ece..665b651efd1 100644 --- a/server/src/test/java/org/elasticsearch/cluster/coordination/ElasticsearchNodeCommandTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/coordination/OpenSearchNodeCommandTests.java @@ -48,7 +48,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.not; -public class ElasticsearchNodeCommandTests extends ESTestCase { +public class OpenSearchNodeCommandTests extends ESTestCase { public void testLoadStateWithoutMissingCustoms() throws IOException { runLoadStateTest(false, false); diff --git a/server/src/test/java/org/opensearch/rest/BytesRestResponseTests.java b/server/src/test/java/org/opensearch/rest/BytesRestResponseTests.java index 0af39bedf86..ea660b96a24 100644 --- a/server/src/test/java/org/opensearch/rest/BytesRestResponseTests.java +++ b/server/src/test/java/org/opensearch/rest/BytesRestResponseTests.java @@ -44,7 +44,7 @@ import java.io.IOException; import java.util.Collections; import java.util.Map; -import static org.elasticsearch.ElasticsearchExceptionTests.assertDeepEquals; +import static org.opensearch.OpenSearchExceptionTests.assertDeepEquals; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; diff --git a/test/framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java b/test/framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java index 05f553afa7b..a514157ab68 100644 --- a/test/framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java +++ b/test/framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java @@ -139,22 +139,22 @@ public class BootstrapForTesting { // read test-framework permissions Map codebases = Security.getCodebaseJarMap(JarHell.parseClassPath()); - // when testing server, the main elasticsearch code is not yet in a jar, so we need to manually add it - addClassCodebase(codebases,"elasticsearch", "org.elasticsearch.plugins.PluginsService"); + // when testing server, the main opensearch code is not yet in a jar, so we need to manually add it + addClassCodebase(codebases,"opensearch", "org.elasticsearch.plugins.PluginsService"); if (System.getProperty("tests.gradle") == null) { // intellij and eclipse don't package our internal libs, so we need to set the codebases for them manually addClassCodebase(codebases,"plugin-classloader", "org.elasticsearch.plugins.ExtendedPluginsClassLoader"); - addClassCodebase(codebases,"elasticsearch-nio", "org.elasticsearch.nio.ChannelFactory"); - addClassCodebase(codebases, "elasticsearch-secure-sm", "org.elasticsearch.secure_sm.SecureSM"); - addClassCodebase(codebases, "elasticsearch-rest-client", "org.elasticsearch.client.RestClient"); + addClassCodebase(codebases,"opensearch-nio", "org.elasticsearch.nio.ChannelFactory"); + addClassCodebase(codebases, "opensearch-secure-sm", "org.elasticsearch.secure_sm.SecureSM"); + addClassCodebase(codebases, "opensearch-rest-client", "org.elasticsearch.client.RestClient"); } final Policy testFramework = Security.readPolicy(Bootstrap.class.getResource("test-framework.policy"), codebases); - final Policy esPolicy = new ESPolicy(codebases, perms, getPluginPermissions(), true, new Permissions()); + final Policy opensearchPolicy = new OpenSearchPolicy(codebases, perms, getPluginPermissions(), true, new Permissions()); Policy.setPolicy(new Policy() { @Override public boolean implies(ProtectionDomain domain, Permission permission) { // implements union - return esPolicy.implies(domain, permission) || testFramework.implies(domain, permission); + return opensearchPolicy.implies(domain, permission) || testFramework.implies(domain, permission); } }); System.setSecurityManager(SecureSM.createTestSecureSM()); diff --git a/test/framework/src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertionsTests.java b/test/framework/src/test/java/org/elasticsearch/test/hamcrest/OpenSearchAssertionsTests.java similarity index 99% rename from test/framework/src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertionsTests.java rename to test/framework/src/test/java/org/elasticsearch/test/hamcrest/OpenSearchAssertionsTests.java index 7dc3fd9e532..6d4deef58f1 100644 --- a/test/framework/src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertionsTests.java +++ b/test/framework/src/test/java/org/elasticsearch/test/hamcrest/OpenSearchAssertionsTests.java @@ -43,7 +43,7 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBloc import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertToXContentEquivalent; import static org.hamcrest.Matchers.containsString; -public class ElasticsearchAssertionsTests extends ESTestCase { +public class OpenSearchAssertionsTests extends ESTestCase { public void testAssertXContentEquivalent() throws IOException { try (XContentBuilder original = JsonXContent.contentBuilder()) {