From 6257d8e5a8b2e2d7b111a5c49984e252feb66f84 Mon Sep 17 00:00:00 2001 From: dblock Date: Fri, 11 Feb 2022 15:15:46 +0000 Subject: [PATCH] Test that the correct IVY repos were added. Signed-off-by: dblock --- .../gradle/DistributionDownloadPlugin.java | 4 ---- .../gradle/DistributionDownloadPluginTests.java | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/buildSrc/src/main/java/org/opensearch/gradle/DistributionDownloadPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/DistributionDownloadPlugin.java index 1ad22b631240b..8b5e81bc2ef07 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/DistributionDownloadPlugin.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/DistributionDownloadPlugin.java @@ -176,10 +176,6 @@ private static void addIvyRepo(Project project, String name, String url, String exclusiveContentRepository.filter(config -> config.includeGroup(group)); exclusiveContentRepository.forRepositories(repos.toArray(new IvyArtifactRepository[repos.size()])); }); - // set testCustomDistributionUrlProperty with url passed as parameter - if (project.findProperty("customDistributionUrl") != null) { - project.getExtensions().getExtraProperties().set("testCustomDistributionUrlProperty", url); - } } private static void addIvyRepo2(Project project, String name, String url, String group) { diff --git a/buildSrc/src/test/java/org/opensearch/gradle/DistributionDownloadPluginTests.java b/buildSrc/src/test/java/org/opensearch/gradle/DistributionDownloadPluginTests.java index 888f94c5950f0..b1c5354ab700e 100644 --- a/buildSrc/src/test/java/org/opensearch/gradle/DistributionDownloadPluginTests.java +++ b/buildSrc/src/test/java/org/opensearch/gradle/DistributionDownloadPluginTests.java @@ -38,6 +38,7 @@ import org.opensearch.gradle.test.GradleUnitTestCase; import org.gradle.api.NamedDomainObjectContainer; import org.gradle.api.Project; +import org.gradle.api.internal.artifacts.repositories.DefaultIvyArtifactRepository; import org.gradle.testfixtures.ProjectBuilder; import java.io.File; @@ -86,18 +87,27 @@ public void testCustomDistributionUrlForNull() { public void testCustomDistributionUrlWithUrl() { Project project = createProject(null, false); - String customUrl = "https://artifacts.opensearch.org"; + String customUrl = "https://artifacts.opensearch.org/custom"; project.getExtensions().getExtraProperties().set("customDistributionUrl", customUrl); DistributionDownloadPlugin plugin = project.getPlugins().getPlugin(DistributionDownloadPlugin.class); plugin.setupDistributions(project); - assertEquals(project.property("testCustomDistributionUrlProperty").toString(), customUrl); + assertEquals(4, project.getRepositories().size()); + assertEquals(((DefaultIvyArtifactRepository) project.getRepositories().getAt("opensearch-downloads")).getUrl().toString(), customUrl); + assertEquals(((DefaultIvyArtifactRepository) project.getRepositories().getAt("opensearch-snapshots")).getUrl().toString(), customUrl); + assertEquals(((DefaultIvyArtifactRepository) project.getRepositories().getAt("elasticsearch-downloads")).getUrl().toString(), "https://artifacts-no-kpi.elastic.co"); + assertEquals(((DefaultIvyArtifactRepository) project.getRepositories().getAt("elasticsearch-snapshots")).getUrl().toString(), "https://snapshots-no-kpi.elastic.co"); } public void testCustomDistributionUrlWithoutUrl() { Project project = createProject(null, false); DistributionDownloadPlugin plugin = project.getPlugins().getPlugin(DistributionDownloadPlugin.class); plugin.setupDistributions(project); - assertFalse(project.hasProperty("testCustomDistributionUrlProperty")); + assertEquals(5, project.getRepositories().size()); + assertEquals(((DefaultIvyArtifactRepository) project.getRepositories().getAt("opensearch-downloads")).getUrl().toString(), "https://artifacts.opensearch.org"); + assertEquals(((DefaultIvyArtifactRepository) project.getRepositories().getAt("opensearch-downloads2")).getUrl().toString(), "https://artifacts.opensearch.org"); + assertEquals(((DefaultIvyArtifactRepository) project.getRepositories().getAt("opensearch-snapshots")).getUrl().toString(), "https://artifacts.opensearch.org"); + assertEquals(((DefaultIvyArtifactRepository) project.getRepositories().getAt("elasticsearch-downloads")).getUrl().toString(), "https://artifacts-no-kpi.elastic.co"); + assertEquals(((DefaultIvyArtifactRepository) project.getRepositories().getAt("elasticsearch-snapshots")).getUrl().toString(), "https://snapshots-no-kpi.elastic.co"); } public void testBadVersionFormat() {