mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-23 21:38:15 +00:00
Add snapshot support to distribution download plugin (#47837)
The distribution download plugin which handles finding built distributions for testing currently only knows how to find locally built snapshots. When an external Elasticsearch plugin uses build-tools, these snapshots do not exist. This commit extends the download plugin so it pulls from the Elastic snapshots service when used outside of the Elasticsearch repository. closes #47123
This commit is contained in:
parent
6ab58de7ef
commit
dc8080e88a
@ -22,6 +22,7 @@ package org.elasticsearch.gradle;
|
||||
import org.elasticsearch.gradle.ElasticsearchDistribution.Flavor;
|
||||
import org.elasticsearch.gradle.ElasticsearchDistribution.Platform;
|
||||
import org.elasticsearch.gradle.ElasticsearchDistribution.Type;
|
||||
import org.elasticsearch.gradle.tool.ClasspathUtils;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.NamedDomainObjectContainer;
|
||||
import org.gradle.api.Plugin;
|
||||
@ -56,7 +57,9 @@ public class DistributionDownloadPlugin implements Plugin<Project> {
|
||||
|
||||
private static final String CONTAINER_NAME = "elasticsearch_distributions";
|
||||
private static final String FAKE_IVY_GROUP = "elasticsearch-distribution";
|
||||
private static final String FAKE_SNAPSHOT_IVY_GROUP = "elasticsearch-distribution-snapshot";
|
||||
private static final String DOWNLOAD_REPO_NAME = "elasticsearch-downloads";
|
||||
private static final String SNAPSHOT_REPO_NAME = "elasticsearch-snapshots";
|
||||
|
||||
private BwcVersions bwcVersions;
|
||||
private NamedDomainObjectContainer<ElasticsearchDistribution> distributionsContainer;
|
||||
@ -72,9 +75,10 @@ public class DistributionDownloadPlugin implements Plugin<Project> {
|
||||
|
||||
setupDownloadServiceRepo(project);
|
||||
|
||||
ExtraPropertiesExtension extraProperties = project.getExtensions().getExtraProperties();
|
||||
this.bwcVersions = (BwcVersions) extraProperties.get("bwcVersions");
|
||||
// TODO: setup snapshot dependency instead of pointing to bwc distribution projects for external projects
|
||||
if (ClasspathUtils.isElasticsearchProject(project)) {
|
||||
ExtraPropertiesExtension extraProperties = project.getExtensions().getExtraProperties();
|
||||
this.bwcVersions = (BwcVersions) extraProperties.get("bwcVersions");
|
||||
}
|
||||
|
||||
project.afterEvaluate(this::setupDistributions);
|
||||
}
|
||||
@ -148,13 +152,10 @@ public class DistributionDownloadPlugin implements Plugin<Project> {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setupDownloadServiceRepo(Project project) {
|
||||
if (project.getRepositories().findByName(DOWNLOAD_REPO_NAME) != null) {
|
||||
return;
|
||||
}
|
||||
private static void addIvyRepo(Project project, String name, String url, String group) {
|
||||
project.getRepositories().ivy(ivyRepo -> {
|
||||
ivyRepo.setName(DOWNLOAD_REPO_NAME);
|
||||
ivyRepo.setUrl("https://artifacts.elastic.co");
|
||||
ivyRepo.setName(name);
|
||||
ivyRepo.setUrl(url);
|
||||
ivyRepo.metadataSources(IvyArtifactRepository.MetadataSources::artifact);
|
||||
// this header is not a credential but we hack the capability to send this header to avoid polluting our download stats
|
||||
ivyRepo.credentials(HttpHeaderCredentials.class, creds -> {
|
||||
@ -163,15 +164,25 @@ public class DistributionDownloadPlugin implements Plugin<Project> {
|
||||
});
|
||||
ivyRepo.getAuthentication().create("header", HttpHeaderAuthentication.class);
|
||||
ivyRepo.patternLayout(layout -> layout.artifact("/downloads/elasticsearch/[module]-[revision](-[classifier]).[ext]"));
|
||||
ivyRepo.content(content -> content.includeGroup(FAKE_IVY_GROUP));
|
||||
ivyRepo.content(content -> content.includeGroup(group));
|
||||
});
|
||||
project.getRepositories().all(repo -> {
|
||||
if (repo.getName().equals(DOWNLOAD_REPO_NAME) == false) {
|
||||
if (repo.getName().equals(name) == false) {
|
||||
// all other repos should ignore the special group name
|
||||
repo.content(content -> content.excludeGroup(FAKE_IVY_GROUP));
|
||||
repo.content(content -> content.excludeGroup(group));
|
||||
}
|
||||
});
|
||||
// TODO: need maven repo just for integ-test-zip, but only in external cases
|
||||
}
|
||||
|
||||
private static void setupDownloadServiceRepo(Project project) {
|
||||
if (project.getRepositories().findByName(DOWNLOAD_REPO_NAME) != null) {
|
||||
return;
|
||||
}
|
||||
addIvyRepo(project, DOWNLOAD_REPO_NAME, "https://artifacts.elastic.co", FAKE_IVY_GROUP);
|
||||
if (ClasspathUtils.isElasticsearchProject(project) == false) {
|
||||
// external, so add snapshot repo as well
|
||||
addIvyRepo(project, SNAPSHOT_REPO_NAME, "https://snapshots.elastic.co", FAKE_SNAPSHOT_IVY_GROUP);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -187,25 +198,30 @@ public class DistributionDownloadPlugin implements Plugin<Project> {
|
||||
*/
|
||||
private Object dependencyNotation(Project project, ElasticsearchDistribution distribution) {
|
||||
|
||||
if (Version.fromString(VersionProperties.getElasticsearch()).equals(distribution.getVersion())) {
|
||||
return projectDependency(project, distributionProjectPath(distribution), "default");
|
||||
// TODO: snapshot dep when not in ES repo
|
||||
}
|
||||
BwcVersions.UnreleasedVersionInfo unreleasedInfo = bwcVersions.unreleasedInfo(distribution.getVersion());
|
||||
if (unreleasedInfo != null) {
|
||||
assert distribution.getBundledJdk();
|
||||
return projectDependency(project, unreleasedInfo.gradleProjectPath, distributionProjectName(distribution));
|
||||
if (ClasspathUtils.isElasticsearchProject(project)) {
|
||||
// non-external project, so depend on local build
|
||||
|
||||
if (VersionProperties.getElasticsearch().equals(distribution.getVersion())) {
|
||||
return projectDependency(project, distributionProjectPath(distribution), "default");
|
||||
}
|
||||
BwcVersions.UnreleasedVersionInfo unreleasedInfo = bwcVersions.unreleasedInfo(Version.fromString(distribution.getVersion()));
|
||||
if (unreleasedInfo != null) {
|
||||
assert distribution.getBundledJdk();
|
||||
return projectDependency(project, unreleasedInfo.gradleProjectPath, distributionProjectName(distribution));
|
||||
}
|
||||
}
|
||||
|
||||
if (distribution.getType() == Type.INTEG_TEST_ZIP) {
|
||||
return "org.elasticsearch.distribution.integ-test-zip:elasticsearch:" + distribution.getVersion();
|
||||
}
|
||||
|
||||
|
||||
Version distroVersion = Version.fromString(distribution.getVersion());
|
||||
String extension = distribution.getType().toString();
|
||||
String classifier = ":x86_64";
|
||||
if (distribution.getType() == Type.ARCHIVE) {
|
||||
extension = distribution.getPlatform() == Platform.WINDOWS ? "zip" : "tar.gz";
|
||||
if (distribution.getVersion().onOrAfter("7.0.0")) {
|
||||
if (distroVersion.onOrAfter("7.0.0")) {
|
||||
classifier = ":" + distribution.getPlatform() + "-x86_64";
|
||||
} else {
|
||||
classifier = "";
|
||||
@ -214,10 +230,12 @@ public class DistributionDownloadPlugin implements Plugin<Project> {
|
||||
classifier = ":amd64";
|
||||
}
|
||||
String flavor = "";
|
||||
if (distribution.getFlavor() == Flavor.OSS && distribution.getVersion().onOrAfter("6.3.0")) {
|
||||
if (distribution.getFlavor() == Flavor.OSS && distroVersion.onOrAfter("6.3.0")) {
|
||||
flavor = "-oss";
|
||||
}
|
||||
return FAKE_IVY_GROUP + ":elasticsearch" + flavor + ":" + distribution.getVersion() + classifier + "@" + extension;
|
||||
|
||||
String group = distribution.getVersion().endsWith("-SNAPSHOT") ? FAKE_SNAPSHOT_IVY_GROUP : FAKE_IVY_GROUP;
|
||||
return group + ":elasticsearch" + flavor + ":" + distribution.getVersion() + classifier + "@" + extension;
|
||||
}
|
||||
|
||||
private static Dependency projectDependency(Project project, String projectPath, String projectConfig) {
|
||||
@ -251,7 +269,7 @@ public class DistributionDownloadPlugin implements Plugin<Project> {
|
||||
projectName += "no-jdk-";
|
||||
}
|
||||
if (distribution.getType() == Type.ARCHIVE) {
|
||||
if (distribution.getVersion().onOrAfter("7.0.0")) {
|
||||
if (Version.fromString(distribution.getVersion()).onOrAfter("7.0.0")) {
|
||||
Platform platform = distribution.getPlatform();
|
||||
projectName += platform.toString() + (platform == Platform.WINDOWS ? "-zip" : "-tar");
|
||||
} else {
|
||||
|
@ -101,7 +101,7 @@ public class ElasticsearchDistribution implements Buildable, Iterable<File> {
|
||||
final Configuration configuration;
|
||||
private final Extracted extracted;
|
||||
|
||||
private final Property<Version> version;
|
||||
private final Property<String> version;
|
||||
private final Property<Type> type;
|
||||
private final Property<Platform> platform;
|
||||
private final Property<Flavor> flavor;
|
||||
@ -111,8 +111,7 @@ public class ElasticsearchDistribution implements Buildable, Iterable<File> {
|
||||
Configuration extractedConfiguration) {
|
||||
this.name = name;
|
||||
this.configuration = fileConfiguration;
|
||||
this.version = objectFactory.property(Version.class);
|
||||
this.version.convention(Version.fromString(VersionProperties.getElasticsearch()));
|
||||
this.version = objectFactory.property(String.class).convention(VersionProperties.getElasticsearch());
|
||||
this.type = objectFactory.property(Type.class);
|
||||
this.type.convention(Type.ARCHIVE);
|
||||
this.platform = objectFactory.property(Platform.class);
|
||||
@ -125,12 +124,13 @@ public class ElasticsearchDistribution implements Buildable, Iterable<File> {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Version getVersion() {
|
||||
public String getVersion() {
|
||||
return version.get();
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version.set(Version.fromString(version));
|
||||
Version.fromString(version); // ensure the version parses, but don't store as Version since that removes -SNAPSHOT
|
||||
this.version.set(version);
|
||||
}
|
||||
|
||||
public Platform getPlatform() {
|
||||
|
@ -180,7 +180,7 @@ public class ElasticsearchNode implements TestClusterConfiguration {
|
||||
|
||||
@Internal
|
||||
public Version getVersion() {
|
||||
return distributions.get(currentDistro).getVersion();
|
||||
return Version.fromString(distributions.get(currentDistro).getVersion());
|
||||
}
|
||||
|
||||
@Internal
|
||||
|
@ -38,6 +38,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.head;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
|
||||
|
||||
public class DistributionDownloadPluginIT extends GradleIntegrationTestCase {
|
||||
|
||||
// TODO: check reuse of root task across projects MOVE TO UNIT TEST
|
||||
// TODO: future: check integ-test-zip to maven, snapshots to snapshot service for external project
|
||||
|
||||
@ -48,32 +49,61 @@ public class DistributionDownloadPluginIT extends GradleIntegrationTestCase {
|
||||
"tests.local_distro.project", projectName);
|
||||
}
|
||||
|
||||
public void testCurrentExternal() throws Exception {
|
||||
checkService(VersionProperties.getElasticsearch(), "archive", "linux", null, null,
|
||||
"/downloads/elasticsearch/elasticsearch-" + VersionProperties.getElasticsearch() + "-linux-x86_64.tar.gz",
|
||||
"tests.internal", "false");
|
||||
}
|
||||
|
||||
public void testBwc() throws Exception {
|
||||
assertExtractedDistro("1.1.0", "archive", "linux", null, null,
|
||||
"tests.local_distro.config", "zip",
|
||||
assertExtractedDistro("8.1.0", "archive", "linux", null, null,
|
||||
"tests.local_distro.config", "linux-tar",
|
||||
"tests.local_distro.project", ":distribution:bwc:minor",
|
||||
"tests.current_version", "2.0.0");
|
||||
"tests.current_version", "8.0.0");
|
||||
}
|
||||
|
||||
public void testBwcExternal() throws Exception {
|
||||
checkService("8.1.0-SNAPSHOT", "archive", "linux", null, null,
|
||||
"/downloads/elasticsearch/elasticsearch-8.1.0-SNAPSHOT-linux-x86_64.tar.gz",
|
||||
"tests.internal", "false",
|
||||
"tests.current_version", "9.0.0");
|
||||
}
|
||||
|
||||
public void testReleased() throws Exception {
|
||||
doTestReleased("7.0.0", "/downloads/elasticsearch/elasticsearch-7.0.0-windows-x86_64.zip");
|
||||
doTestReleased("6.5.0", "/downloads/elasticsearch/elasticsearch-6.5.0.zip");
|
||||
checkService("7.0.0", "archive", "windows", null, null,
|
||||
"/downloads/elasticsearch/elasticsearch-7.0.0-windows-x86_64.zip");
|
||||
checkService("6.5.0", "archive", "windows", null, null,
|
||||
"/downloads/elasticsearch/elasticsearch-6.5.0.zip");
|
||||
}
|
||||
|
||||
private void doTestReleased(String version, String urlPath) throws IOException {
|
||||
public void testReleasedExternal() throws Exception {
|
||||
checkService("7.0.0", "archive", "windows", null, null,
|
||||
"/downloads/elasticsearch/elasticsearch-7.0.0-windows-x86_64.zip",
|
||||
"tests.internal", "false");
|
||||
checkService("6.5.0", "archive", "windows", null, null,
|
||||
"/downloads/elasticsearch/elasticsearch-6.5.0.zip",
|
||||
"tests.internal", "false");
|
||||
}
|
||||
|
||||
private void checkService(String version, String type, String platform, String flavor, Boolean bundledJdk,
|
||||
String urlPath, String... sysProps) throws IOException {
|
||||
String suffix = urlPath.endsWith("zip") ? "zip" : "tar.gz";
|
||||
String sourceFile = "src/testKit/distribution-download/distribution/files/fake_elasticsearch." + suffix;
|
||||
WireMockServer wireMock = new WireMockServer(0);
|
||||
try {
|
||||
final byte[] filebytes;
|
||||
try (InputStream stream =
|
||||
Files.newInputStream(Paths.get("src/testKit/distribution-download/distribution/files/fake_elasticsearch.zip"))) {
|
||||
try (InputStream stream = Files.newInputStream(Paths.get(sourceFile))) {
|
||||
filebytes = stream.readAllBytes();
|
||||
}
|
||||
wireMock.stubFor(head(urlEqualTo(urlPath)).willReturn(aResponse().withStatus(200)));
|
||||
wireMock.stubFor(get(urlEqualTo(urlPath)).willReturn(aResponse().withStatus(200).withBody(filebytes)));
|
||||
wireMock.start();
|
||||
|
||||
assertExtractedDistro(version, "archive", "windows", null, null,
|
||||
"tests.download_service", wireMock.baseUrl());
|
||||
List<String> allSysProps = new ArrayList<>();
|
||||
allSysProps.addAll(Arrays.asList(sysProps));
|
||||
allSysProps.add("tests.download_service");
|
||||
allSysProps.add(wireMock.baseUrl());
|
||||
assertExtractedDistro(version, type, platform, flavor, bundledJdk, allSysProps.toArray(new String[0]));
|
||||
} catch (Exception e) {
|
||||
// for debugging
|
||||
System.err.println("missed requests: " + wireMock.findUnmatchedRequests().getRequests());
|
||||
|
@ -54,58 +54,58 @@ public class DistributionDownloadPluginTests extends GradleUnitTestCase {
|
||||
new BwcVersions(new TreeSet<>(Arrays.asList(BWC_MAINTENANCE_VERSION, BWC_STAGED_VERSION, BWC_MINOR_VERSION)), BWC_MINOR_VERSION);
|
||||
|
||||
public void testVersionDefault() {
|
||||
ElasticsearchDistribution distro = checkDistro(createProject(null),
|
||||
ElasticsearchDistribution distro = checkDistro(createProject(null, false),
|
||||
"testdistro", null, Type.ARCHIVE, Platform.LINUX, Flavor.OSS, true);
|
||||
assertEquals(distro.getVersion(), Version.fromString(VersionProperties.getElasticsearch()));
|
||||
assertEquals(distro.getVersion(), VersionProperties.getElasticsearch());
|
||||
}
|
||||
|
||||
public void testBadVersionFormat() {
|
||||
assertDistroError(createProject(null), "testdistro", "badversion", Type.ARCHIVE, Platform.LINUX, Flavor.OSS, true,
|
||||
assertDistroError(createProject(null, false), "testdistro", "badversion", Type.ARCHIVE, Platform.LINUX, Flavor.OSS, true,
|
||||
"Invalid version format: 'badversion'");
|
||||
}
|
||||
|
||||
public void testTypeDefault() {
|
||||
ElasticsearchDistribution distro = checkDistro(createProject(null),
|
||||
ElasticsearchDistribution distro = checkDistro(createProject(null, false),
|
||||
"testdistro", "5.0.0", null, Platform.LINUX, Flavor.OSS, true);
|
||||
assertEquals(distro.getType(), Type.ARCHIVE);
|
||||
}
|
||||
|
||||
public void testPlatformDefault() {
|
||||
ElasticsearchDistribution distro = checkDistro(createProject(null),
|
||||
ElasticsearchDistribution distro = checkDistro(createProject(null, false),
|
||||
"testdistro", "5.0.0", Type.ARCHIVE, null, Flavor.OSS, true);
|
||||
assertEquals(distro.getPlatform(), ElasticsearchDistribution.CURRENT_PLATFORM);
|
||||
}
|
||||
|
||||
public void testPlatformForIntegTest() {
|
||||
assertDistroError(createProject(null), "testdistro", "5.0.0", Type.INTEG_TEST_ZIP, Platform.LINUX, null, null,
|
||||
assertDistroError(createProject(null, false), "testdistro", "5.0.0", Type.INTEG_TEST_ZIP, Platform.LINUX, null, null,
|
||||
"platform not allowed for elasticsearch distribution [testdistro]");
|
||||
}
|
||||
|
||||
public void testFlavorDefault() {
|
||||
ElasticsearchDistribution distro = checkDistro(createProject(null),
|
||||
ElasticsearchDistribution distro = checkDistro(createProject(null, false),
|
||||
"testdistro", "5.0.0", Type.ARCHIVE, Platform.LINUX, null, true);
|
||||
assertEquals(distro.getFlavor(), Flavor.DEFAULT);
|
||||
}
|
||||
|
||||
public void testFlavorForIntegTest() {
|
||||
assertDistroError(createProject(null),
|
||||
assertDistroError(createProject(null, false),
|
||||
"testdistro", "5.0.0", Type.INTEG_TEST_ZIP, null, Flavor.OSS, null,
|
||||
"flavor [oss] not allowed for elasticsearch distribution [testdistro] of type [integ_test_zip]");
|
||||
}
|
||||
|
||||
public void testBundledJdkDefault() {
|
||||
ElasticsearchDistribution distro = checkDistro(createProject(null),
|
||||
ElasticsearchDistribution distro = checkDistro(createProject(null, false),
|
||||
"testdistro", "5.0.0", Type.ARCHIVE, Platform.LINUX, null, true);
|
||||
assertTrue(distro.getBundledJdk());
|
||||
}
|
||||
|
||||
public void testBundledJdkForIntegTest() {
|
||||
assertDistroError(createProject(null), "testdistro", "5.0.0", Type.INTEG_TEST_ZIP, null, null, true,
|
||||
assertDistroError(createProject(null, false), "testdistro", "5.0.0", Type.INTEG_TEST_ZIP, null, null, true,
|
||||
"bundledJdk not allowed for elasticsearch distribution [testdistro]");
|
||||
}
|
||||
|
||||
public void testCurrentVersionIntegTestZip() {
|
||||
Project project = createProject(null);
|
||||
public void testLocalCurrentVersionIntegTestZip() {
|
||||
Project project = createProject(BWC_MINOR, true);
|
||||
Project archiveProject = ProjectBuilder.builder().withParent(archivesProject).withName("integ-test-zip").build();
|
||||
archiveProject.getConfigurations().create("default");
|
||||
archiveProject.getArtifacts().add("default", new File("doesnotmatter"));
|
||||
@ -114,12 +114,12 @@ public class DistributionDownloadPluginTests extends GradleUnitTestCase {
|
||||
checkPlugin(project);
|
||||
}
|
||||
|
||||
public void testCurrentVersionArchives() {
|
||||
public void testLocalCurrentVersionArchives() {
|
||||
for (Platform platform : Platform.values()) {
|
||||
for (Flavor flavor : Flavor.values()) {
|
||||
for (boolean bundledJdk : new boolean[] { true, false}) {
|
||||
// create a new project in each iteration, so that we know we are resolving the only additional project being created
|
||||
Project project = createProject(null);
|
||||
Project project = createProject(BWC_MINOR, true);
|
||||
String projectName = projectName(platform.toString(), flavor, bundledJdk);
|
||||
projectName += (platform == Platform.WINDOWS ? "-zip" : "-tar");
|
||||
Project archiveProject = ProjectBuilder.builder().withParent(archivesProject).withName(projectName).build();
|
||||
@ -133,11 +133,11 @@ public class DistributionDownloadPluginTests extends GradleUnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testCurrentVersionPackages() {
|
||||
public void testLocalCurrentVersionPackages() {
|
||||
for (Type packageType : new Type[] { Type.RPM, Type.DEB }) {
|
||||
for (Flavor flavor : Flavor.values()) {
|
||||
for (boolean bundledJdk : new boolean[] { true, false}) {
|
||||
Project project = createProject(null);
|
||||
Project project = createProject(BWC_MINOR, true);
|
||||
String projectName = projectName(packageType.toString(), flavor, bundledJdk);
|
||||
Project packageProject = ProjectBuilder.builder().withParent(packagesProject).withName(projectName).build();
|
||||
packageProject.getConfigurations().create("default");
|
||||
@ -157,10 +157,10 @@ public class DistributionDownloadPluginTests extends GradleUnitTestCase {
|
||||
String configName = projectName(platform.toString(), flavor, true);
|
||||
configName += (platform == Platform.WINDOWS ? "-zip" : "-tar");
|
||||
|
||||
checkBwc("minor", configName, BWC_MINOR_VERSION, BWC_MINOR, Type.ARCHIVE, platform, flavor);
|
||||
checkBwc("staged", configName, BWC_STAGED_VERSION, BWC_STAGED, Type.ARCHIVE, platform, flavor);
|
||||
checkBwc("bugfix", configName, BWC_BUGFIX_VERSION, BWC_BUGFIX, Type.ARCHIVE, platform, flavor);
|
||||
checkBwc("maintenance", configName, BWC_MAINTENANCE_VERSION, BWC_MAINTENANCE, Type.ARCHIVE, platform, flavor);
|
||||
checkBwc("minor", configName, BWC_MINOR_VERSION, Type.ARCHIVE, platform, flavor, BWC_MINOR, true);
|
||||
checkBwc("staged", configName, BWC_STAGED_VERSION, Type.ARCHIVE, platform, flavor, BWC_STAGED, true);
|
||||
checkBwc("bugfix", configName, BWC_BUGFIX_VERSION, Type.ARCHIVE, platform, flavor, BWC_BUGFIX, true);
|
||||
checkBwc("maintenance", configName, BWC_MAINTENANCE_VERSION, Type.ARCHIVE, platform, flavor, BWC_MAINTENANCE, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -171,10 +171,10 @@ public class DistributionDownloadPluginTests extends GradleUnitTestCase {
|
||||
// note: no non bundled jdk for bwc
|
||||
String configName = projectName(packageType.toString(), flavor, true);
|
||||
|
||||
checkBwc("minor", configName, BWC_MINOR_VERSION, BWC_MINOR, packageType, null, flavor);
|
||||
checkBwc("staged", configName, BWC_STAGED_VERSION, BWC_STAGED, packageType, null, flavor);
|
||||
checkBwc("bugfix", configName, BWC_BUGFIX_VERSION, BWC_BUGFIX, packageType, null, flavor);
|
||||
checkBwc("maintenance", configName, BWC_MAINTENANCE_VERSION, BWC_MAINTENANCE, packageType, null, flavor);
|
||||
checkBwc("minor", configName, BWC_MINOR_VERSION, packageType, null, flavor, BWC_MINOR, true);
|
||||
checkBwc("staged", configName, BWC_STAGED_VERSION, packageType, null, flavor, BWC_STAGED, true);
|
||||
checkBwc("bugfix", configName, BWC_BUGFIX_VERSION, packageType, null, flavor, BWC_BUGFIX, true);
|
||||
checkBwc("maintenance", configName, BWC_MAINTENANCE_VERSION, packageType, null, flavor, BWC_MAINTENANCE, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -222,9 +222,9 @@ public class DistributionDownloadPluginTests extends GradleUnitTestCase {
|
||||
plugin.setupDistributions(project);
|
||||
}
|
||||
|
||||
private void checkBwc(String projectName, String config, Version version, BwcVersions bwcVersions,
|
||||
Type type, Platform platform, Flavor flavor) {
|
||||
Project project = createProject(bwcVersions);
|
||||
private void checkBwc(String projectName, String config, Version version,
|
||||
Type type, Platform platform, Flavor flavor, BwcVersions bwcVersions, boolean isInternal) {
|
||||
Project project = createProject(bwcVersions, isInternal);
|
||||
Project archiveProject = ProjectBuilder.builder().withParent(bwcProject).withName(projectName).build();
|
||||
archiveProject.getConfigurations().create(config);
|
||||
archiveProject.getArtifacts().add(config, new File("doesnotmatter"));
|
||||
@ -232,14 +232,18 @@ public class DistributionDownloadPluginTests extends GradleUnitTestCase {
|
||||
checkPlugin(project);
|
||||
}
|
||||
|
||||
private Project createProject(BwcVersions bwcVersions) {
|
||||
private Project createProject(BwcVersions bwcVersions, boolean isInternal) {
|
||||
rootProject = ProjectBuilder.builder().build();
|
||||
rootProject.getExtensions().getExtraProperties().set("isInternal", isInternal);
|
||||
Project distributionProject = ProjectBuilder.builder().withParent(rootProject).withName("distribution").build();
|
||||
archivesProject = ProjectBuilder.builder().withParent(distributionProject).withName("archives").build();
|
||||
packagesProject = ProjectBuilder.builder().withParent(distributionProject).withName("packages").build();
|
||||
bwcProject = ProjectBuilder.builder().withParent(distributionProject).withName("bwc").build();
|
||||
Project project = ProjectBuilder.builder().withParent(rootProject).build();
|
||||
project.getExtensions().getExtraProperties().set("bwcVersions", bwcVersions);
|
||||
if (bwcVersions != null) {
|
||||
project.getExtensions().getExtraProperties().set("bwcVersions", bwcVersions);
|
||||
}
|
||||
project.getExtensions().getExtraProperties().set("isInternal", isInternal);
|
||||
project.getPlugins().apply("elasticsearch.distribution-download");
|
||||
return project;
|
||||
}
|
||||
|
@ -19,26 +19,38 @@ import org.elasticsearch.gradle.Version
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// bring in build-tools onto the classpath
|
||||
plugins {
|
||||
id 'elasticsearch.global-build-info' apply false
|
||||
id 'elasticsearch.global-build-info'
|
||||
}
|
||||
boolean internal = Boolean.parseBoolean(System.getProperty("tests.internal", "true"))
|
||||
|
||||
project.gradle.projectsEvaluated {
|
||||
// wire the download service url to wiremock
|
||||
String fakeDownloadService = System.getProperty('tests.download_service')
|
||||
if (fakeDownloadService != null) {
|
||||
println rootProject.repositories.asMap.keySet()
|
||||
IvyArtifactRepository repository = (IvyArtifactRepository) rootProject.repositories.getByName("elasticsearch-downloads")
|
||||
repository.setUrl(fakeDownloadService)
|
||||
repository = (IvyArtifactRepository) project('subproj').repositories.getByName("elasticsearch-downloads")
|
||||
repository.setUrl(fakeDownloadService)
|
||||
if (internal == false) {
|
||||
repository = (IvyArtifactRepository) rootProject.repositories.getByName("elasticsearch-snapshots")
|
||||
repository.setUrl(fakeDownloadService)
|
||||
repository = (IvyArtifactRepository) project('subproj').repositories.getByName("elasticsearch-snapshots")
|
||||
repository.setUrl(fakeDownloadService)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Version currentVersion = Version.fromString("2.0.0")
|
||||
BwcVersions versions = new BwcVersions(new TreeSet<>(
|
||||
Arrays.asList(Version.fromString("1.0.0"), Version.fromString("1.0.1"), Version.fromString("1.1.0"), currentVersion)),
|
||||
currentVersion)
|
||||
allprojects {
|
||||
ext.bwcVersions = versions
|
||||
}
|
||||
ext.isInternal = internal
|
||||
}
|
||||
|
||||
if (internal) {
|
||||
Version currentVersion = Version.fromString("9.0.0")
|
||||
BwcVersions versions = new BwcVersions(new TreeSet<>(
|
||||
Arrays.asList(Version.fromString("8.0.0"), Version.fromString("8.0.1"), Version.fromString("8.1.0"), currentVersion)),
|
||||
currentVersion)
|
||||
allprojects {
|
||||
ext.bwcVersions = versions
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
plugins {
|
||||
id 'elasticsearch.distribution-download'
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user