Skip to content

Commit

Permalink
Remove support for legacy test clusters (#5303)
Browse files Browse the repository at this point in the history
This commit removes the support we added for running test clusters for legacy ES versions for bwc tests.

Signed-off-by: Rabi Panda <adnapibar@gmail.com>

Signed-off-by: Rabi Panda <adnapibar@gmail.com>
  • Loading branch information
adnapibar authored Nov 18, 2022
1 parent 7aa615f commit a0f022b
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 357 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.Objects;

/**
* A plugin to manage getting and extracting distributions of OpenSearch.
Expand All @@ -71,12 +70,6 @@ public class DistributionDownloadPlugin implements Plugin<Project> {
private static final String SNAPSHOT_REPO_NAME = "opensearch-snapshots";
public static final String DISTRO_EXTRACTED_CONFIG_PREFIX = "opensearch_distro_extracted_";

// for downloading Elasticsearch OSS distributions to run BWC
private static final String FAKE_IVY_GROUP_ES = "elasticsearch-distribution";
private static final String DOWNLOAD_REPO_NAME_ES = "elasticsearch-downloads";
private static final String SNAPSHOT_REPO_NAME_ES = "elasticsearch-snapshots";
private static final String FAKE_SNAPSHOT_IVY_GROUP_ES = "elasticsearch-distribution-snapshot";

private static final String RELEASE_PATTERN_LAYOUT = "/core/opensearch/[revision]/[module]-min-[revision](-[classifier]).[ext]";
private static final String SNAPSHOT_PATTERN_LAYOUT =
"/snapshots/core/opensearch/[revision]/[module]-min-[revision](-[classifier])-latest.[ext]";
Expand Down Expand Up @@ -159,35 +152,20 @@ private DistributionDependency resolveDependencyNotation(Project p, OpenSearchDi
return distributionsResolutionStrategiesContainer.stream()
.sorted(Comparator.comparingInt(DistributionResolution::getPriority))
.map(r -> r.getResolver().resolve(p, distribution))
.filter(d -> d != null)
.filter(Objects::nonNull)
.findFirst()
.orElseGet(() -> DistributionDependency.of(dependencyNotation(distribution)));
}

private static void addIvyRepo(Project project, String name, String url, String group, String... patternLayout) {
final List<IvyArtifactRepository> repos = Arrays.stream(patternLayout).map(pattern -> project.getRepositories().ivy(repo -> {
repo.setName(name);
repo.setUrl(url);
repo.metadataSources(IvyArtifactRepository.MetadataSources::artifact);
repo.patternLayout(layout -> layout.artifact(pattern));
})).collect(Collectors.toList());

project.getRepositories().exclusiveContent(exclusiveContentRepository -> {
exclusiveContentRepository.filter(config -> config.includeGroup(group));
exclusiveContentRepository.forRepositories(repos.toArray(new IvyArtifactRepository[0]));
});
}

private static void addIvyRepo2(Project project, String name, String url, String group) {
IvyArtifactRepository ivyRepo = project.getRepositories().ivy(repo -> {
repo.setName(name);
repo.setUrl(url);
repo.metadataSources(IvyArtifactRepository.MetadataSources::artifact);
repo.patternLayout(layout -> layout.artifact("/downloads/elasticsearch/elasticsearch-oss-[revision](-[classifier]).[ext]"));
});
project.getRepositories().exclusiveContent(exclusiveContentRepository -> {
exclusiveContentRepository.filter(config -> config.includeGroup(group));
exclusiveContentRepository.forRepositories(ivyRepo);
exclusiveContentRepository.forRepositories(Arrays.stream(patternLayout).map(pattern -> project.getRepositories().ivy(repo -> {
repo.setName(name);
repo.setUrl(url);
repo.metadataSources(IvyArtifactRepository.MetadataSources::artifact);
repo.patternLayout(layout -> layout.artifact(pattern));
})).toArray(IvyArtifactRepository[]::new));
});
}

Expand All @@ -211,9 +189,6 @@ private static void setupDownloadServiceRepo(Project project) {
);
addIvyRepo(project, SNAPSHOT_REPO_NAME, "https://artifacts.opensearch.org", FAKE_SNAPSHOT_IVY_GROUP, SNAPSHOT_PATTERN_LAYOUT);
}

addIvyRepo2(project, DOWNLOAD_REPO_NAME_ES, "https://artifacts-no-kpi.elastic.co", FAKE_IVY_GROUP_ES);
addIvyRepo2(project, SNAPSHOT_REPO_NAME_ES, "https://snapshots-no-kpi.elastic.co", FAKE_SNAPSHOT_IVY_GROUP_ES);
}

/**
Expand All @@ -222,59 +197,37 @@ private static void setupDownloadServiceRepo(Project project) {
* The returned object is suitable to be passed to {@link DependencyHandler}.
* The concrete type of the object will be a set of maven coordinates as a {@link String}.
* Maven coordinates point to either the integ-test-zip coordinates on maven central, or a set of artificial
* coordinates that resolve to the Elastic download service through an ivy repository.
* coordinates that resolve to the OpenSearch download service through an ivy repository.
*/
private String dependencyNotation(OpenSearchDistribution distribution) {
Version distroVersion = Version.fromString(distribution.getVersion());
if (distribution.getType() == Type.INTEG_TEST_ZIP) {
if (distroVersion.onOrAfter("1.0.0")) {
return "org.opensearch.distribution.integ-test-zip:opensearch:" + distribution.getVersion() + "@zip";
} else {
return "org.elasticsearch.distribution.integ-test-zip:elasticsearch:" + distribution.getVersion() + "@zip";
}
return "org.opensearch.distribution.integ-test-zip:opensearch:" + distribution.getVersion() + "@zip";
}

String extension = distribution.getType().toString();
String classifier = distroVersion.onOrAfter("1.0.0") ? ":x64" : ":x86_64";
if (distribution.getType() == Type.ARCHIVE) {
extension = distribution.getPlatform() == Platform.WINDOWS ? "zip" : "tar.gz";

if (distroVersion.onOrAfter("1.0.0")) {
switch (distribution.getArchitecture()) {
case ARM64:
classifier = ":" + distribution.getPlatform() + "-arm64";
break;
case X64:
classifier = ":" + distribution.getPlatform() + "-x64";
break;
case S390X:
classifier = ":" + distribution.getPlatform() + "-s390x";
break;
default:
throw new IllegalArgumentException("Unsupported architecture: " + distribution.getArchitecture());
}
} else if (distroVersion.onOrAfter("7.0.0")) {
classifier = ":" + distribution.getPlatform() + "-x86_64";
} else {
classifier = "";
switch (distribution.getArchitecture()) {
case ARM64:
classifier = ":" + distribution.getPlatform() + "-arm64";
break;
case X64:
classifier = ":" + distribution.getPlatform() + "-x64";
break;
case S390X:
classifier = ":" + distribution.getPlatform() + "-s390x";
break;
default:
throw new IllegalArgumentException("Unsupported architecture: " + distribution.getArchitecture());
}
} else if (distribution.getType() == Type.DEB) {
if (distroVersion.onOrAfter("7.0.0")) {
classifier = ":amd64";
} else {
classifier = "";
}
} else if (distribution.getType() == Type.RPM && distroVersion.before("7.0.0")) {
classifier = "";
classifier = ":amd64";
}

String group;
if (distroVersion.onOrAfter("1.0.0")) {
group = distribution.getVersion().endsWith("-SNAPSHOT") ? FAKE_SNAPSHOT_IVY_GROUP : FAKE_IVY_GROUP;
return group + ":opensearch" + ":" + distribution.getVersion() + classifier + "@" + extension;
} else {
group = distribution.getVersion().endsWith("-SNAPSHOT") ? FAKE_SNAPSHOT_IVY_GROUP_ES : FAKE_IVY_GROUP_ES;
return group + ":elasticsearch-oss" + ":" + distribution.getVersion() + classifier + "@" + extension;
}
String group = distribution.getVersion().endsWith("-SNAPSHOT") ? FAKE_SNAPSHOT_IVY_GROUP : FAKE_IVY_GROUP;
return group + ":opensearch" + ":" + distribution.getVersion() + classifier + "@" + extension;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
package org.opensearch.gradle.testclusters;

import org.opensearch.gradle.FileSupplier;
import org.opensearch.gradle.Jdk;
import org.opensearch.gradle.PropertyNormalization;
import org.opensearch.gradle.ReaperService;
import org.opensearch.gradle.http.WaitForHttpResource;
Expand Down Expand Up @@ -75,7 +74,6 @@ public class OpenSearchCluster implements TestClusterConfiguration, Named {
private final String path;
private final String clusterName;
private final NamedDomainObjectContainer<OpenSearchNode> nodes;
private final Jdk bwcJdk;
private final File workingDirBase;
private final LinkedHashMap<String, Predicate<TestClusterConfiguration>> waitConditions = new LinkedHashMap<>();
private final Project project;
Expand All @@ -92,8 +90,7 @@ public OpenSearchCluster(
ReaperService reaper,
File workingDirBase,
FileSystemOperations fileSystemOperations,
ArchiveOperations archiveOperations,
Jdk bwcJdk
ArchiveOperations archiveOperations
) {
this.path = project.getPath();
this.clusterName = clusterName;
Expand All @@ -103,7 +100,6 @@ public OpenSearchCluster(
this.archiveOperations = archiveOperations;
this.workingDirBase = workingDirBase;
this.nodes = project.container(OpenSearchNode.class);
this.bwcJdk = bwcJdk;

// Always add the first node
String zone = hasZoneProperty() ? "zone-1" : "";
Expand Down Expand Up @@ -167,7 +163,6 @@ private void addNode(String nodeName, String zoneName) {
fileSystemOperations,
archiveOperations,
workingDirBase,
bwcJdk,
zoneName
);
// configure the cluster name eagerly
Expand Down
Loading

0 comments on commit a0f022b

Please sign in to comment.