Skip to content

Commit

Permalink
Refactors test/fixtures as per OpenSearch naming (#370)
Browse files Browse the repository at this point in the history
Signed-off-by: Himanshu Setia <setiah@amazon.com>
  • Loading branch information
setiah authored and nknize committed Mar 20, 2021
1 parent 3d98ff6 commit c46a6bd
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 31 deletions.
4 changes: 2 additions & 2 deletions test/fixtures/azure-fixture/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.java'
apply plugin: 'elasticsearch.test.fixtures'
apply plugin: 'opensearch.java'
apply plugin: 'opensearch.test.fixtures'

description = 'Fixture for Azure external service'
test.enabled = false
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/gcs-fixture/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.java'
apply plugin: 'elasticsearch.test.fixtures'
apply plugin: 'opensearch.java'
apply plugin: 'opensearch.test.fixtures'

description = 'Fixture for Google Cloud Storage service'
test.enabled = false
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/hdfs-fixture/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

apply plugin: 'elasticsearch.java'
apply plugin: 'opensearch.java'

dependencies {
api "org.apache.hadoop:hadoop-minicluster:2.8.5"
Expand Down
12 changes: 6 additions & 6 deletions test/fixtures/hdfs-fixture/src/main/java/hdfs/MiniHDFS.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static void main(String[] args) throws Exception {
MiniDFSCluster dfs = builder.build();

// Configure contents of the filesystem
org.apache.hadoop.fs.Path esUserPath = new org.apache.hadoop.fs.Path("/user/elasticsearch");
org.apache.hadoop.fs.Path opensearchUserPath = new org.apache.hadoop.fs.Path("/user/opensearch");

FileSystem fs;
if (haEnabled) {
Expand All @@ -130,12 +130,12 @@ public static void main(String[] args) throws Exception {
}

try {
// Set the elasticsearch user directory up
fs.mkdirs(esUserPath);
// Set the opensearch user directory up
fs.mkdirs(opensearchUserPath);
if (UserGroupInformation.isSecurityEnabled()) {
List<AclEntry> acls = new ArrayList<>();
acls.add(new AclEntry.Builder().setType(AclEntryType.USER).setName("elasticsearch").setPermission(FsAction.ALL).build());
fs.modifyAclEntries(esUserPath, acls);
acls.add(new AclEntry.Builder().setType(AclEntryType.USER).setName("opensearch").setPermission(FsAction.ALL).build());
fs.modifyAclEntries(opensearchUserPath, acls);
}

// Install a pre-existing repository into HDFS
Expand All @@ -150,7 +150,7 @@ public static void main(String[] args) throws Exception {

fs.copyFromLocalFile(true, true,
new org.apache.hadoop.fs.Path(tempDirectory.resolve(directoryName).toAbsolutePath().toUri()),
esUserPath.suffix("/existing/" + directoryName)
opensearchUserPath.suffix("/existing/" + directoryName)
);

FileUtils.deleteDirectory(tempDirectory.toFile());
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/krb5kdc-fixture/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.test.fixtures'
apply plugin: 'opensearch.test.fixtures'

List<String> services = ["peppa", "hdfs"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

set -e

addprinc.sh "elasticsearch"
addprinc.sh "hdfs/hdfs.build.elastic.co"
addprinc.sh "opensearch"
#TODO(OpenSearch): fix username
addprinc.sh "hdfs/hdfs.build.opensearch.co"

# Use this as a signal that setup is complete
python3 -m http.server 4444 &

sleep infinity
sleep infinity
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

set -e

addprinc.sh elasticsearch
addprinc.sh opensearch
addprinc.sh HTTP/localhost
addprinc.sh peppa
addprinc.sh george dino

# Use this as a signal that setup is complete
python3 -m http.server 4444 &

sleep infinity
sleep infinity
2 changes: 1 addition & 1 deletion test/fixtures/minio-fixture/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.test.fixtures'
apply plugin: 'opensearch.test.fixtures'

description = 'Fixture for MinIO Storage service'

Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
* 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
a "ports" file with the port on which Elasticsearch is running.
"""

apply plugin: 'elasticsearch.java'
apply plugin: 'opensearch.java'
test.enabled = false

dependencies {
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 Elasticsearch that has been unzipped into an empty directory,
* Starts a version of OpenSearch 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 Elasticsearch before 5.0 because they do not support
* required for versions of OpenSearch before 5.0 because they do not support
* writing a "ports" file.
*/
public class OldElasticsearch {
public class OldOpenSearch {
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 es directory to contain a single child directory but contained none.");
System.err.println("expected the opensearch directory to contain a single child directory but contained none.");
System.exit(1);
}
Path esDir = children.next();
Path opensearchDir= children.next();
if (children.hasNext()) {
System.err.println("expected the es directory to contains a single child directory but contained [" + esDir + "] and ["
System.err.println("expected the opensearch directory to contains a single child directory but contained [" + opensearchDir+ "] and ["
+ children.next() + "].");
System.exit(1);
}
if (false == Files.isDirectory(esDir)) {
System.err.println("expected the es directory to contains a single child directory but contained a single child file.");
if (false == Files.isDirectory(opensearchDir)) {
System.err.println("expected the opensearch directory to contains a single child directory but contained a single child file.");
System.exit(1);
}

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

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

Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/s3-fixture/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.java'
apply plugin: 'elasticsearch.test.fixtures'
apply plugin: 'opensearch.java'
apply plugin: 'opensearch.test.fixtures'

description = 'Fixture for S3 Storage service'
test.enabled = false
Expand Down

0 comments on commit c46a6bd

Please sign in to comment.