This is an automated email from the ASF dual-hosted git repository. bschuchardt pushed a commit to branch feature/GEODE-7250 in repository https://gitbox.apache.org/repos/asf/geode.git
commit 3c0174c1f541944ac9f1cbeb8f1d0e01db6cf466 Author: Bruce Schuchardt <[email protected]> AuthorDate: Fri Sep 27 11:15:06 2019 -0700 GEODE-7250 accomodate new versions greater than 1.9 --- .../Tomcat8ClientServerRollingUpgradeTest.java | 3 +- ...omcatSessionBackwardsCompatibilityTestBase.java | 11 ++- .../geode/ClusterCommunicationsDUnitTest.java | 3 +- ...aAuthorizationUsingLegacySecurityDUnitTest.java | 10 +-- ...onUsingLegacySecurityWithFailoverDUnitTest.java | 10 +-- .../geode/test/dunit/internal/ProcessManager.java | 15 ++-- .../org/apache/geode/test/version/TestVersion.java | 96 ++++++++++++++++++++++ .../apache/geode/test/version/VersionManager.java | 27 ++---- .../LuceneSearchWithRollingUpgradeDUnit.java | 3 +- geode-old-versions/build.gradle | 5 +- ...ipleReceiversDefinedInClusterConfiguration.java | 3 +- settings.gradle | 3 +- 12 files changed, 141 insertions(+), 48 deletions(-) diff --git a/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/Tomcat8ClientServerRollingUpgradeTest.java b/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/Tomcat8ClientServerRollingUpgradeTest.java index eb292ae..37528dd 100644 --- a/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/Tomcat8ClientServerRollingUpgradeTest.java +++ b/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/Tomcat8ClientServerRollingUpgradeTest.java @@ -43,6 +43,7 @@ import org.apache.geode.test.junit.categories.BackwardCompatibilityTest; import org.apache.geode.test.junit.rules.gfsh.GfshRule; import org.apache.geode.test.junit.rules.gfsh.GfshScript; import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory; +import org.apache.geode.test.version.TestVersion; import org.apache.geode.test.version.VersionManager; /** @@ -64,7 +65,7 @@ public class Tomcat8ClientServerRollingUpgradeTest { List<String> result = VersionManager.getInstance().getVersionsWithoutCurrent(); String minimumVersion = SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9) ? "1.8.0" : "1.7.0"; - result.removeIf(s -> s.compareTo(minimumVersion) < 0); + result.removeIf(s -> TestVersion.compare(s, minimumVersion) < 0); return result; } diff --git a/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTestBase.java b/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTestBase.java index 0202647..f4b8272 100644 --- a/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTestBase.java +++ b/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTestBase.java @@ -37,6 +37,7 @@ import org.apache.geode.management.internal.cli.util.CommandStringBuilder; import org.apache.geode.test.junit.categories.BackwardCompatibilityTest; import org.apache.geode.test.junit.rules.GfshCommandRule; import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory; +import org.apache.geode.test.version.TestVersion; import org.apache.geode.test.version.VersionManager; /** @@ -52,7 +53,7 @@ public abstract class TomcatSessionBackwardsCompatibilityTestBase { @Parameterized.Parameters public static Collection<String> data() { List<String> result = VersionManager.getInstance().getVersionsWithoutCurrent(); - result.removeIf(s -> Integer.parseInt(VersionManager.getInstance().versionWithNoDots(s)) < 120); + result.removeIf(s -> TestVersion.compare(s, "1.2.0") < 0); if (result.size() < 1) { throw new RuntimeException("No older versions of Geode were found to test against"); } @@ -87,7 +88,13 @@ public abstract class TomcatSessionBackwardsCompatibilityTestBase { protected TomcatSessionBackwardsCompatibilityTestBase(String version) { VersionManager versionManager = VersionManager.getInstance(); - String installLocation = versionManager.getInstall(version); + String installLocation = null; + try { + installLocation = versionManager.getInstall(version); + } finally { + System.out.println( + "BRUCE: for version " + version + " the installation directory is " + installLocation); + } oldBuild = new File(installLocation); oldModules = new File(installLocation + "/tools/Modules/"); } diff --git a/geode-core/src/distributedTest/java/org/apache/geode/ClusterCommunicationsDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/ClusterCommunicationsDUnitTest.java index cc80088..2de8462 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/ClusterCommunicationsDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/ClusterCommunicationsDUnitTest.java @@ -91,6 +91,7 @@ import org.apache.geode.test.junit.categories.BackwardCompatibilityTest; import org.apache.geode.test.junit.categories.MembershipTest; import org.apache.geode.test.junit.rules.serializable.SerializableTestName; import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory; +import org.apache.geode.test.version.TestVersion; import org.apache.geode.test.version.VersionManager; /** @@ -202,7 +203,7 @@ public class ClusterCommunicationsDUnitTest implements Serializable { @Test public void performARollingUpgrade() { List<String> testVersions = VersionManager.getInstance().getVersionsWithoutCurrent(); - Collections.sort(testVersions); + Collections.sort(testVersions, (v1, v2) -> TestVersion.compare(v1, v2)); String testVersion = testVersions.get(testVersions.size() - 1); // create a cluster with the previous version of Geode diff --git a/geode-core/src/distributedTest/java/org/apache/geode/security/ClientDataAuthorizationUsingLegacySecurityDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/security/ClientDataAuthorizationUsingLegacySecurityDUnitTest.java index 55342d2..e55a67f 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/security/ClientDataAuthorizationUsingLegacySecurityDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/security/ClientDataAuthorizationUsingLegacySecurityDUnitTest.java @@ -50,6 +50,7 @@ import org.apache.geode.test.dunit.rules.ClusterStartupRule; import org.apache.geode.test.dunit.rules.MemberVM; import org.apache.geode.test.junit.categories.SecurityTest; import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory; +import org.apache.geode.test.version.TestVersion; import org.apache.geode.test.version.VersionManager; /** @@ -98,8 +99,7 @@ public class ClientDataAuthorizationUsingLegacySecurityDUnitTest { // We want the cluster VMs to be super-users for ease of testing / remote invocation. Properties clusterMemberProperties = getVMPropertiesWithPermission("cluster,data"); - int version = Integer.parseInt(VersionManager.getInstance().versionWithNoDots(clientVersion)); - if (version == 0 || version >= 140) { + if (TestVersion.compare(clientVersion, "1.4.0") >= 0) { clusterMemberProperties.setProperty(ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER, "org.apache.geode.security.templates.UsernamePrincipal"); } @@ -145,8 +145,7 @@ public class ClientDataAuthorizationUsingLegacySecurityDUnitTest { @Test public void dataWriteCannotGet() throws Exception { Properties props = getVMPropertiesWithPermission("dataWrite"); - int version = Integer.parseInt(VersionManager.getInstance().versionWithNoDots(clientVersion)); - if (version == 0 || version >= 140) { + if (TestVersion.compare(clientVersion, "1.4.0") >= 0) { props.setProperty(ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER, "org.apache.geode.security.templates.UsernamePrincipal"); } @@ -206,8 +205,7 @@ public class ClientDataAuthorizationUsingLegacySecurityDUnitTest { @Test public void dataReadCannotPut() throws Exception { Properties props = getVMPropertiesWithPermission("dataRead"); - int version = Integer.parseInt(VersionManager.getInstance().versionWithNoDots(clientVersion)); - if (version == 0 || version >= 140) { + if (TestVersion.compare(clientVersion, "1.4.0") >= 0) { props.setProperty(ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER, "org.apache.geode.security.templates.UsernamePrincipal"); } diff --git a/geode-core/src/distributedTest/java/org/apache/geode/security/ClientDataAuthorizationUsingLegacySecurityWithFailoverDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/security/ClientDataAuthorizationUsingLegacySecurityWithFailoverDUnitTest.java index dfcd100..0ae5aa1 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/security/ClientDataAuthorizationUsingLegacySecurityWithFailoverDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/security/ClientDataAuthorizationUsingLegacySecurityWithFailoverDUnitTest.java @@ -57,6 +57,7 @@ import org.apache.geode.test.dunit.rules.ClusterStartupRule; import org.apache.geode.test.dunit.rules.MemberVM; import org.apache.geode.test.junit.categories.SecurityTest; import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory; +import org.apache.geode.test.version.TestVersion; import org.apache.geode.test.version.VersionManager; /** @@ -131,8 +132,7 @@ public class ClientDataAuthorizationUsingLegacySecurityWithFailoverDUnitTest { @Before public void setup() throws Exception { Properties clusterMemberProperties = getVMPropertiesWithPermission("cluster,data"); - int version = Integer.parseInt(VersionManager.getInstance().versionWithNoDots(clientVersion)); - if (version == 0 || version >= 140) { + if (TestVersion.compare(clientVersion, "1.4.0") >= 0) { clusterMemberProperties.setProperty(ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER, "org.apache.geode.security.templates.UsernamePrincipal"); } @@ -317,8 +317,7 @@ public class ClientDataAuthorizationUsingLegacySecurityWithFailoverDUnitTest { @Test public void dataWriterCannotRegisterInterestAcrossFailover() throws Exception { Properties props = getVMPropertiesWithPermission("dataWrite"); - int version = Integer.parseInt(VersionManager.getInstance().versionWithNoDots(clientVersion)); - if (version == 0 || version >= 140) { + if (TestVersion.compare(clientVersion, "1.4.0") >= 0) { props.setProperty(ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER, "org.apache.geode.security.templates.UsernamePrincipal"); } @@ -378,8 +377,7 @@ public class ClientDataAuthorizationUsingLegacySecurityWithFailoverDUnitTest { Properties props = getVMPropertiesWithPermission(withPermission); - int version = Integer.parseInt(VersionManager.getInstance().versionWithNoDots(clientVersion)); - if (version == 0 || version >= 140) { + if (TestVersion.compare(clientVersion, "1.4.0") >= 0) { props.setProperty(ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER, "org.apache.geode.security.templates.UsernamePrincipal"); } diff --git a/geode-dunit/src/main/java/org/apache/geode/test/dunit/internal/ProcessManager.java b/geode-dunit/src/main/java/org/apache/geode/test/dunit/internal/ProcessManager.java index 5035d2e..4529b15 100755 --- a/geode-dunit/src/main/java/org/apache/geode/test/dunit/internal/ProcessManager.java +++ b/geode-dunit/src/main/java/org/apache/geode/test/dunit/internal/ProcessManager.java @@ -209,15 +209,18 @@ class ProcessManager implements ChildVMLauncher { return classpath; } - private String removeModuleFromIntelliJPath(String classpath, String module) { + private String removeModuleFromIntelliJPath(String p_classpath, String module) { + String classpath = p_classpath; String mainClasses = File.separator + "out" + File.separator + "production" + File.separator + "org.apache.geode." + module + ".main"; - - if (!classpath.contains(mainClasses)) { - return classpath; + if (classpath.contains(mainClasses)) { + classpath = removeFromPath(classpath, mainClasses); + } + mainClasses = File.separator + "out" + File.separator + "production" + + File.separator + "geode." + module + ".main"; + if (classpath.contains(mainClasses)) { + classpath = removeFromPath(classpath, mainClasses); } - - classpath = removeFromPath(classpath, mainClasses); return classpath; } diff --git a/geode-junit/src/main/java/org/apache/geode/test/version/TestVersion.java b/geode-junit/src/main/java/org/apache/geode/test/version/TestVersion.java new file mode 100644 index 0000000..ac3a791 --- /dev/null +++ b/geode-junit/src/main/java/org/apache/geode/test/version/TestVersion.java @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.apache.geode.test.version; + +import java.util.Objects; + +public class TestVersion implements Comparable { + private final int major; + private final int minor; + private final int patch; + + public TestVersion(String versionString) { + String[] split = versionString.split("\\."); + if (split.length != 3) { + throw new IllegalArgumentException("Expected a version string but received " + versionString); + } + major = Integer.parseInt(split[0]); + minor = Integer.parseInt(split[1]); + if (split[2].contains("-incubating")) { + split[2] = split[2].substring(0, split[2].length() - "-incubating".length()); + } + patch = Integer.parseInt(split[2]); + } + + /** + * Perform a comparison of the major, minor and patch versions of the two version strings. + * The version strings should be in dot notation. + */ + public static int compare(String version1, String version2) { + return new TestVersion(version1).compareTo(new TestVersion(version2)); + } + + @Override + public String toString() { + return "" + major + "." + minor + "." + patch; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof TestVersion)) { + return false; + } + TestVersion that = (TestVersion) o; + return major == that.major && + minor == that.minor && + patch == that.patch; + } + + @Override + public int hashCode() { + return Objects.hash(major, minor, patch); + } + + public TestVersion(int major, int minor, int patch) { + this.major = major; + this.minor = minor; + this.patch = patch; + } + + @Override + public int compareTo(Object o) { + if (o == null) { + throw new NullPointerException("parameter may not be null"); + } + TestVersion other = (TestVersion) o; + int comparison = Integer.compare(major, other.major); + if (comparison != 0) { + return comparison; + } + comparison = Integer.compare(minor, other.minor); + if (comparison != 0) { + return comparison; + } + return Integer.compare(patch, other.patch); + } + + public int compareTo(int major, int minor, int patch) { + return compareTo(new TestVersion(major, minor, patch)); + } +} diff --git a/geode-junit/src/main/java/org/apache/geode/test/version/VersionManager.java b/geode-junit/src/main/java/org/apache/geode/test/version/VersionManager.java index 54ed847..849de3e 100755 --- a/geode-junit/src/main/java/org/apache/geode/test/version/VersionManager.java +++ b/geode-junit/src/main/java/org/apache/geode/test/version/VersionManager.java @@ -39,7 +39,7 @@ import org.apache.commons.lang3.SystemUtils; * see Host.getVM(String, int) */ public class VersionManager { - public static final String CURRENT_VERSION = "0.0.0"; + public static final String CURRENT_VERSION = "10240.0.0"; private static VersionManager instance; @@ -117,30 +117,15 @@ public class VersionManager { public String getInstall(String version) { - return installs.get(version); - } - - /** - * Remove the dots from a version string. "1.2.0" -> "120" - */ - public String versionWithNoDots(String s) { - StringBuilder b = new StringBuilder(10); - int length = s.length(); - for (int i = 0; i < length; i++) { - char ch = s.charAt(i); - if (ch != '.') { - // leave off any trailing stuff like "-incubating" - if (!Character.isDigit(ch)) { - break; - } - b.append(ch); - } + if (!installs.containsKey(version) || (installs.get(version) == null)) { + throw new IllegalArgumentException("unable to locate installation directory for " + version); } - return b.toString(); + return installs.get(version); } /** - * Returns a list of older versions available for testing + * Returns a list of older versions available for testing. + * Note: if you need to compare version strings use TestVersion.compare() */ public List<String> getVersions() { checkForLoadFailure(); diff --git a/geode-lucene/src/upgradeTest/java/org/apache/geode/cache/lucene/LuceneSearchWithRollingUpgradeDUnit.java b/geode-lucene/src/upgradeTest/java/org/apache/geode/cache/lucene/LuceneSearchWithRollingUpgradeDUnit.java index 1056bfd..2a8cf9f 100644 --- a/geode-lucene/src/upgradeTest/java/org/apache/geode/cache/lucene/LuceneSearchWithRollingUpgradeDUnit.java +++ b/geode-lucene/src/upgradeTest/java/org/apache/geode/cache/lucene/LuceneSearchWithRollingUpgradeDUnit.java @@ -60,6 +60,7 @@ import org.apache.geode.test.dunit.VM; import org.apache.geode.test.dunit.internal.DUnitLauncher; import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase; import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory; +import org.apache.geode.test.version.TestVersion; import org.apache.geode.test.version.VersionManager; @RunWith(Parameterized.class) @@ -82,7 +83,7 @@ public abstract class LuceneSearchWithRollingUpgradeDUnit extends JUnit4Distribu List<String> result = VersionManager.getInstance().getVersionsWithoutCurrent(); // Lucene Compatibility checks start with Apache Geode v1.2.0 // Removing the versions older than v1.2.0 - result.removeIf(s -> Integer.parseInt(VersionManager.getInstance().versionWithNoDots(s)) < 120); + result.removeIf(s -> TestVersion.compare(s, "1.2.0") < 0); if (result.size() < 1) { throw new RuntimeException("No older versions of Geode were found to test against"); } else { diff --git a/geode-old-versions/build.gradle b/geode-old-versions/build.gradle index 322dc83..32d8d05 100644 --- a/geode-old-versions/build.gradle +++ b/geode-old-versions/build.gradle @@ -27,8 +27,9 @@ subprojects { def oldGeodeVersion = project.name - boolean useTgz = (oldGeodeVersion >= "1.7.0") - boolean downloadInstall = (oldGeodeVersion >= "1.2.0") + boolean isIncubating = oldGeodeVersion.contains("incubating") + boolean useTgz = !isIncubating && ((oldGeodeVersion >= "1.7.0") || (oldGeodeVersion.length() > 5)) + boolean downloadInstall = !isIncubating && ((oldGeodeVersion >= "1.2.0") || (oldGeodeVersion.length() > 5)) String archiveType = useTgz ? "tgz" : "zip" diff --git a/geode-wan/src/upgradeTest/java/org/apache/geode/cache/wan/WANRollingUpgradeMultipleReceiversDefinedInClusterConfiguration.java b/geode-wan/src/upgradeTest/java/org/apache/geode/cache/wan/WANRollingUpgradeMultipleReceiversDefinedInClusterConfiguration.java index 62f0cdd..130656d 100644 --- a/geode-wan/src/upgradeTest/java/org/apache/geode/cache/wan/WANRollingUpgradeMultipleReceiversDefinedInClusterConfiguration.java +++ b/geode-wan/src/upgradeTest/java/org/apache/geode/cache/wan/WANRollingUpgradeMultipleReceiversDefinedInClusterConfiguration.java @@ -47,6 +47,7 @@ import org.apache.geode.test.dunit.DistributedTestUtils; import org.apache.geode.test.dunit.Host; import org.apache.geode.test.dunit.NetworkUtils; import org.apache.geode.test.dunit.VM; +import org.apache.geode.test.version.TestVersion; import org.apache.geode.test.version.VersionManager; public class WANRollingUpgradeMultipleReceiversDefinedInClusterConfiguration @@ -95,7 +96,7 @@ public class WANRollingUpgradeMultipleReceiversDefinedInClusterConfiguration // saved in cluster configuration and multiple receivers are not supported starting in 140. // Note: This comparison works because '130' < '140'. List<String> result = VersionManager.getInstance().getVersionsWithoutCurrent(); - result.removeIf(version -> (version.compareTo("1.4.0") >= 0)); + result.removeIf(version -> (TestVersion.compare(version, "1.4.0") >= 0)); if (result.size() < 1) { throw new RuntimeException("No older versions of Geode were found to test against"); } diff --git a/settings.gradle b/settings.gradle index 04f9541..1669d7e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -77,7 +77,8 @@ include 'static-analysis:pmd-rules' '1.7.0', '1.8.0', '1.9.0', - '1.9.1'].each { + '1.9.1', + '1.10.0'].each { include 'geode-old-versions:'.concat(it) }
