You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ab...@apache.org on 2018/11/27 04:46:25 UTC

[geode] branch develop updated: GEODE-6075 Improve tests using the geode version

This is an automated email from the ASF dual-hosted git repository.

abaker pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new b389f5a  GEODE-6075 Improve tests using the geode version
b389f5a is described below

commit b389f5ac1b9bef9966541e263d22df3cb658f215
Author: Anthony Baker <ab...@apache.org>
AuthorDate: Mon Nov 19 21:39:13 2018 -0800

    GEODE-6075 Improve tests using the geode version
    
    Currently several tests check the geode assembly for correctness using
    fixed information, including the geode version.  Every time we bump the
    geode version these tests fail and we have to update the comparison
    files.  This change skips strict version checks on the geode version
    while retaining presence detection (e.g. if geode-core-*.jar was missing
    the test will still fail).
---
 .../geode/AssemblyContentsIntegrationTest.java     |  60 +++++------
 .../geode/GeodeDependencyJarIntegrationTest.java   |  46 ++++-----
 .../integrationTest/resources/assembly_content.txt |  42 ++++----
 .../resources/dependency_classpath.txt             | 114 ++++++++++-----------
 gradle/publish.gradle                              |   8 +-
 5 files changed, 129 insertions(+), 141 deletions(-)

diff --git a/geode-assembly/src/integrationTest/java/org/apache/geode/AssemblyContentsIntegrationTest.java b/geode-assembly/src/integrationTest/java/org/apache/geode/AssemblyContentsIntegrationTest.java
index 2d256cf..4d74481 100644
--- a/geode-assembly/src/integrationTest/java/org/apache/geode/AssemblyContentsIntegrationTest.java
+++ b/geode-assembly/src/integrationTest/java/org/apache/geode/AssemblyContentsIntegrationTest.java
@@ -14,7 +14,7 @@
  */
 package org.apache.geode;
 
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.File;
 import java.io.IOException;
@@ -22,7 +22,6 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Collection;
-import java.util.Set;
 import java.util.TreeSet;
 import java.util.stream.Collectors;
 
