Skip to content

Commit

Permalink
Reverts the rename for test/fixtures/old-elasticsearch done in #370 (#…
Browse files Browse the repository at this point in the history
…402)

Signed-off-by: Himanshu Setia <setiah@amazon.com>
  • Loading branch information
setiah authored and nknize committed Mar 20, 2021
1 parent 9d01f91 commit 47988e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
Expand All @@ -17,7 +17,6 @@
* under the License.
*/

//TODO(OpenSearch): Remove later if not needed.
description = """\
Launches versions of Elasticsearch prior to 5.0 for testing.
These need special handling because they do not support writing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
import java.util.regex.Pattern;

/**
* Starts a version of OpenSearch that has been unzipped into an empty directory,
* Starts a version of Elasticsearch that has been unzipped into an empty directory,
* instructing it to ask the OS for an unused port, grepping the logs for the port
* it actually got, and writing a {@code ports} file with the port. This is only
* required for versions of OpenSearch before 5.0 because they do not support
* required for versions of Elasticsearch before 5.0 because they do not support
* writing a "ports" file.
*/
public class OldOpenSearch {
public class OldElasticsearch {
public static void main(String[] args) throws IOException {
Path baseDir = Paths.get(args[0]);
Path unzipDir = Paths.get(args[1]);
Expand All @@ -65,22 +65,22 @@ public static void main(String[] args) throws IOException {

Iterator<Path> children = Files.list(unzipDir).iterator();
if (false == children.hasNext()) {
System.err.println("expected the opensearch directory to contain a single child directory but contained none.");
System.err.println("expected the es directory to contain a single child directory but contained none.");
System.exit(1);
}
Path opensearchDir= children.next();
Path esDir= children.next();
if (children.hasNext()) {
System.err.println("expected the opensearch directory to contains a single child directory but contained [" + opensearchDir+ "] and ["
System.err.println("expected the es directory to contains a single child directory but contained [" + esDir+ "] and ["
+ children.next() + "].");
System.exit(1);
}
if (false == Files.isDirectory(opensearchDir)) {
System.err.println("expected the opensearch directory to contains a single child directory but contained a single child file.");
if (false == Files.isDirectory(esDir)) {
System.err.println("expected the es directory to contains a single child directory but contained a single child file.");
System.exit(1);
}

Path bin = opensearchDir.resolve("bin").resolve("opensearch" + (Constants.WINDOWS ? ".bat" : ""));
Path config = opensearchDir.resolve("config").resolve("opensearch.yml");
Path bin = esDir.resolve("bin").resolve("elasticsearch" + (Constants.WINDOWS ? ".bat" : ""));
Path config = esDir.resolve("config").resolve("elasticsearch.yml");

Files.write(config, Arrays.asList("http.port: 0", "transport.tcp.port: 0", "network.host: 127.0.0.1"), StandardCharsets.UTF_8);

Expand Down

0 comments on commit 47988e6

Please sign in to comment.