Skip to content

Commit

Permalink
Perform more renaming to OpenSearch.
Browse files Browse the repository at this point in the history
This commit performs more renaming to OpenSearch which were missed in the earlier commits.

Signed-off-by: Rabi Panda <adnapibar@gmail.com>
  • Loading branch information
adnapibar committed Mar 29, 2021
1 parent b255d11 commit 3c66237
Show file tree
Hide file tree
Showing 22 changed files with 71 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
package org.opensearch.gradle

import org.opensearch.gradle.fixtures.AbstractGradleFuncTest
import org.gradle.testkit.runner.GradleRunner
import spock.lang.IgnoreIf
import spock.lang.Requires
import spock.util.environment.OperatingSystem

import static org.opensearch.gradle.fixtures.DistributionDownloadFixture.withMockedDistributionDownload

Expand Down Expand Up @@ -70,8 +67,8 @@ class TestClustersPluginFuncTest extends AbstractGradleFuncTest {

then:
result.output.contains("opensearch-keystore script executed!")
assertEsStdoutContains("myCluster", "Starting OpenSearch process")
assertEsStdoutContains("myCluster", "Stopping node")
assertOpenSearchStdoutContains("myCluster", "Starting OpenSearch process")
assertOpenSearchStdoutContains("myCluster", "Stopping node")
assertNoCustomDistro('myCluster')
}

Expand All @@ -97,12 +94,12 @@ class TestClustersPluginFuncTest extends AbstractGradleFuncTest {

then:
result.output.contains("opensearch-keystore script executed!")
assertEsStdoutContains("myCluster", "Starting OpenSearch process")
assertEsStdoutContains("myCluster", "Stopping node")
assertOpenSearchStdoutContains("myCluster", "Starting OpenSearch process")
assertOpenSearchStdoutContains("myCluster", "Stopping node")
assertCustomDistro('myCluster')
}

