Skip to content
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

[Rename] server/src/test/java/org/elasticsearch/bootstrap #217

Merged
merged 9 commits into from
Mar 11, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
* under the License.
*/

package org.elasticsearch.bootstrap;
package org.opensearch.bootstrap;

import org.apache.logging.log4j.Logger;
import org.apache.lucene.util.Constants;
import org.elasticsearch.cluster.coordination.ClusterBootstrapService;
import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.common.CheckedConsumer;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.BoundTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.discovery.DiscoveryModule;
import org.elasticsearch.discovery.SettingsBasedSeedHostsProvider;
import org.elasticsearch.monitor.jvm.JvmInfo;
import org.elasticsearch.node.NodeValidationException;
import org.elasticsearch.test.AbstractBootstrapCheckTestCase;
import org.opensearch.cluster.coordination.ClusterBootstrapService;
import org.opensearch.cluster.metadata.Metadata;
import org.opensearch.common.CheckedConsumer;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.transport.BoundTransportAddress;
import org.opensearch.common.transport.TransportAddress;
import org.opensearch.discovery.DiscoveryModule;
import org.opensearch.discovery.SettingsBasedSeedHostsProvider;
import org.opensearch.monitor.jvm.JvmInfo;
import org.opensearch.node.NodeValidationException;
import org.opensearch.test.AbstractBootstrapCheckTestCase;
import org.hamcrest.Matcher;

import java.net.InetAddress;
Expand All @@ -45,8 +45,8 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;

