Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into pits2.x
  • Loading branch information
bharath-techie committed Sep 28, 2022
2 parents 8a0b21d + c43c56c commit 92c1122
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased]
### Added
- Add support for s390x architecture ([#4001](https://github.com/opensearch-project/OpenSearch/pull/4001))
- Github workflow for changelog verification ([#4085](https://github.com/opensearch-project/OpenSearch/pull/4085))
- Point in time rest layer changes for create and delete PIT API ([#4064](https://github.com/opensearch-project/OpenSearch/pull/4064))
- Add failover support with Segment Replication enabled. ([#4325](https://github.com/opensearch-project/OpenSearch/pull/4325)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
public enum Architecture {

X64,
ARM64;
ARM64,
S390X;

public static Architecture current() {
final String architecture = System.getProperty("os.arch", "");
Expand All @@ -45,6 +46,8 @@ public static Architecture current() {
return X64;
case "aarch64":
return ARM64;
case "s390x":
return S390X;
default:
throw new IllegalArgumentException("can not determine architecture from [" + architecture + "]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ private String dependencyNotation(OpenSearchDistribution distribution) {
case X64:
classifier = ":" + distribution.getPlatform() + "-x64";
break;
case S390X:
classifier = ":" + distribution.getPlatform() + "-s390x";
break;
default:
throw new IllegalArgumentException("Unsupported architecture: " + distribution.getArchitecture());
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/org/opensearch/gradle/Jdk.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

public class Jdk implements Buildable, Iterable<File> {

private static final List<String> ALLOWED_ARCHITECTURES = Collections.unmodifiableList(Arrays.asList("aarch64", "x64"));
private static final List<String> ALLOWED_ARCHITECTURES = Collections.unmodifiableList(Arrays.asList("aarch64", "x64", "s390x"));
private static final List<String> ALLOWED_VENDORS = Collections.unmodifiableList(Arrays.asList("adoptium", "adoptopenjdk", "openjdk"));
private static final List<String> ALLOWED_PLATFORMS = Collections.unmodifiableList(
Arrays.asList("darwin", "freebsd", "linux", "mac", "windows")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.gradle;

import org.opensearch.gradle.test.GradleUnitTestCase;

public class ArchitectureTests extends GradleUnitTestCase {

final String architecture = System.getProperty("os.arch", "");

public void testCurrentArchitecture() {
assertEquals(Architecture.X64, currentArchitecture("amd64"));
assertEquals(Architecture.X64, currentArchitecture("x86_64"));
assertEquals(Architecture.ARM64, currentArchitecture("aarch64"));
assertEquals(Architecture.S390X, currentArchitecture("s390x"));
}

public void testInvalidCurrentArchitecture() {
assertThrows("can not determine architecture from [", IllegalArgumentException.class, () -> currentArchitecture("fooBar64"));
}

/**
* Determines the return value of {@link Architecture#current()} based on a string representing a potential OS Architecture.
*
* @param osArchToTest An expected value of the {@code os.arch} system property on another architecture.
* @return the value of the {@link Architecture} enum which would have resulted with the given value.
* @throws IllegalArgumentException if the string is not mapped to a value of the {@link Architecture} enum.
*/
private Architecture currentArchitecture(String osArchToTest) throws IllegalArgumentException {
// Test new architecture
System.setProperty("os.arch", osArchToTest);
try {
return Architecture.current();
} finally {
// Restore actual architecture property value
System.setProperty("os.arch", this.architecture);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void testUnknownArchitecture() {
"11.0.2+33",
"linux",
"unknown",
"unknown architecture [unknown] for jdk [testjdk], must be one of [aarch64, x64]"
"unknown architecture [unknown] for jdk [testjdk], must be one of [aarch64, x64, s390x]"
);
}

Expand Down
7 changes: 7 additions & 0 deletions distribution/archives/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ distribution_archives {
}
}

linuxS390xTar {
archiveClassifier = 'linux-s390x'
content {
archiveFiles(modulesFiles('linux-s390x'), 'tar', 'linux', 's390x', false)
}
}

windowsZip {
archiveClassifier = 'windows-x64'
content {
Expand Down
4 changes: 2 additions & 2 deletions distribution/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
// Setup all required JDKs
project.jdks {
['darwin', 'linux', 'windows'].each { platform ->
(platform == 'linux' || platform == 'darwin' ? ['x64', 'aarch64'] : ['x64']).each { architecture ->
(platform == 'linux' || platform == 'darwin' ? ['x64', 'aarch64', 's390x'] : ['x64']).each { architecture ->
"bundled_${platform}_${architecture}" {
it.platform = platform
it.version = VersionProperties.getBundledJdk(platform)
Expand Down Expand Up @@ -353,7 +353,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
}
}
def buildModules = buildModulesTaskProvider
List excludePlatforms = ['darwin-x64', 'freebsd-x64', 'linux-x64', 'linux-arm64', 'windows-x64', 'darwin-arm64']
List excludePlatforms = ['darwin-x64', 'freebsd-x64', 'linux-x64', 'linux-arm64', 'linux-s390x', 'windows-x64', 'darwin-arm64']
if (platform != null) {
excludePlatforms.remove(excludePlatforms.indexOf(platform))
} else {
Expand Down
8 changes: 8 additions & 0 deletions distribution/docker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ testFixtures.useFixture()

configurations {
arm64DockerSource
s390xDockerSource
dockerSource
}

dependencies {
arm64DockerSource project(path: ":distribution:archives:linux-arm64-tar", configuration:"default")
s390xDockerSource project(path: ":distribution:archives:linux-s390x-tar", configuration:"default")
dockerSource project(path: ":distribution:archives:linux-tar", configuration:"default")
}

Expand All @@ -42,6 +44,8 @@ ext.expansions = { Architecture architecture, DockerBase base, boolean local ->
classifier = "linux-arm64"
} else if (architecture == Architecture.X64) {
classifier = "linux-x64"
} else if (architecture == Architecture.S390X) {
classifier = "linux-s390x"
} else {
throw new IllegalArgumentException("Unsupported architecture [" + architecture + "]")
}
Expand Down Expand Up @@ -85,12 +89,14 @@ RUN curl --retry 8 -S -L \\
private static String buildPath(Architecture architecture, DockerBase base) {
return 'build/' +
(architecture == Architecture.ARM64 ? 'arm64-' : '') +
(architecture == Architecture.S390X ? 's390x-' : '') +
'docker'
}

private static String taskName(String prefix, Architecture architecture, DockerBase base, String suffix) {
return prefix +
(architecture == Architecture.ARM64 ? 'Arm64' : '') +
(architecture == Architecture.S390X ? 'S390x' : '') +
suffix
}

Expand Down Expand Up @@ -127,6 +133,8 @@ void addCopyDockerContextTask(Architecture architecture, DockerBase base) {

if (architecture == Architecture.ARM64) {
from configurations.arm64DockerSource
} else if (architecture == Architecture.S390X) {
from configurations.s390xDockerSource
} else {
from configurations.dockerSource
}
Expand Down
13 changes: 13 additions & 0 deletions distribution/docker/docker-s390x-export/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

// This file is intentionally blank. All configuration of the
// export is done in the parent project.
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ static class Arch {
Map<String, Arch> m = new HashMap<>();
m.put("amd64", new Arch(0xC000003E, 0x3FFFFFFF, 57, 58, 59, 322, 317));
m.put("aarch64", new Arch(0xC00000B7, 0xFFFFFFFF, 1079, 1071, 221, 281, 277));
m.put("s390x", new Arch(0x80000016, 0xFFFFFFFF, 2, 190, 11, 354, 348));
ARCHITECTURES = Collections.unmodifiableMap(m);
}

Expand Down
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ List projects = [
'distribution:archives:freebsd-tar',
'distribution:archives:no-jdk-freebsd-tar',
'distribution:archives:linux-arm64-tar',
'distribution:archives:linux-s390x-tar',
'distribution:archives:linux-tar',
'distribution:archives:no-jdk-linux-tar',
'distribution:docker',
'distribution:docker:docker-arm64-build-context',
'distribution:docker:docker-arm64-export',
'distribution:docker:docker-s390x-export',
'distribution:docker:docker-build-context',
'distribution:docker:docker-export',
'distribution:packages:arm64-deb',
Expand Down

0 comments on commit 92c1122

Please sign in to comment.