boolean assertEsStdoutContains(String testCluster, String expectedOutput) {
boolean assertOpenSearchStdoutContains(String testCluster, String expectedOutput) {
assert new File(testProjectDir.root,
"build/testclusters/${testCluster}-0/logs/opensearch.stdout.log").text.contains(expectedOutput)
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class NodeInfo {
String executable

/** Path to the opensearch start script */
private Object esScript
private Object opensearchScript

/** script to run when running in the background */
private File wrapperScript
Expand Down Expand Up @@ -154,11 +154,11 @@ class NodeInfo {
* We have to delay building the string as the path will not exist during configuration which will fail on Windows due to
* getting the short name requiring the path to already exist.
*/
esScript = "${-> binPath().resolve('opensearch.bat').toString()}"
opensearchScript = "${-> binPath().resolve('opensearch.bat').toString()}"
} else {
executable = 'bash'
wrapperScript = new File(cwd, "run")
esScript = binPath().resolve('opensearch')
opensearchScript = binPath().resolve('opensearch')
}
if (config.daemonize) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
Expand All @@ -171,7 +171,7 @@ class NodeInfo {
args.add("${wrapperScript}")
}
} else {
args.add("${esScript}")
args.add("${opensearchScript}")
}


Expand Down Expand Up @@ -270,7 +270,7 @@ class NodeInfo {
argsPasser = '%*'
exitMarker = "\r\n if \"%errorlevel%\" neq \"0\" ( type nul >> run.failed )"
}
wrapperScript.setText("\"${esScript}\" ${argsPasser} > run.log 2>&1 ${exitMarker}", 'UTF-8')
wrapperScript.setText("\"${opensearchScript}\" ${argsPasser} > run.log 2>&1 ${exitMarker}", 'UTF-8')
}

/** Returns an address and port suitable for a uri to connect to this node over http */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public TaskProvider<? extends Task> createTask(Project project) {
resourcesTask.configure(t -> {
t.setOutputDir(resourcesDir.toFile());
t.copy("forbidden/jdk-signatures.txt");
t.copy("forbidden/es-all-signatures.txt");
t.copy("forbidden/es-test-signatures.txt");
t.copy("forbidden/opensearch-all-signatures.txt");
t.copy("forbidden/opensearch-test-signatures.txt");
t.copy("forbidden/http-signatures.txt");
t.copy("forbidden/es-server-signatures.txt");
t.copy("forbidden/opensearch-server-signatures.txt");
});
project.getTasks().withType(CheckForbiddenApis.class).configureEach(t -> {
t.dependsOn(resourcesTask);
Expand All @@ -79,22 +79,25 @@ public TaskProvider<? extends Task> createTask(Project project) {
}
t.setBundledSignatures(Set.of("jdk-unsafe", "jdk-deprecated", "jdk-non-portable", "jdk-system-out"));
t.setSignaturesFiles(
project.files(resourcesDir.resolve("forbidden/jdk-signatures.txt"), resourcesDir.resolve("forbidden/es-all-signatures.txt"))
project.files(
resourcesDir.resolve("forbidden/jdk-signatures.txt"),
resourcesDir.resolve("forbidden/opensearch-all-signatures.txt")
)
);
t.setSuppressAnnotations(Set.of("**.SuppressForbidden"));
if (t.getName().endsWith("Test")) {
t.setSignaturesFiles(
t.getSignaturesFiles()
.plus(
project.files(
resourcesDir.resolve("forbidden/es-test-signatures.txt"),
resourcesDir.resolve("forbidden/opensearch-test-signatures.txt"),
resourcesDir.resolve("forbidden/http-signatures.txt")
)
)
);
} else {
t.setSignaturesFiles(
t.getSignaturesFiles().plus(project.files(resourcesDir.resolve("forbidden/es-server-signatures.txt")))
t.getSignaturesFiles().plus(project.files(resourcesDir.resolve("forbidden/opensearch-server-signatures.txt")))
);
}
ExtraPropertiesExtension ext = t.getExtensions().getExtraProperties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,15 @@ public class OpenSearchNode implements TestClusterConfiguration {
private final Path confPathLogs;
private final Path transportPortFile;
private final Path httpPortsFile;
private final Path esStdoutFile;
private final Path esStderrFile;
private final Path esStdinFile;
private final Path opensearchStdoutFile;
private final Path opensearchStderrFile;
private final Path opensearchStdinFile;
private final Path tmpDir;

private int currentDistro = 0;
private TestDistribution testDistribution;
private List<OpenSearchDistribution> distributions = new ArrayList<>();
private volatile Process esProcess;
private volatile Process opensearchProcess;
private Function<String, String> nameCustomization = Function.identity();
private boolean isWorkingDirConfigured = false;
private String httpPort = "0";
Expand Down Expand Up @@ -191,9 +191,9 @@ public class OpenSearchNode implements TestClusterConfiguration {
confPathLogs = workingDir.resolve("logs");
transportPortFile = confPathLogs.resolve("transport.ports");
httpPortsFile = confPathLogs.resolve("http.ports");
esStdoutFile = confPathLogs.resolve("opensearch.stdout.log");
esStderrFile = confPathLogs.resolve("opensearch.stderr.log");
esStdinFile = workingDir.resolve("opensearch.stdin");
opensearchStdoutFile = confPathLogs.resolve("opensearch.stdout.log");
opensearchStderrFile = confPathLogs.resolve("opensearch.stderr.log");
opensearchStdinFile = workingDir.resolve("opensearch.stdin");
tmpDir = workingDir.resolve("tmp");
waitConditions.put("ports files", this::checkPortsFilesExistWithDelay);

Expand Down Expand Up @@ -438,7 +438,7 @@ public void freeze() {
* @return stream of log lines
*/
public Stream<String> logLines() throws IOException {
return Files.lines(esStdoutFile, StandardCharsets.UTF_8);
return Files.lines(opensearchStdoutFile, StandardCharsets.UTF_8);
}

@Override
Expand Down Expand Up @@ -540,11 +540,11 @@ private boolean canUseSharedDistribution() {

private void logToProcessStdout(String message) {
try {
if (Files.exists(esStdoutFile.getParent()) == false) {
Files.createDirectories(esStdoutFile.getParent());
if (Files.exists(opensearchStdoutFile.getParent()) == false) {
Files.createDirectories(opensearchStdoutFile.getParent());
}
Files.write(
esStdoutFile,
opensearchStdoutFile,
("[" + Instant.now().toString() + "] [BUILD] " + message + "\n").getBytes(StandardCharsets.UTF_8),
StandardOpenOption.CREATE,
StandardOpenOption.APPEND
Expand Down Expand Up @@ -784,24 +784,24 @@ private void startOpenSearchProcess() {
environment.putAll(getESEnvironment());

// don't buffer all in memory, make sure we don't block on the default pipes
processBuilder.redirectError(ProcessBuilder.Redirect.appendTo(esStderrFile.toFile()));
processBuilder.redirectOutput(ProcessBuilder.Redirect.appendTo(esStdoutFile.toFile()));
processBuilder.redirectError(ProcessBuilder.Redirect.appendTo(opensearchStderrFile.toFile()));
processBuilder.redirectOutput(ProcessBuilder.Redirect.appendTo(opensearchStdoutFile.toFile()));

if (keystorePassword != null && keystorePassword.length() > 0) {
try {
Files.write(esStdinFile, (keystorePassword + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE);
processBuilder.redirectInput(esStdinFile.toFile());
Files.write(opensearchStdinFile, (keystorePassword + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE);
processBuilder.redirectInput(opensearchStdinFile.toFile());
} catch (IOException e) {
throw new TestClustersException("Failed to set the keystore password for " + this, e);
}
}
LOGGER.info("Running `{}` in `{}` for {} env: {}", command, workingDir, this, environment);
try {
esProcess = processBuilder.start();
opensearchProcess = processBuilder.start();
} catch (IOException e) {
throw new TestClustersException("Failed to start ES process for " + this, e);
}
reaper.registerPid(toString(), esProcess.pid());
reaper.registerPid(toString(), opensearchProcess.pid());
}

@Internal
Expand Down Expand Up @@ -860,21 +860,21 @@ public synchronized void stop(boolean tailLogs) {
} catch (IOException e) {
throw new UncheckedIOException(e);
}
if (esProcess == null && tailLogs) {
if (opensearchProcess == null && tailLogs) {
// This is a special case. If start() throws an exception the plugin will still call stop
// Another exception here would eat the orriginal.
return;
}
LOGGER.info("Stopping `{}`, tailLogs: {}", this, tailLogs);
requireNonNull(esProcess, "Can't stop `" + this + "` as it was not started or already stopped.");
requireNonNull(opensearchProcess, "Can't stop `" + this + "` as it was not started or already stopped.");
// Test clusters are not reused, don't spend time on a graceful shutdown
stopHandle(esProcess.toHandle(), true);
stopHandle(opensearchProcess.toHandle(), true);
reaper.unregister(toString());
if (tailLogs) {
logFileContents("Standard output of node", esStdoutFile);
logFileContents("Standard error of node", esStderrFile);
logFileContents("Standard output of node", opensearchStdoutFile);
logFileContents("Standard error of node", opensearchStderrFile);
}
esProcess = null;
opensearchProcess = null;
// Clean up the ports file in case this is started again.
try {
if (Files.exists(httpPortsFile)) {
Expand Down Expand Up @@ -1348,8 +1348,8 @@ public List<?> getExtraConfigFiles() {
@Override
@Internal
public boolean isProcessAlive() {
requireNonNull(esProcess, "Can't wait for `" + this + "` as it's not started. Does the task have `useCluster` ?");
return esProcess.isAlive();
requireNonNull(opensearchProcess, "Can't wait for `" + this + "` as it's not started. Does the task have `useCluster` ?");
return opensearchProcess.isAlive();
}

void waitForAllConditions() {
Expand Down Expand Up @@ -1414,13 +1414,13 @@ void setDataPath(Path dataPath) {
}

@Internal
Path getEsStdoutFile() {
return esStdoutFile;
Path getOpensearchStdoutFile() {
return opensearchStdoutFile;
}

@Internal
Path getEsStderrFile() {
return esStderrFile;
Path getOpensearchStderrFile() {
return opensearchStderrFile;
}

private static class FileEntry implements Named {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void runAndWait() throws IOException {
try {
for (OpenSearchCluster cluster : getClusters()) {
for (OpenSearchNode node : cluster.getNodes()) {
BufferedReader reader = Files.newBufferedReader(node.getEsStdoutFile());
BufferedReader reader = Files.newBufferedReader(node.getOpensearchStdoutFile());
toRead.add(reader);
aliveChecks.add(node::isProcessAlive);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,11 @@ public void testSearchRequestAggregations() throws IOException {
{
BulkRequest request = new BulkRequest();
request.add(new IndexRequest("posts").id("1")
.source(XContentType.JSON, "company", "Elastic", "age", 20));
.source(XContentType.JSON, "company", "OpenSearch", "age", 20));
request.add(new IndexRequest("posts").id("2")
.source(XContentType.JSON, "company", "Elastic", "age", 30));
.source(XContentType.JSON, "company", "OpenSearch", "age", 30));
request.add(new IndexRequest("posts").id("3")
.source(XContentType.JSON, "company", "Elastic", "age", 40));
.source(XContentType.JSON, "company", "OpenSearch", "age", 40));
request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT);
assertSame(RestStatus.OK, bulkResponse.status());
Expand All @@ -334,7 +334,7 @@ public void testSearchRequestAggregations() throws IOException {
// tag::search-request-aggregations-get
Aggregations aggregations = searchResponse.getAggregations();
Terms byCompanyAggregation = aggregations.get("by_company"); // <1>
Bucket elasticBucket = byCompanyAggregation.getBucketByKey("Elastic"); // <2>
Bucket elasticBucket = byCompanyAggregation.getBucketByKey("OpenSearch"); // <2>
Avg averageAge = elasticBucket.getAggregations().get("average_age"); // <3>
double avg = averageAge.getValue();
// end::search-request-aggregations-get
Expand Down Expand Up @@ -368,7 +368,7 @@ public void testSearchRequestAggregations() throws IOException {
for (Aggregation agg : aggregations) {
String type = agg.getType();
if (type.equals(TermsAggregationBuilder.NAME)) {
Bucket elasticBucket = ((Terms) agg).getBucketByKey("Elastic");
Bucket elasticBucket = ((Terms) agg).getBucketByKey("OpenSearch");
long numberOfDocs = elasticBucket.getDocCount();
}
}
Expand Down Expand Up @@ -1404,7 +1404,7 @@ private static void indexCountTestData() throws IOException {
.source(XContentType.JSON, "title", "Doubling Down on Open?", "user",
Collections.singletonList("foobar"), "innerObject", Collections.singletonMap("key", "value")));
bulkRequest.add(new IndexRequest("blog").id("2")
.source(XContentType.JSON, "title", "Swiftype Joins Forces with Elastic", "user",
.source(XContentType.JSON, "title", "XYZ Joins Forces with OpenSearch", "user",
Arrays.asList("foobar", "matt"), "innerObject", Collections.singletonMap("key", "value")));
bulkRequest.add(new IndexRequest("blog").id("3")
.source(XContentType.JSON, "title", "On Net Neutrality", "user",
Expand Down
2 changes: 1 addition & 1 deletion client/transport/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies {
forbiddenApisTest {
// we don't use the core test-framework, no lucene classes present so we don't want the es-test-signatures to
// be pulled in
replaceSignatureFiles 'jdk-signatures', 'es-all-signatures'
replaceSignatureFiles 'jdk-signatures', 'opensearch-all-signatures'
}

testingConventions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private String getSortedDocValue(String field, SearchContext context, int docId)
BytesRef joinName = docValues.lookupOrd(ord);
return joinName.utf8ToString();
} catch (IOException e) {
throw ExceptionsHelper.convertToElastic(e);
throw ExceptionsHelper.convertToOpenSearchException(e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion server/src/main/java/org/opensearch/ExceptionsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static RuntimeException convertToRuntime(Exception e) {
return new OpenSearchException(e);
}

public static OpenSearchException convertToElastic(Exception e) {
public static OpenSearchException convertToOpenSearchException(Exception e) {
if (e instanceof OpenSearchException) {
return (OpenSearchException) e;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public ClusterState execute(ClusterState currentState) {
indicesService.verifyIndexMetadata(updatedMetadata, updatedMetadata);
}
} catch (IOException ex) {
throw ExceptionsHelper.convertToElastic(ex);
throw ExceptionsHelper.convertToOpenSearchException(ex);
}
return updatedState;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public BitSet getBitSet(LeafReaderContext context) throws IOException {
try {
return getAndLoadIfNotPresent(query, context);
} catch (ExecutionException e) {
throw ExceptionsHelper.convertToElastic(e);
throw ExceptionsHelper.convertToOpenSearchException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public static OpenSearchException newConfigurationException(String processorType

public static OpenSearchException newConfigurationException(String processorType, String processorTag,
String propertyName, Exception cause) {
OpenSearchException exception = ExceptionsHelper.convertToElastic(cause);
OpenSearchException exception = ExceptionsHelper.convertToOpenSearchException(cause);
addMetadataToException(exception, processorType, processorTag, propertyName);
return exception;
}
Expand Down
Loading

0 comments on commit 3c66237

Please sign in to comment.