import static org.elasticsearch.discovery.DiscoveryModule.ZEN2_DISCOVERY_TYPE;
import static org.elasticsearch.discovery.DiscoveryModule.ZEN_DISCOVERY_TYPE;
import static org.opensearch.discovery.DiscoveryModule.ZEN2_DISCOVERY_TYPE;
import static org.opensearch.discovery.DiscoveryModule.ZEN_DISCOVERY_TYPE;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
Expand Down Expand Up @@ -287,7 +287,7 @@ boolean isMemoryLocked() {
Collections.singletonList(check)));
assertThat(
e.getMessage(),
containsString("memory locking requested for elasticsearch process but memory is not locked"));
containsString("memory locking requested for opensearch process but memory is not locked"));
} else {
// nothing should happen
BootstrapChecks.check(bootstrapContext, true, Collections.singletonList(check));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
* under the License.
*/

package org.elasticsearch.bootstrap;
package org.opensearch.bootstrap;

import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
import org.opensearch.common.settings.Settings;
import org.opensearch.test.OpenSearchTestCase;

public class BootstrapSettingsTests extends ESTestCase {
public class BootstrapSettingsTests extends OpenSearchTestCase {

public void testDefaultSettings() {
assertTrue(BootstrapSettings.SECURITY_FILTER_BAD_DEFAULTS_SETTING.get(Settings.EMPTY));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
* under the License.
*/

package org.elasticsearch.bootstrap;
package org.opensearch.bootstrap;

import org.apache.lucene.util.Constants;
import org.elasticsearch.test.ESTestCase;
import org.opensearch.test.OpenSearchTestCase;

import static org.hamcrest.Matchers.equalTo;

public class JNANativesTests extends ESTestCase {
public class JNANativesTests extends OpenSearchTestCase {
public void testMlockall() {
if (Constants.MAC_OS_X) {
assertFalse("Memory locking is not available on OS X platforms", JNANatives.LOCAL_MLOCKALL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
* under the License.
*/

package org.elasticsearch.bootstrap;
package org.opensearch.bootstrap;

import org.elasticsearch.test.ESTestCase;
import org.opensearch.test.OpenSearchTestCase;

import java.util.List;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;

public class JavaVersionTests extends ESTestCase {
public class JavaVersionTests extends OpenSearchTestCase {
public void testParse() {
JavaVersion javaVersion = JavaVersion.parse("1.7.0");
List<Integer> version = javaVersion.getVersion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
* under the License.
*/

package org.elasticsearch.bootstrap;
package org.opensearch.bootstrap;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.lucene.util.Constants;
import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.AbstractBootstrapCheckTestCase;
import org.elasticsearch.test.MockLogAppender;
import org.opensearch.cluster.metadata.Metadata;
import org.opensearch.common.io.PathUtils;
import org.opensearch.common.logging.Loggers;
import org.opensearch.common.settings.Settings;
import org.opensearch.test.AbstractBootstrapCheckTestCase;
import org.opensearch.test.MockLogAppender;

import java.io.BufferedReader;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
* under the License.
*/

package org.elasticsearch.bootstrap;
package org.opensearch.bootstrap;

import org.elasticsearch.Build;
import org.elasticsearch.cli.ExitCodes;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.monitor.jvm.JvmInfo;
import org.opensearch.Build;
import org.opensearch.cli.ExitCodes;
import org.opensearch.common.settings.Settings;
import org.opensearch.monitor.jvm.JvmInfo;

import java.nio.file.Path;
import java.util.Locale;
Expand All @@ -32,7 +32,7 @@
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.allOf;

public class ElasticsearchCliTests extends ESElasticsearchCliTestCase {
public class OpenSearchCliTests extends BaseOpenSearchCliTestCase {

public void testVersion() throws Exception {
runTestThatVersionIsMutuallyExclusiveToOtherOptions("-V", "-d");
Expand Down Expand Up @@ -149,7 +149,7 @@ private void runQuietTest(final boolean expectedQuiet, final String... args) thr
args);
}

public void testElasticsearchSettings() throws Exception {
public void testOpenSearchSettings() throws Exception {
runTest(
ExitCodes.OK,
true,
Expand All @@ -162,7 +162,7 @@ public void testElasticsearchSettings() throws Exception {
"-Efoo=bar", "-E", "baz=qux");
}

public void testElasticsearchSettingCanNotBeEmpty() throws Exception {
public void testOpenSearchSettingCanNotBeEmpty() throws Exception {
runTest(
ExitCodes.USAGE,
false,
Expand All @@ -171,7 +171,7 @@ public void testElasticsearchSettingCanNotBeEmpty() throws Exception {
"-E", "foo=");
}

public void testElasticsearchSettingCanNotBeDuplicated() throws Exception {
public void testOpenSsearchSettingCanNotBeDuplicated() throws Exception {
runTest(
ExitCodes.USAGE,
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
* under the License.
*/

package org.elasticsearch.bootstrap;
package org.opensearch.bootstrap;

import org.elasticsearch.test.ESTestCase;
import org.opensearch.test.OpenSearchTestCase;

import java.security.AccessControlContext;
import java.security.AccessController;
Expand All @@ -28,12 +28,12 @@
import java.security.PrivilegedAction;
import java.security.ProtectionDomain;

/**
* Tests for ESPolicy
/**
* Tests for OpenSearchPolicy
*/
public class ESPolicyTests extends ESTestCase {
public class OpenSearchPolicyTests extends OpenSearchTestCase {

/**
/**
* test restricting privileges to no permissions actually works
*/
public void testRestrictPrivileges() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
* under the License.
*/

package org.elasticsearch.bootstrap;
package org.opensearch.bootstrap;

import org.elasticsearch.test.ESTestCase;
import org.opensearch.test.OpenSearchTestCase;
import org.junit.Before;

import java.io.IOError;
Expand All @@ -34,7 +34,7 @@

import static org.hamcrest.CoreMatchers.equalTo;

public class ElasticsearchUncaughtExceptionHandlerTests extends ESTestCase {
public class OpenSearchUncaughtExceptionHandlerTests extends OpenSearchTestCase {

private Map<Class<? extends Error>, Integer> expectedStatus;

Expand Down Expand Up @@ -65,7 +65,7 @@ public void testUncaughtError() throws InterruptedException {
final AtomicInteger observedStatus = new AtomicInteger();
final AtomicReference<String> threadNameReference = new AtomicReference<>();
final AtomicReference<Throwable> throwableReference = new AtomicReference<>();
thread.setUncaughtExceptionHandler(new ElasticsearchUncaughtExceptionHandler() {
thread.setUncaughtExceptionHandler(new OpenSearchUncaughtExceptionHandler() {

@Override
void halt(int status) {
Expand Down Expand Up @@ -106,7 +106,7 @@ public void testUncaughtException() throws InterruptedException {
thread.setName(name);
final AtomicReference<String> threadNameReference = new AtomicReference<>();
final AtomicReference<Throwable> throwableReference = new AtomicReference<>();
thread.setUncaughtExceptionHandler(new ElasticsearchUncaughtExceptionHandler() {
thread.setUncaughtExceptionHandler(new OpenSearchUncaughtExceptionHandler() {
@Override
void halt(int status) {
fail();
Expand Down Expand Up @@ -140,11 +140,11 @@ public void testIsFatalCause() {
}

private void assertFatal(Throwable cause) {
assertTrue(ElasticsearchUncaughtExceptionHandler.isFatalUncaught(cause));
assertTrue(OpenSearchUncaughtExceptionHandler.isFatalUncaught(cause));
}

private void assertNonFatal(Throwable cause) {
assertFalse(ElasticsearchUncaughtExceptionHandler.isFatalUncaught(cause));
assertFalse(OpenSearchUncaughtExceptionHandler.isFatalUncaught(cause));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
* under the License.
*/

package org.elasticsearch.bootstrap;
package org.opensearch.bootstrap;

import org.elasticsearch.test.ESTestCase;
import org.opensearch.test.OpenSearchTestCase;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

public class SecurityTests extends ESTestCase {
public class SecurityTests extends OpenSearchTestCase {

public void testEnsureExists() throws IOException {
Path p = createTempDir();

Expand All @@ -36,16 +36,16 @@ public void testEnsureExists() throws IOException {
Security.ensureDirectoryExists(exists);
Files.createTempFile(exists, null, null);
}
public void testEnsureNotExists() throws IOException {

public void testEnsureNotExists() throws IOException {
Path p = createTempDir();

// directory does not exist: create it
Path notExists = p.resolve("notexists");
Security.ensureDirectoryExists(notExists);
Files.createTempFile(notExists, null, null);
}

public void testEnsureRegularFile() throws IOException {
Path p = createTempDir();

Expand All @@ -57,7 +57,7 @@ public void testEnsureRegularFile() throws IOException {
fail("didn't get expected exception");
} catch (IOException expected) {}
}

/** can't execute processes */
public void testProcessExecution() throws Exception {
assumeTrue("test requires security manager", System.getSecurityManager() != null);
Expand Down