@@ -38,58 +37,49 @@ import org.apache.geode.util.test.TestUtil;
 public class AssemblyContentsIntegrationTest {
 
   private static final String GEODE_HOME = System.getenv("GEODE_HOME");
-  private Set<String> expectedAssemblyContent;
+  private Collection<String> expectedAssemblyContent;
 
   @Before
   public void loadExpectedAssemblyContent() throws IOException {
     String assemblyContent =
         TestUtil.getResourcePath(AssemblyContentsIntegrationTest.class, "/assembly_content.txt");
 
-    expectedAssemblyContent = Files.lines(Paths.get(assemblyContent)).collect(Collectors.toSet());
+    expectedAssemblyContent =
+        Files.lines(Paths.get(assemblyContent)).collect(Collectors.toCollection(TreeSet::new));
   }
 
   @Test
   public void verifyAssemblyContents() throws IOException {
-    Set<String> currentAssemblyContent = getAssemblyContent();
-
+    Collection<String> currentAssemblyContent = getAssemblyContent();
     Files.write(Paths.get("assembly_content.txt"), currentAssemblyContent);
 
-    Set<String> newAssemblyContent = new TreeSet<>(currentAssemblyContent);
-    newAssemblyContent.removeAll(expectedAssemblyContent);
-    Set<String> missingAssemblyContent = new TreeSet<>(expectedAssemblyContent);
-    missingAssemblyContent.removeAll(currentAssemblyContent);
-
-    String message =
-        "The assembly contents have changed. Verify dependencies."
-            + "\nWhen fixed, copy geode-assembly/build/integrationTest/assembly_content.txt"
-            + "\nto geode-assembly/src/integrationTest/resources/assembly_content.txt"
-            + "\nRemoved Content\n--------------\n"
-            + String.join("\n", missingAssemblyContent) + "\n\nAdded Content\n--------------\n"
-            + String.join("\n", newAssemblyContent) + "\n\n";
-
-    assertTrue(message, expectedAssemblyContent.equals(currentAssemblyContent));
+    assertThat(currentAssemblyContent)
+        .describedAs("The assembly contents have changed. Verify dependencies and "
+            + "copy geode-assembly/build/integrationTest/assembly_content.txt to "
+            + "geode-assembly/src/integrationTest/resources/assembly_content.txt")
+        .containsExactlyElementsOf(expectedAssemblyContent);
   }
 
   /**
    * Find all of the jars bundled with the project. Key is the name of the jar, value is the path.
    */
-  private Set<String> getAssemblyContent() {
+  private Collection<String> getAssemblyContent() {
     File geodeHomeDirectory = new File(GEODE_HOME);
     Path geodeHomePath = Paths.get(GEODE_HOME);
 
-    assertTrue(
-        "Please set the GEODE_HOME environment variable to the product installation directory.",
-        geodeHomeDirectory.isDirectory());
-
-    Collection<File> contents = FileUtils.listFiles(geodeHomeDirectory, null, true);
-    Set<String> sortedContent = new TreeSet<>();
-    contents.forEach(content -> {
-      Path path = Paths.get(content.getPath());
-      // replacing '\' with '/' to test on windows properly
-      sortedContent.add(geodeHomePath.relativize(path).toString().replace('\\', '/'));
-    });
-
-    return sortedContent;
+    assertThat(geodeHomeDirectory)
+        .describedAs(
+            "Please set the GEODE_HOME environment variable to the product installation directory.")
+        .isDirectory();
+
+    String versionRegex = "\\d+\\.\\d+\\.\\d+(-SNAPSHOT)?";
+    return FileUtils.listFiles(geodeHomeDirectory, null, true).stream()
+        .map(file -> geodeHomePath.relativize(Paths.get(file.getPath())).toString().replace('\\',
+            '/'))
+        .map(entry -> entry.contains("/geode-")
+            ? entry.replaceFirst(versionRegex, "0.0.0") : entry)
+        .map(entry -> entry.contains("Apache_Geode")
+            ? entry.replaceFirst(versionRegex, "0.0.0") : entry)
+        .collect(Collectors.toCollection(TreeSet::new));
   }
-
 }
diff --git a/geode-assembly/src/integrationTest/java/org/apache/geode/GeodeDependencyJarIntegrationTest.java b/geode-assembly/src/integrationTest/java/org/apache/geode/GeodeDependencyJarIntegrationTest.java
index 445db39..c490617 100644
--- a/geode-assembly/src/integrationTest/java/org/apache/geode/GeodeDependencyJarIntegrationTest.java
+++ b/geode-assembly/src/integrationTest/java/org/apache/geode/GeodeDependencyJarIntegrationTest.java
@@ -14,15 +14,14 @@
  */
 package org.apache.geode;
 
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.Arrays;
-import java.util.Set;
-import java.util.TreeSet;
+import java.util.List;
 import java.util.jar.JarFile;
 import java.util.jar.Manifest;
 import java.util.stream.Collectors;
@@ -38,7 +37,7 @@ import org.apache.geode.util.test.TestUtil;
 public class GeodeDependencyJarIntegrationTest {
 
   private static final String GEODE_HOME = System.getenv("GEODE_HOME");
-  private Set<String> expectedClasspathElements;
+  private List<String> expectedClasspathElements;
 
   @Before
   public void loadExpectedClassPath() throws IOException {
@@ -47,40 +46,30 @@ public class GeodeDependencyJarIntegrationTest {
             "/dependency_classpath.txt");
 
     expectedClasspathElements =
-        Files.lines(Paths.get(dependencyClasspath)).collect(Collectors.toSet());
+        Files.lines(Paths.get(dependencyClasspath)).collect(Collectors.toList());
   }
 
   @Test
   public void verifyManifestClassPath() throws IOException {
-    Set<String> currentClasspathElements = getManifestClassPath();
-
+    List<String> currentClasspathElements = getManifestClassPath();
     Files.write(Paths.get("dependency_classpath.txt"), currentClasspathElements);
 
-    Set<String> newClasspathElements = new TreeSet<>(currentClasspathElements);
-    newClasspathElements.removeAll(expectedClasspathElements);
-    Set<String> missingClasspathElements = new TreeSet<>(expectedClasspathElements);
-    missingClasspathElements.removeAll(currentClasspathElements);
-
-    String message =
-        "The geode-dependency jar's manifest classpath has changed. Verify dependencies."
-            + "\nWhen fixed, copy geode-assembly/build/integrationTest/dependency_classpath.txt"
-            + "\nto src/integrationTest/resources/dependency_classpath.txt"
-            + "\nRemoved Elements\n--------------\n"
-            + String.join("\n", missingClasspathElements) + "\n\nAdded Elements\n--------------\n"
-            + String.join("\n", newClasspathElements) + "\n\n";
-
-    assertTrue(message, expectedClasspathElements.equals(currentClasspathElements));
+    assertThat(getManifestClassPath())
+        .describedAs("The geode-dependency jar's manifest classpath has changed. Verify "
+            + "dependencies and copy geode-assembly/build/integrationTest/dependency_classpath.txt "
+            + "to src/integrationTest/resources/dependency_classpath.txt")
+        .containsExactlyElementsOf(expectedClasspathElements);
   }
 
   /**
    * Find all of the jars bundled with the project. Key is the name of the jar, value is the path.
    */
-  private Set<String> getManifestClassPath() throws IOException {
+  private List<String> getManifestClassPath() throws IOException {
     File geodeHomeDirectory = new File(GEODE_HOME);
-
-    assertTrue(
-        "Please set the GEODE_HOME environment variable to the product installation directory.",
-        geodeHomeDirectory.isDirectory());
+    assertThat(geodeHomeDirectory)
+        .describedAs(
+            "Please set the GEODE_HOME environment variable to the product installation directory.")
+        .isDirectory();
 
     JarFile geodeDependencies =
         new JarFile(new File(geodeHomeDirectory, "lib/geode-dependencies.jar"));
@@ -89,6 +78,9 @@ public class GeodeDependencyJarIntegrationTest {
 
     String classpath = geodeDependenciesManifest.getMainAttributes().getValue("Class-Path");
 
-    return Arrays.stream(classpath.split(" ")).collect(Collectors.toSet());
+    return Arrays.stream(classpath.split(" "))
+        .map(entry -> entry.contains("geode")
+            ? entry.replaceFirst("\\d+\\.\\d+\\.\\d+(-SNAPSHOT)?", "0.0.0") : entry)
+        .collect(Collectors.toList());
   }
 }
diff --git a/geode-assembly/src/integrationTest/resources/assembly_content.txt b/geode-assembly/src/integrationTest/resources/assembly_content.txt
index 59f8506..9cd4c19 100644
--- a/geode-assembly/src/integrationTest/resources/assembly_content.txt
+++ b/geode-assembly/src/integrationTest/resources/assembly_content.txt
@@ -876,20 +876,20 @@ lib/commons-validator-1.6.jar
 lib/fastutil-8.2.2.jar
 lib/findbugs-annotations-1.3.9-1.jar
 lib/geo-0.7.1.jar
-lib/geode-common-1.9.0-SNAPSHOT.jar
-lib/geode-connectors-1.9.0-SNAPSHOT.jar
-lib/geode-core-1.9.0-SNAPSHOT.jar
-lib/geode-cq-1.9.0-SNAPSHOT.jar
+lib/geode-common-0.0.0.jar
+lib/geode-connectors-0.0.0.jar
+lib/geode-core-0.0.0.jar
+lib/geode-cq-0.0.0.jar
 lib/geode-dependencies.jar
-lib/geode-jca-1.9.0-SNAPSHOT.rar
-lib/geode-json-1.9.0-SNAPSHOT.jar
-lib/geode-lucene-1.9.0-SNAPSHOT.jar
-lib/geode-old-client-support-1.9.0-SNAPSHOT.jar
-lib/geode-protobuf-1.9.0-SNAPSHOT.jar
-lib/geode-protobuf-messages-1.9.0-SNAPSHOT.jar
-lib/geode-rebalancer-1.9.0-SNAPSHOT.jar
-lib/geode-wan-1.9.0-SNAPSHOT.jar
-lib/geode-web-1.9.0-SNAPSHOT.jar
+lib/geode-jca-0.0.0.rar
+lib/geode-json-0.0.0.jar
+lib/geode-lucene-0.0.0.jar
+lib/geode-old-client-support-0.0.0.jar
+lib/geode-protobuf-0.0.0.jar
+lib/geode-protobuf-messages-0.0.0.jar
+lib/geode-rebalancer-0.0.0.jar
+lib/geode-wan-0.0.0.jar
+lib/geode-web-0.0.0.jar
 lib/gfsh-dependencies.jar
 lib/grumpy-core-0.2.2.jar
 lib/jackson-annotations-2.9.7.jar
@@ -950,11 +950,11 @@ lib/spring-core-4.3.20.RELEASE.jar
 lib/spring-expression-4.3.20.RELEASE.jar
 lib/spring-shell-1.2.0.RELEASE.jar
 lib/spring-web-4.3.20.RELEASE.jar
-tools/ClientProtocol/geode-protobuf-messages-definitions-1.9.0-SNAPSHOT.zip
-tools/Extensions/geode-web-1.9.0-SNAPSHOT.war
-tools/Extensions/geode-web-api-1.9.0-SNAPSHOT.war
-tools/Modules/Apache_Geode_Modules-1.9.0-SNAPSHOT-AppServer.zip
-tools/Modules/Apache_Geode_Modules-1.9.0-SNAPSHOT-Tomcat.zip
-tools/Modules/Apache_Geode_Modules-1.9.0-SNAPSHOT-tcServer.zip
-tools/Modules/Apache_Geode_Modules-1.9.0-SNAPSHOT-tcServer30.zip
-tools/Pulse/geode-pulse-1.9.0-SNAPSHOT.war
+tools/ClientProtocol/geode-protobuf-messages-definitions-0.0.0.zip
+tools/Extensions/geode-web-0.0.0.war
+tools/Extensions/geode-web-api-0.0.0.war
+tools/Modules/Apache_Geode_Modules-0.0.0-AppServer.zip
+tools/Modules/Apache_Geode_Modules-0.0.0-Tomcat.zip
+tools/Modules/Apache_Geode_Modules-0.0.0-tcServer.zip
+tools/Modules/Apache_Geode_Modules-0.0.0-tcServer30.zip
+tools/Pulse/geode-pulse-0.0.0.war
diff --git a/geode-assembly/src/integrationTest/resources/dependency_classpath.txt b/geode-assembly/src/integrationTest/resources/dependency_classpath.txt
index b6cf79d..7c10995 100644
--- a/geode-assembly/src/integrationTest/resources/dependency_classpath.txt
+++ b/geode-assembly/src/integrationTest/resources/dependency_classpath.txt
@@ -1,71 +1,71 @@
-shiro-core-1.4.0.jar
-lucene-analyzers-common-6.6.2.jar
+geode-common-0.0.0.jar
+geode-json-0.0.0.jar
+geode-core-0.0.0.jar
+geode-connectors-0.0.0.jar
+geode-lucene-0.0.0.jar
+geode-old-client-support-0.0.0.jar
+geode-protobuf-0.0.0.jar
+geode-protobuf-messages-0.0.0.jar
+geode-wan-0.0.0.jar
+geode-cq-0.0.0.jar
+geode-rebalancer-0.0.0.jar
+antlr-2.7.7.jar
+jgroups-3.6.14.Final.jar
 jackson-databind-2.9.7.jar
-netty-all-4.1.31.Final.jar
+jackson-annotations-2.9.7.jar
+spring-shell-1.2.0.RELEASE.jar
+commons-io-2.6.jar
+commons-validator-1.6.jar
+activation-1.1.1.jar
+jaxb-api-2.2.11.jar
+jaxb-core-2.2.11.jar
+jaxb-impl-2.2.11.jar
 commons-lang3-3.8.1.jar
-geode-common-1.9.0-SNAPSHOT.jar
-geode-core-1.9.0-SNAPSHOT.jar
-commons-logging-1.2.jar
-geode-old-client-support-1.9.0-SNAPSHOT.jar
+netty-all-4.1.31.Final.jar
+fastutil-8.2.2.jar
+javax.resource-api-1.7.jar
+jna-4.1.0.jar
+jopt-simple-5.0.4.jar
+log4j-slf4j-impl-2.11.1.jar
+log4j-core-2.11.1.jar
+log4j-jcl-2.11.1.jar
 log4j-jul-2.11.1.jar
+log4j-api-2.11.1.jar
+jetty-webapp-9.4.12.v20180830.jar
+spring-core-4.3.20.RELEASE.jar
+snappy-0.4.jar
+shiro-core-1.4.0.jar
+classgraph-4.0.6.jar
+rmiio-2.1.2.jar
+jansi-1.17.1.jar
+shiro-cache-1.4.0.jar
+shiro-crypto-hash-1.4.0.jar
 shiro-crypto-cipher-1.4.0.jar
+shiro-config-ogdl-1.4.0.jar
+shiro-config-core-1.4.0.jar
 shiro-event-1.4.0.jar
-jline-2.12.jar
-shiro-crypto-hash-1.4.0.jar
-fastutil-8.2.2.jar
-activation-1.1.1.jar
-javax.servlet-api-3.1.0.jar
-jgroups-3.6.14.Final.jar
 shiro-crypto-core-1.4.0.jar
 shiro-lang-1.4.0.jar
-jetty-security-9.4.12.v20180830.jar
-lucene-queryparser-6.6.2.jar
 slf4j-api-1.7.25.jar
-spring-core-4.3.20.RELEASE.jar
-jansi-1.17.1.jar
 jackson-core-2.9.7.jar
-geode-wan-1.9.0-SNAPSHOT.jar
-jetty-xml-9.4.12.v20180830.jar
-geode-lucene-1.9.0-SNAPSHOT.jar
-geode-cq-1.9.0-SNAPSHOT.jar
+commons-beanutils-1.9.3.jar
+commons-logging-1.2.jar
 commons-collections-3.2.2.jar
-jetty-webapp-9.4.12.v20180830.jar
-log4j-jcl-2.11.1.jar
-jna-4.1.0.jar
-geode-rebalancer-1.9.0-SNAPSHOT.jar
-rmiio-2.1.2.jar
-commons-codec-1.10.jar
-log4j-api-2.11.1.jar
+javax.transaction-api-1.2.jar
+jetty-xml-9.4.12.v20180830.jar
+jetty-servlet-9.4.12.v20180830.jar
+jline-2.12.jar
+jetty-security-9.4.12.v20180830.jar
 jetty-server-9.4.12.v20180830.jar
-geode-connectors-1.9.0-SNAPSHOT.jar
-HikariCP-3.2.0.jar
-jaxb-impl-2.2.11.jar
-jopt-simple-5.0.4.jar
-jetty-util-9.4.12.v20180830.jar
-lucene-analyzers-phonetic-6.6.2.jar
-shiro-config-ogdl-1.4.0.jar
 jetty-http-9.4.12.v20180830.jar
-geode-protobuf-1.9.0-SNAPSHOT.jar
-classgraph-4.0.6.jar
-snappy-0.4.jar
-javax.resource-api-1.7.jar
-protobuf-java-3.6.1.jar
-lucene-queries-6.6.2.jar
-geode-json-1.9.0-SNAPSHOT.jar
 jetty-io-9.4.12.v20180830.jar
+jetty-util-9.4.12.v20180830.jar
+javax.servlet-api-3.1.0.jar
+HikariCP-3.2.0.jar
+lucene-analyzers-phonetic-6.6.2.jar
+lucene-analyzers-common-6.6.2.jar
+lucene-queryparser-6.6.2.jar
 lucene-core-6.6.2.jar
-spring-shell-1.2.0.RELEASE.jar
-jaxb-api-2.2.11.jar
-jackson-annotations-2.9.7.jar
-log4j-slf4j-impl-2.11.1.jar
-jetty-servlet-9.4.12.v20180830.jar
-jaxb-core-2.2.11.jar
-commons-beanutils-1.9.3.jar
-commons-io-2.6.jar
-commons-validator-1.6.jar
-shiro-config-core-1.4.0.jar
-javax.transaction-api-1.2.jar
-antlr-2.7.7.jar
-shiro-cache-1.4.0.jar
-geode-protobuf-messages-1.9.0-SNAPSHOT.jar
-log4j-core-2.11.1.jar
+lucene-queries-6.6.2.jar
+commons-codec-1.10.jar
+protobuf-java-3.6.1.jar
diff --git a/gradle/publish.gradle b/gradle/publish.gradle
index dc0e708..debde74 100644
--- a/gradle/publish.gradle
+++ b/gradle/publish.gradle
@@ -149,7 +149,13 @@ subprojects {
         def expectedPom = new XmlParser().parse(expectedPomFile.toString())
         def expectedDependencies = new TreeSet()
         expectedPom.dependencies.dependency.each() {
-          expectedDependencies.add(it as String)
+          def dep = it as String
+          if (dep.contains("org.apache.geode")) {
+            // since the project version is the source of truth, use that for comparison instead of
+            // whatever is stored in the expected pom file
+            dep = dep.replaceFirst("(.*\\[)(\\d+.\\d+.\\d+(-SNAPSHOT)?)(\\].*)", '$1' + version + '$4')
+          }
+          expectedDependencies.add(dep)
         }
 
         def actualPomFile = generatePomFileForMavenPublication.outputs.files.first()