From 6074d953636a40c4dc612c3a341d08e6d8cfc3a7 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Wed, 13 Feb 2019 15:33:04 +0200 Subject: [PATCH 1/6] Fix backwards boolean logic --- .../java/org/elasticsearch/upgrades/FullClusterRestartIT.java | 1 + 1 file changed, 1 insertion(+) diff --git a/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java b/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java index b34f677e1c15b..b7a7d17d9c617 100644 --- a/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java +++ b/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java @@ -33,6 +33,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.common.xcontent.support.XContentMapValues; + import org.elasticsearch.test.NotEqualMessageBuilder; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.test.rest.yaml.ObjectPath; From f99fd4245363d6607c8e2481a246bc71a7a8d6bf Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Wed, 13 Feb 2019 12:02:18 +0200 Subject: [PATCH 2/6] Include current version in bwc tests --- .../gradle/test/ClusterFormationTasks.groovy | 3 +- .../gradle/vagrant/VagrantTestPlugin.groovy | 4 +- .../gradle/VersionCollection.java | 27 ++++---- .../gradle/VersionCollectionTests.java | 68 +++++++++---------- distribution/build.gradle | 12 ++++ distribution/bwc/build.gradle | 2 +- 6 files changed, 63 insertions(+), 53 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy index 7a0a7d9436ee2..aca0452ca00bd 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy @@ -216,7 +216,8 @@ class ClusterFormationTasks { } if (unreleasedInfo != null) { dependency = project.dependencies.project( - path: ":distribution:bwc:${unreleasedInfo.gradleProjectName}", configuration: snapshotProject) + path: unreleasedInfo.gradleProjectName, configuration: snapshotProject + ) } else if (internalBuild && elasticsearchVersion.equals(VersionProperties.elasticsearch)) { dependency = project.dependencies.project(path: ":distribution:archives:${snapshotProject}") } else { diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy index 210fb939c7113..99a35b97422d8 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy @@ -197,10 +197,10 @@ class VagrantTestPlugin implements Plugin { // handle snapshots pointing to bwc build UPGRADE_FROM_ARCHIVES.each { dependencies.add(project.dependencies.project( - path: ":distribution:bwc:${unreleasedInfo.gradleProjectName}", configuration: it)) + path: "${unreleasedInfo.gradleProjectName}", configuration: it)) if (upgradeFromVersion.onOrAfter('6.3.0')) { dependencies.add(project.dependencies.project( - path: ":distribution:bwc:${unreleasedInfo.gradleProjectName}", configuration: "oss-${it}")) + path: "${unreleasedInfo.gradleProjectName}", configuration: "oss-${it}")) } } } else { diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/VersionCollection.java b/buildSrc/src/main/java/org/elasticsearch/gradle/VersionCollection.java index cf8eb1829abef..3ff80d2b21926 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/VersionCollection.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/VersionCollection.java @@ -135,9 +135,6 @@ protected VersionCollection(List versionLines, Version currentVersionPro Map unreleased = new HashMap<>(); for (Version unreleasedVersion : getUnreleased()) { - if (unreleasedVersion.equals(currentVersion)) { - continue; - } unreleased.put(unreleasedVersion, new UnreleasedVersionInfo(unreleasedVersion, getBranchFor(unreleasedVersion), getGradleProjectNameFor(unreleasedVersion))); } @@ -186,7 +183,7 @@ public void forPreviousUnreleased(Consumer consumer) { private String getGradleProjectNameFor(Version version) { if (version.equals(currentVersion)) { - throw new IllegalArgumentException("The Gradle project to build " + version + " is the current build."); + return ":distribution"; } Map> releasedMajorGroupedByMinor = getReleasedMajorGroupedByMinor(); @@ -197,31 +194,33 @@ private String getGradleProjectNameFor(Version version) { .collect(Collectors.toList()); if (unreleasedStagedOrMinor.size() > 2) { if (unreleasedStagedOrMinor.get(unreleasedStagedOrMinor.size() - 2).equals(version)) { - return "minor"; + return ":distribution:bwc:minor"; } else{ - return "staged"; + return ":distribution:bwc:staged"; } } else { - return "minor"; + return ":distribution:bwc:minor"; } } else { if (releasedMajorGroupedByMinor .getOrDefault(version.getMinor(), emptyList()) .contains(version)) { - return "bugfix"; + return ":distribution:bwc:bugfix"; } else { - return "maintenance"; + return ":distribution:bwc:maintenance"; } } } private String getBranchFor(Version version) { switch (getGradleProjectNameFor(version)) { - case "minor": + case ":distribution": + return "master"; + case ":distribution:bwc:minor": return version.getMajor() + ".x"; - case "staged": - case "maintenance": - case "bugfix": + case ":distribution:bwc:staged": + case ":distribution:bwc:maintenance": + case ":distribution:bwc:bugfix": return version.getMajor() + "." + version.getMinor(); default: throw new IllegalStateException("Unexpected Gradle project name"); @@ -320,7 +319,6 @@ public List getIndexCompatible() { groupByMajor.get(currentVersion.getMajor() - 1).stream(), groupByMajor.get(currentVersion.getMajor()).stream() ) - .filter(version -> version.equals(currentVersion) == false) .collect(Collectors.toList()) ); } @@ -337,7 +335,6 @@ public List getWireCompatible() { wireCompat.add(prevMajors.get(i)); } wireCompat.addAll(groupByMajor.get(currentVersion.getMajor())); - wireCompat.remove(currentVersion); wireCompat.sort(Version::compareTo); return unmodifiableList(wireCompat); diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/VersionCollectionTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/VersionCollectionTests.java index 4ea33b240e532..17e347795d6ed 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/VersionCollectionTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/VersionCollectionTests.java @@ -110,16 +110,16 @@ public void testExceptionOnTooManyMajors() { public void testWireCompatible() { assertVersionsEquals( - singletonList("6.5.0-SNAPSHOT"), + asList("6.5.0", "7.0.0"), getVersionCollection("7.0.0-alpha1").getWireCompatible() ); assertVersionsEquals( asList( "5.6.0", "5.6.1", "5.6.2", "5.6.3", "5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", - "5.6.11", "5.6.12", "5.6.13-SNAPSHOT", + "5.6.11", "5.6.12", "5.6.13", "6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4", "6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4", - "6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2-SNAPSHOT" + "6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2", "6.5.0" ), getVersionCollection("6.5.0").getWireCompatible() ); @@ -127,8 +127,8 @@ public void testWireCompatible() { assertVersionsEquals( asList( "5.6.0", "5.6.1", "5.6.2", "5.6.3", "5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", - "5.6.11", "5.6.12", "5.6.13-SNAPSHOT", "6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4", - "6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4", "6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1" + "5.6.11", "5.6.12", "5.6.13", "6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4", + "6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4", "6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2" ), getVersionCollection("6.4.2").getWireCompatible() ); @@ -136,20 +136,20 @@ public void testWireCompatible() { assertVersionsEquals( asList( "5.6.0", "5.6.1", "5.6.2", "5.6.3", "5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", - "5.6.11", "5.6.12", "5.6.13-SNAPSHOT", + "5.6.11", "5.6.12", "5.6.13", "6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4", "6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4", - "6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2-SNAPSHOT", "6.5.0-SNAPSHOT" + "6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2", "6.5.0", "6.6.0" ), getVersionCollection("6.6.0").getWireCompatible() ); assertVersionsEquals( - singletonList("7.3.0"), + asList("7.3.0", "8.0.0"), getVersionCollection("8.0.0").getWireCompatible() ); assertVersionsEquals( - asList("6.7.0", "7.0.0"), + asList("6.7.0", "7.0.0", "7.1.0"), getVersionCollection("7.1.0").getWireCompatible() ); @@ -157,30 +157,30 @@ public void testWireCompatible() { public void testWireCompatibleUnreleased() { assertVersionsEquals( - singletonList("6.5.0-SNAPSHOT"), + asList("6.5.0", "7.0.0"), getVersionCollection("7.0.0-alpha1").getUnreleasedWireCompatible() ); assertVersionsEquals( - asList("5.6.13-SNAPSHOT", "6.4.2-SNAPSHOT"), + asList("5.6.13", "6.4.2", "6.5.0"), getVersionCollection("6.5.0").getUnreleasedWireCompatible() ); assertVersionsEquals( - singletonList("5.6.13-SNAPSHOT"), + asList("5.6.13", "6.4.2"), getVersionCollection("6.4.2").getUnreleasedWireCompatible() ); assertVersionsEquals( - asList("5.6.13-SNAPSHOT", "6.4.2-SNAPSHOT", "6.5.0-SNAPSHOT"), + asList("5.6.13", "6.4.2", "6.5.0", "6.6.0"), getVersionCollection("6.6.0").getUnreleasedWireCompatible() ); assertVersionsEquals( - singletonList("7.3.0"), + asList("7.3.0", "8.0.0"), getVersionCollection("8.0.0").getUnreleasedWireCompatible() ); assertVersionsEquals( - asList("6.7.0", "7.0.0"), + asList("6.7.0", "7.0.0", "7.1.0"), getVersionCollection("7.1.0").getWireCompatible() ); } @@ -190,7 +190,7 @@ public void testIndexCompatible() { asList( "6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4", "6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4", "6.3.0", "6.3.1", - "6.3.2", "6.4.0", "6.4.1", "6.4.2-SNAPSHOT", "6.5.0-SNAPSHOT" + "6.3.2", "6.4.0", "6.4.1", "6.4.2", "6.5.0", "7.0.0" ), getVersionCollection("7.0.0-alpha1").getIndexCompatible() ); @@ -199,9 +199,9 @@ public void testIndexCompatible() { asList( "5.0.0", "5.0.1", "5.0.2", "5.1.1", "5.1.2", "5.2.0", "5.2.1", "5.2.2", "5.3.0", "5.3.1", "5.3.2", "5.3.3", "5.4.0", "5.4.1", "5.4.2", "5.4.3", "5.5.0", "5.5.1", "5.5.2", "5.5.3", "5.6.0", "5.6.1", "5.6.2", "5.6.3", - "5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", "5.6.11", "5.6.12", "5.6.13-SNAPSHOT", + "5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", "5.6.11", "5.6.12", "5.6.13", "6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4", "6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4", - "6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2-SNAPSHOT" + "6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2", "6.5.0" ), getVersionCollection("6.5.0").getIndexCompatible() ); @@ -210,9 +210,9 @@ public void testIndexCompatible() { asList( "5.0.0", "5.0.1", "5.0.2", "5.1.1", "5.1.2", "5.2.0", "5.2.1", "5.2.2", "5.3.0", "5.3.1", "5.3.2", "5.3.3", "5.4.0", "5.4.1", "5.4.2", "5.4.3", "5.5.0", "5.5.1", "5.5.2", "5.5.3", "5.6.0", "5.6.1", "5.6.2", "5.6.3", - "5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", "5.6.11", "5.6.12", "5.6.13-SNAPSHOT", + "5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", "5.6.11", "5.6.12", "5.6.13", "6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4", "6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4", - "6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1" + "6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2" ), getVersionCollection("6.4.2").getIndexCompatible() ); @@ -221,42 +221,42 @@ public void testIndexCompatible() { asList( "5.0.0", "5.0.1", "5.0.2", "5.1.1", "5.1.2", "5.2.0", "5.2.1", "5.2.2", "5.3.0", "5.3.1", "5.3.2", "5.3.3", "5.4.0", "5.4.1", "5.4.2", "5.4.3", "5.5.0", "5.5.1", "5.5.2", "5.5.3", "5.6.0", "5.6.1", "5.6.2", "5.6.3", - "5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", "5.6.11", "5.6.12", "5.6.13-SNAPSHOT", + "5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", "5.6.11", "5.6.12", "5.6.13", "6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4", "6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4", - "6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2-SNAPSHOT", "6.5.0-SNAPSHOT" + "6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2", "6.5.0", "6.6.0" ), getVersionCollection("6.6.0").getIndexCompatible() ); assertVersionsEquals( - asList("7.0.0", "7.0.1", "7.1.0", "7.1.1", "7.2.0", "7.3.0"), + asList("7.0.0", "7.0.1", "7.1.0", "7.1.1", "7.2.0", "7.3.0", "8.0.0"), getVersionCollection("8.0.0").getIndexCompatible() ); } public void testIndexCompatibleUnreleased() { assertVersionsEquals( - asList("6.4.2-SNAPSHOT", "6.5.0-SNAPSHOT"), + asList("6.4.2", "6.5.0", "7.0.0"), getVersionCollection("7.0.0-alpha1").getUnreleasedIndexCompatible() ); assertVersionsEquals( - asList("5.6.13-SNAPSHOT", "6.4.2-SNAPSHOT"), + asList("5.6.13", "6.4.2", "6.5.0"), getVersionCollection("6.5.0").getUnreleasedIndexCompatible() ); assertVersionsEquals( - singletonList("5.6.13-SNAPSHOT"), + asList("5.6.13", "6.4.2"), getVersionCollection("6.4.2").getUnreleasedIndexCompatible() ); assertVersionsEquals( - asList("5.6.13-SNAPSHOT", "6.4.2-SNAPSHOT", "6.5.0-SNAPSHOT"), + asList("5.6.13", "6.4.2", "6.5.0", "6.6.0"), getVersionCollection("6.6.0").getUnreleasedIndexCompatible() ); assertVersionsEquals( - asList("7.1.1", "7.2.0", "7.3.0"), + asList("7.1.1", "7.2.0", "7.3.0", "8.0.0"), getVersionCollection("8.0.0").getUnreleasedIndexCompatible() ); } @@ -309,27 +309,27 @@ public void testGetBranch() { public void testGetGradleProjectName() { assertUnreleasedGradleProjectNames( - asList("bugfix", "minor"), + asList(":distribution:bwc:bugfix", ":distribution:bwc:minor"), getVersionCollection("7.0.0-alpha1") ); assertUnreleasedGradleProjectNames( - asList("maintenance", "bugfix"), + asList(":distribution:bwc:maintenance", ":distribution:bwc:bugfix"), getVersionCollection("6.5.0") ); assertUnreleasedGradleProjectNames( - singletonList("maintenance"), + singletonList(":distribution:bwc:maintenance"), getVersionCollection("6.4.2") ); assertUnreleasedGradleProjectNames( - asList("maintenance", "bugfix", "minor"), + asList(":distribution:bwc:maintenance", ":distribution:bwc:bugfix", ":distribution:bwc:minor"), getVersionCollection("6.6.0") ); assertUnreleasedGradleProjectNames( - asList("bugfix", "staged", "minor"), + asList(":distribution:bwc:bugfix", ":distribution:bwc:staged", ":distribution:bwc:minor"), getVersionCollection("8.0.0") ); assertUnreleasedGradleProjectNames( - asList("staged", "minor"), + asList(":distribution:bwc:staged", ":distribution:bwc:minor"), getVersionCollection("7.1.0") ); } diff --git a/distribution/build.gradle b/distribution/build.gradle index 3cf4a170700df..dd36bd59c76f0 100644 --- a/distribution/build.gradle +++ b/distribution/build.gradle @@ -516,3 +516,15 @@ subprojects { } } } + +['archives:windows-zip','archives:oss-windows-zip', + 'archives:darwin-tar','archives:oss-darwin-tar', + 'archives:linux-tar', 'archives:oss-linux-tar', + 'packages:rpm', 'packages:deb' +].forEach { subName -> + Project subproject = project("${project.path}:${subName}") + Configuration configuration = configurations.create(subproject.name) + dependencies { + "${configuration.name}" project(subproject.path) + } +} \ No newline at end of file diff --git a/distribution/bwc/build.gradle b/distribution/bwc/build.gradle index ff111ecaa08ca..30a890b87a0a6 100644 --- a/distribution/bwc/build.gradle +++ b/distribution/bwc/build.gradle @@ -33,7 +33,7 @@ import static org.elasticsearch.gradle.BuildPlugin.getJavaHome * unreleased versions are when Gradle projects are set up, so we use "build-unreleased-version-*" as placeholders * and configure them to build various versions here. */ -bwcVersions.forPreviousUnreleased { VersionCollection.UnreleasedVersionInfo unreleasedVersion -> project("${project.path}:${unreleasedVersion.gradleProjectName}") { +bwcVersions.forPreviousUnreleased { VersionCollection.UnreleasedVersionInfo unreleasedVersion -> project("${unreleasedVersion.gradleProjectName}") { Version bwcVersion = unreleasedVersion.version String bwcBranch = unreleasedVersion.branch apply plugin: 'distribution' From 8ac280a3ee30dab237c6ebf8198e52341d3c0974 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Tue, 19 Feb 2019 17:05:19 +0200 Subject: [PATCH 3/6] Fix full cluster restart --- .../java/org/elasticsearch/upgrades/FullClusterRestartIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java b/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java index b7a7d17d9c617..d1450fadc647b 100644 --- a/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java +++ b/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java @@ -778,7 +778,7 @@ public void testRecovery() throws Exception { */ public void testSnapshotRestore() throws IOException { int count; - if (isRunningAgainstOldCluster() && getOldClusterVersion().major < 8) { + if (isRunningAgainstOldCluster()) { // Create the index count = between(200, 300); indexRandomDocuments(count, true, true, i -> jsonBuilder().startObject().field("field", "value").endObject()); From c7ea6fd2c133e20b23d0fb9c877f23c7eb9e64ab Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Tue, 19 Feb 2019 17:05:31 +0200 Subject: [PATCH 4/6] fix version utils test --- .../test/java/org/elasticsearch/test/VersionUtilsTests.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/framework/src/test/java/org/elasticsearch/test/VersionUtilsTests.java b/test/framework/src/test/java/org/elasticsearch/test/VersionUtilsTests.java index b96dd11be2a65..2395fcc2484e9 100644 --- a/test/framework/src/test/java/org/elasticsearch/test/VersionUtilsTests.java +++ b/test/framework/src/test/java/org/elasticsearch/test/VersionUtilsTests.java @@ -344,9 +344,6 @@ public void testGradleVersionsMatchVersionUtils() { assertEquals(releasedIndexCompatible, indexCompatible.released); List unreleasedIndexCompatible = new ArrayList<>(VersionUtils.allUnreleasedVersions().stream() - /* Gradle skips the current version because being backwards compatible - * with yourself is implied. Java lists the version because it is useful. */ - .filter(v -> !Version.CURRENT.equals(v)) /* Java lists all versions from the 5.x series onwards, but we only want to consider * ones that we're supposed to be compatible with. */ .filter(v -> v.onOrAfter(Version.CURRENT.minimumIndexCompatibilityVersion())) @@ -374,9 +371,6 @@ public void testGradleVersionsMatchVersionUtils() { assertEquals(releasedWireCompatible, wireCompatible.released); List unreleasedWireCompatible = VersionUtils.allUnreleasedVersions().stream() - /* Gradle skips the current version because being backwards compatible - * with yourself is implied. Java lists the version because it is useful. */ - .filter(v -> !Version.CURRENT.equals(v)) .filter(v -> v.onOrAfter(minimumCompatibleVersion)) .map(Object::toString) .collect(toList()); From 46967d58074b03c49dffa5c190582527e1bc5e05 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Tue, 19 Feb 2019 17:07:58 +0200 Subject: [PATCH 5/6] Add configurations for oss packages --- distribution/build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/distribution/build.gradle b/distribution/build.gradle index dd36bd59c76f0..572b48372ea36 100644 --- a/distribution/build.gradle +++ b/distribution/build.gradle @@ -520,7 +520,8 @@ subprojects { ['archives:windows-zip','archives:oss-windows-zip', 'archives:darwin-tar','archives:oss-darwin-tar', 'archives:linux-tar', 'archives:oss-linux-tar', - 'packages:rpm', 'packages:deb' + 'packages:rpm', 'packages:deb', + 'packages:oss-rpm', 'packages:oss-deb', ].forEach { subName -> Project subproject = project("${project.path}:${subName}") Configuration configuration = configurations.create(subproject.name) From df3023c2921cf0ef1f43c5e034110c5f6b15b274 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Thu, 28 Feb 2019 10:14:37 +0200 Subject: [PATCH 6/6] PR comments --- .../gradle/test/ClusterFormationTasks.groovy | 2 +- .../gradle/vagrant/VagrantTestPlugin.groovy | 4 ++-- .../gradle/VersionCollection.java | 24 ++++++++++++------- .../gradle/VersionCollectionTests.java | 18 +++++++------- distribution/bwc/build.gradle | 2 +- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy index 23385fc9ee91a..dca45e2b98a60 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy @@ -216,7 +216,7 @@ class ClusterFormationTasks { } if (unreleasedInfo != null) { dependency = project.dependencies.project( - path: unreleasedInfo.gradleProjectName, configuration: snapshotProject + path: unreleasedInfo.gradleProjectPath, configuration: snapshotProject ) } else if (internalBuild && elasticsearchVersion.equals(VersionProperties.elasticsearch)) { dependency = project.dependencies.project(path: ":distribution:archives:${snapshotProject}") diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy index 55fa64b1c7065..fe3ba216f2ba6 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy @@ -199,10 +199,10 @@ class VagrantTestPlugin implements Plugin { // handle snapshots pointing to bwc build UPGRADE_FROM_ARCHIVES.each { dependencies.add(project.dependencies.project( - path: "${unreleasedInfo.gradleProjectName}", configuration: it)) + path: "${unreleasedInfo.gradleProjectPath}", configuration: it)) if (upgradeFromVersion.onOrAfter('6.3.0')) { dependencies.add(project.dependencies.project( - path: "${unreleasedInfo.gradleProjectName}", configuration: "oss-${it}")) + path: "${unreleasedInfo.gradleProjectPath}", configuration: "oss-${it}")) } } } else { diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/VersionCollection.java b/buildSrc/src/main/java/org/elasticsearch/gradle/VersionCollection.java index 3ff80d2b21926..dc981a2694e4e 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/VersionCollection.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/VersionCollection.java @@ -57,7 +57,7 @@ *
    *
  • the unreleased major, M+1.0.0 on the `master` branch
  • *
  • the unreleased minor, M.N.0 on the `M.x` (x is literal) branch
  • - *
  • the unreleased bugfix, M.N.c (c > 0) on the `M.b` branch
  • + *
  • the unreleased bugfix, M.N.c (c > 0) on the `M.N` branch
  • *
  • the unreleased maintenance, M-1.d.e ( d > 0, e > 0) on the `(M-1).d` branch
  • *
* In addition to these, there will be a fifth one when a minor reaches feature freeze, we call this the staged @@ -74,7 +74,7 @@ * We can reliably figure out which the unreleased versions are due to the convention of always adding the next unreleased * version number to server in all branches when a version is released. * E.x when M.N.c is released M.N.c+1 is added to the Version class mentioned above in all the following branches: - * `M.b`, `M.x` and `master` so we can reliably assume that the leafs of the version tree are unreleased. + * `M.N`, `M.x` and `master` so we can reliably assume that the leafs of the version tree are unreleased. * This convention is enforced by checking the versions we consider to be unreleased against an * authoritative source (maven central). * We are then able to map the unreleased version to branches in git and Gradle projects that are capable of checking @@ -93,12 +93,12 @@ public class VersionCollection { public class UnreleasedVersionInfo { public final Version version; public final String branch; - public final String gradleProjectName; + public final String gradleProjectPath; - UnreleasedVersionInfo(Version version, String branch, String gradleProjectName) { + UnreleasedVersionInfo(Version version, String branch, String gradleProjectPath) { this.version = version; this.branch = branch; - this.gradleProjectName = gradleProjectName; + this.gradleProjectPath = gradleProjectPath; } } @@ -136,7 +136,7 @@ protected VersionCollection(List versionLines, Version currentVersionPro Map unreleased = new HashMap<>(); for (Version unreleasedVersion : getUnreleased()) { unreleased.put(unreleasedVersion, - new UnreleasedVersionInfo(unreleasedVersion, getBranchFor(unreleasedVersion), getGradleProjectNameFor(unreleasedVersion))); + new UnreleasedVersionInfo(unreleasedVersion, getBranchFor(unreleasedVersion), getGradleProjectPathFor(unreleasedVersion))); } this.unreleased = Collections.unmodifiableMap(unreleased); } @@ -173,7 +173,7 @@ public void forPreviousUnreleased(Consumer consumer) { .map(version -> new UnreleasedVersionInfo( version, getBranchFor(version), - getGradleProjectNameFor(version) + getGradleProjectPathFor(version) ) ) .collect(Collectors.toList()); @@ -181,7 +181,9 @@ public void forPreviousUnreleased(Consumer consumer) { collect.forEach(uvi -> consumer.accept(uvi)); } - private String getGradleProjectNameFor(Version version) { + private String getGradleProjectPathFor(Version version) { + // We have Gradle projects set up to check out and build unreleased versions based on the our branching + // conventions described in this classes javadoc if (version.equals(currentVersion)) { return ":distribution"; } @@ -213,7 +215,11 @@ private String getGradleProjectNameFor(Version version) { } private String getBranchFor(Version version) { - switch (getGradleProjectNameFor(version)) { + // based on the rules described in this classes javadoc, figure out the branch on which an unreleased version + // lives. + // We do this based on the Gradle project path because there's a direct correlation, so we dont have to duplicate + // the logic from there + switch (getGradleProjectPathFor(version)) { case ":distribution": return "master"; case ":distribution:bwc:minor": diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/VersionCollectionTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/VersionCollectionTests.java index 17e347795d6ed..03e08cb3ffe45 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/VersionCollectionTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/VersionCollectionTests.java @@ -307,28 +307,28 @@ public void testGetBranch() { ); } - public void testGetGradleProjectName() { - assertUnreleasedGradleProjectNames( + public void testGetGradleProjectPath() { + assertUnreleasedGradleProjectPaths( asList(":distribution:bwc:bugfix", ":distribution:bwc:minor"), getVersionCollection("7.0.0-alpha1") ); - assertUnreleasedGradleProjectNames( + assertUnreleasedGradleProjectPaths( asList(":distribution:bwc:maintenance", ":distribution:bwc:bugfix"), getVersionCollection("6.5.0") ); - assertUnreleasedGradleProjectNames( + assertUnreleasedGradleProjectPaths( singletonList(":distribution:bwc:maintenance"), getVersionCollection("6.4.2") ); - assertUnreleasedGradleProjectNames( + assertUnreleasedGradleProjectPaths( asList(":distribution:bwc:maintenance", ":distribution:bwc:bugfix", ":distribution:bwc:minor"), getVersionCollection("6.6.0") ); - assertUnreleasedGradleProjectNames( + assertUnreleasedGradleProjectPaths( asList(":distribution:bwc:bugfix", ":distribution:bwc:staged", ":distribution:bwc:minor"), getVersionCollection("8.0.0") ); - assertUnreleasedGradleProjectNames( + assertUnreleasedGradleProjectPaths( asList(":distribution:bwc:staged", ":distribution:bwc:minor"), getVersionCollection("7.1.0") ); @@ -382,10 +382,10 @@ public void testCompareToAuthoritativeNotReallyRelesed() { vc.compareToAuthoritative(authoritativeReleasedVersions); } - private void assertUnreleasedGradleProjectNames(List expectedNAmes, VersionCollection versionCollection) { + private void assertUnreleasedGradleProjectPaths(List expectedNAmes, VersionCollection versionCollection) { List actualNames = new ArrayList<>(); versionCollection.forPreviousUnreleased(unreleasedVersion -> - actualNames.add(unreleasedVersion.gradleProjectName) + actualNames.add(unreleasedVersion.gradleProjectPath) ); assertEquals(expectedNAmes, actualNames); } diff --git a/distribution/bwc/build.gradle b/distribution/bwc/build.gradle index b49562e5e2ba0..8459257ddd329 100644 --- a/distribution/bwc/build.gradle +++ b/distribution/bwc/build.gradle @@ -33,7 +33,7 @@ import static org.elasticsearch.gradle.BuildPlugin.getJavaHome * unreleased versions are when Gradle projects are set up, so we use "build-unreleased-version-*" as placeholders * and configure them to build various versions here. */ -bwcVersions.forPreviousUnreleased { VersionCollection.UnreleasedVersionInfo unreleasedVersion -> project("${unreleasedVersion.gradleProjectName}") { +bwcVersions.forPreviousUnreleased { VersionCollection.UnreleasedVersionInfo unreleasedVersion -> project("${unreleasedVersion.gradleProjectPath}") { Version bwcVersion = unreleasedVersion.version String bwcBranch = unreleasedVersion.branch apply plugin: 'distribution'