You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dp...@apache.org on 2018/11/29 17:32:10 UTC

ignite git commit: IGNITE-8379 Add maven-surefire-plugin support for PDS Compatibility tests. - Fixes #5411.

Repository: ignite
Updated Branches:
  refs/heads/master 4a8c38c8b -> 51d36e8f6


IGNITE-8379 Add maven-surefire-plugin support for PDS Compatibility tests. - Fixes #5411.

Signed-off-by: Dmitriy Pavlov <dp...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/51d36e8f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/51d36e8f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/51d36e8f

Branch: refs/heads/master
Commit: 51d36e8f61ec8def62d22e8fa7928152f4f3e4d6
Parents: 4a8c38c
Author: Vyacheslav Daradur <da...@gmail.com>
Authored: Thu Nov 29 20:31:47 2018 +0300
Committer: Dmitriy Pavlov <dp...@apache.org>
Committed: Thu Nov 29 20:31:47 2018 +0300

----------------------------------------------------------------------
 .../IgnitePKIndexesMigrationToUnwrapPkTest.java |  16 ++-
 .../testframework/junits/Dependency.java        | 123 +++++++++----------
 .../junits/IgniteCompatibilityAbstractTest.java |  40 +++---
 .../testframework/util/MavenUtils.java          |  15 +--
 4 files changed, 101 insertions(+), 93 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/51d36e8f/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/IgnitePKIndexesMigrationToUnwrapPkTest.java
----------------------------------------------------------------------
diff --git a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/IgnitePKIndexesMigrationToUnwrapPkTest.java b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/IgnitePKIndexesMigrationToUnwrapPkTest.java
index 316e574..da77dd8 100644
--- a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/IgnitePKIndexesMigrationToUnwrapPkTest.java
+++ b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/IgnitePKIndexesMigrationToUnwrapPkTest.java
@@ -21,6 +21,7 @@ package org.apache.ignite.compatibility.persistence;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Set;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.cache.query.SqlFieldsQuery;
 import org.apache.ignite.compatibility.testframework.junits.Dependency;
@@ -50,15 +51,23 @@ public class IgnitePKIndexesMigrationToUnwrapPkTest extends IgnitePersistenceCom
     }
 
     /** {@inheritDoc} */
-    @NotNull @Override protected Collection<Dependency> getDependencies(String igniteVer) {
+    @Override @NotNull protected Collection<Dependency> getDependencies(String igniteVer) {
         Collection<Dependency> dependencies = super.getDependencies(igniteVer);
 
-        dependencies.add(new Dependency("indexing", null, "ignite-indexing", igniteVer));
-        dependencies.add(new Dependency("h2", "com.h2database", "h2", "1.4.195", true));
+        dependencies.add(new Dependency("h2", "com.h2database", "h2", "1.4.195", false));
 
         return dependencies;
     }
 
+    /** {@inheritDoc} */
+    @Override @NotNull protected Set<String> getExcluded(Collection<Dependency> dependencies) {
+        Set<String> excluded = super.getExcluded(dependencies);
+
+        excluded.add("h2");
+
+        return excluded;
+    }
+
     /**
      * Tests opportunity to read data from previous Ignite DB version.
      *
@@ -245,5 +254,4 @@ public class IgnitePKIndexesMigrationToUnwrapPkTest extends IgnitePersistenceCom
             cfg.setDataStorageConfiguration(memCfg);
         }
     }
-
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/51d36e8f/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/Dependency.java
----------------------------------------------------------------------
diff --git a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/Dependency.java b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/Dependency.java
index a30fb1e..1316203 100644
--- a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/Dependency.java
+++ b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/Dependency.java
@@ -17,96 +17,76 @@
 
 package org.apache.ignite.compatibility.testframework.junits;
 
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 /**
  * Module dependency: Should be filtered out from current test classpath for separate JVM classpath.
  */
 public class Dependency {
-    /** Local module name. Folder name where module is located. */
-    private String locModuleName;
+    /** Default value of group id. */
+    private static final String DEFAULT_GROUP_ID = "org.apache.ignite";
 
-    /** Group name. Null means ignite default group name. */
-    @Nullable
-    private String groupName;
+    /** Local module name. Folder name where module is located. */
+    private final String locModuleName;
 
-    /** Artifact name (artifact ID) without group name. */
-    private String artifactName;
+    /** Group id. */
+    private final String groupId;
 
-    /** Version. Null means default Ignite version is to be used. May be used for 3rd party dependencies. */
-    @Nullable
-    private String version;
+    /** Artifact id. */
+    private final String artifactId;
 
-    /** Test flag. Test jar should have {@code true} value. Default is {@code false}. */
-    private boolean test;
+    /** Version. {@code null} means default Ignite version is to be used. May be used for 3rd party dependencies. */
+    @Nullable private final String ver;
 
-    /** */
-    private String exludePathFromClassPath;
+    /** Test flag. Test jar should have {@code true} value. */
+    private final boolean test;
 
     /**
-     * Creates dependency.
+     * Creates dependency with {@link #DEFAULT_GROUP_ID} as group id.
      *
      * @param locModuleName Local module name. Folder name where module is located.
-     * @param artifactName Artifact name (artifact ID) without group name.
-     * @param test Test flag. Test jar should have {@code true} value. Default is {@code false}.
+     * @param artifactId Artifact id.
+     * @param test Test flag. Test jar should have {@code true} value.
      */
-    public Dependency(String locModuleName, String artifactName, boolean test) {
-        this.locModuleName = locModuleName;
-        this.artifactName = artifactName;
-        this.test = test;
+    public Dependency(String locModuleName, String artifactId, boolean test) {
+        this(locModuleName, artifactId, null, test);
     }
 
     /**
-     * Creates dependency.
+     * Creates dependency with {@link #DEFAULT_GROUP_ID} as group id.
      *
      * @param locModuleName Local module name. Folder name where module is located.
-     * @param artifactName Artifact name (artifact ID) without group name.
+     * @param artifactId Artifact id.
+     * @param ver Version, {@code null} means default Ignite version is to be used.
+     * @param test Test flag. Test jar should have {@code true} value.
      */
-    public Dependency(String locModuleName, String artifactName) {
-        this.locModuleName = locModuleName;
-        this.artifactName = artifactName;
+    public Dependency(String locModuleName, String artifactId, String ver, boolean test) {
+        this(locModuleName, DEFAULT_GROUP_ID, artifactId, ver, test);
     }
 
     /**
+     * Creates dependency with given parameters.
+     *
      * @param locModuleName Local module name. Folder name where module is located.
-     * @param grpName Group name. Null means ignite default group name.
-     * @param artifactName Artifact name (artifact ID) without group na
-     * @param version Version. Null means default Ignite version is to be used. M
-     */
-    public Dependency(String locModuleName, @Nullable String grpName, String artifactName, @Nullable String version) {
-        this(locModuleName, grpName, artifactName, version, false);
-    }
-
-    /**
-     * @param excludeName Local module name or part of exclude path.
-     * @param grpName Group name. Null means ignite default group name.
-     * @param artifactName Artifact name (artifact ID) without group na
-     * @param version Version. Null means default Ignite version is to be used. M
-     * @param exludeNotLocModule {@code true} In case param @excludeName should exclude path instead of local module.
+     * @param groupId Group id.
+     * @param artifactId Artifact id.
+     * @param ver Dependency version, {@code null} means default Ignite version is to be used.
+     * @param test Test flag. Test jar should have {@code true} value.
      */
-    public Dependency(String excludeName, @Nullable String grpName, String artifactName, @Nullable String version,
-        boolean exludeNotLocModule) {
-        if (exludeNotLocModule)
-            this.exludePathFromClassPath = excludeName;
-        else
-            this.locModuleName = excludeName;
-
-        this.groupName = grpName;
-        this.artifactName = artifactName;
-        this.version = version;
-    }
-
-    /**
-     * @return Path to exclude form classpath.
-     */
-    public String excludePathFromClassPath() {
-        return exludePathFromClassPath;
+    public Dependency(@NotNull String locModuleName, @NotNull String groupId, @NotNull String artifactId,
+        @Nullable String ver, boolean test) {
+        this.locModuleName = locModuleName;
+        this.groupId = groupId;
+        this.artifactId = artifactId;
+        this.ver = ver;
+        this.test = test;
     }
 
     /**
-     * @return path based on local module name to exclude from classpath
+     * @return Template of sources path based on local module name.
      */
-    public String localPathTemplate() {
+    public String sourcePathTemplate() {
         return "modules/" +
             locModuleName +
             "/target/" +
@@ -114,30 +94,37 @@ public class Dependency {
     }
 
     /**
-     * @return {@link #artifactName}
+     * @return Template of artifact's path in Maven repository.
+     */
+    public String artifactPathTemplate() {
+        return "repository/" + groupId.replaceAll("\\.", "/") + "/" + artifactId;
+    }
+
+    /**
+     * @return Dependency artifact id.
      */
-    public String artifactName() {
-        return artifactName;
+    public String artifactId() {
+        return artifactId;
     }
 
     /**
-     * @return classifier or {@code} null depending on {@link #test} flag
+     * @return Classifier or {@code null} depending on {@link #test} flag.
      */
     @Nullable public String classifier() {
         return test ? "tests" : null;
     }
 
     /**
-     * @return {@link #version}
+     * @return Dependency version.
      */
     @Nullable public String version() {
-        return version;
+        return ver;
     }
 
     /**
-     * @return {@link #groupName}
+     * @return Dependency group id.
      */
-    @Nullable public String groupName() {
-        return groupName;
+    public String groupId() {
+        return groupId;
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/51d36e8f/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityAbstractTest.java b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityAbstractTest.java
index 71ff9ff..2d73bd8 100644
--- a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityAbstractTest.java
+++ b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityAbstractTest.java
@@ -21,12 +21,12 @@ import java.io.File;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Objects;
+import java.util.HashSet;
+import java.util.Optional;
 import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.compatibility.testframework.junits.logger.ListenedGridTestLog4jLogger;
@@ -169,25 +169,22 @@ public abstract class IgniteCompatibilityAbstractTest extends GridCommonAbstract
 
                 final Collection<Dependency> dependencies = getDependencies(ver);
 
-                Set<String> excludedModules = dependencies.stream().map(Dependency::localPathTemplate).collect(Collectors.toSet());
-
-                Set<String> excludedPaths = dependencies.stream().map(Dependency::excludePathFromClassPath).filter(Objects::nonNull).collect(Collectors.toSet());
+                Set<String> excluded = getExcluded(dependencies);
 
                 StringBuilder pathBuilder = new StringBuilder();
 
                 for (URL url : CompatibilityTestsUtils.classLoaderUrls(CLASS_LOADER)) {
                     String path = url.getPath();
 
-                    if (excludedModules.stream().noneMatch(path::contains) && excludedPaths.stream().noneMatch(path::contains))
+                    if (excluded.stream().noneMatch(path::contains))
                         pathBuilder.append(path).append(File.pathSeparator);
                 }
 
                 for (Dependency dependency : dependencies) {
-                    final String artifactVer = dependency.version() != null ? dependency.version() : ver;
-                    final String grpName = dependency.groupName() != null ? dependency.groupName() : "org.apache.ignite";
+                    final String artifactVer = Optional.ofNullable(dependency.version()).orElse(ver);
 
-                    String pathToArtifact = MavenUtils.getPathToIgniteArtifact(grpName, dependency.artifactName(),
-                        artifactVer, dependency.classifier());
+                    String pathToArtifact = MavenUtils.getPathToIgniteArtifact(dependency.groupId(),
+                        dependency.artifactId(), artifactVer, dependency.classifier());
 
                     pathBuilder.append(pathToArtifact).append(File.pathSeparator);
                 }
@@ -243,16 +240,31 @@ public abstract class IgniteCompatibilityAbstractTest extends GridCommonAbstract
     @NotNull protected Collection<Dependency> getDependencies(String igniteVer) {
         final Collection<Dependency> dependencies = new ArrayList<>();
 
-        dependencies.add(new Dependency("core", "ignite-core"));
+        dependencies.add(new Dependency("core", "ignite-core", false));
         dependencies.add(new Dependency("core", "ignite-core", true));
 
-        //Just to exclude indexing module
-        dependencies.add(new Dependency("indexing", "ignite-core"));
-
         return dependencies;
     }
 
     /**
+     * @param dependencies Dependencies to filter.
+     * @return Set of paths to exclude.
+     */
+    @NotNull protected Set<String> getExcluded(Collection<Dependency> dependencies) {
+        Set<String> excluded = new HashSet<>();
+
+        for (Dependency dependency : dependencies) {
+            excluded.add(dependency.sourcePathTemplate());
+            excluded.add(dependency.artifactPathTemplate());
+        }
+
+        // Just to exclude indexing module
+        excluded.add("indexing");
+
+        return excluded;
+    }
+
+    /**
      * Allows to setup JVM arguments for standalone JVM
      *
      * @return additional JVM arguments

http://git-wip-us.apache.org/repos/asf/ignite/blob/51d36e8f/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtils.java
----------------------------------------------------------------------
diff --git a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtils.java b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtils.java
index 7eb3131..a05cfd9 100644
--- a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtils.java
+++ b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtils.java
@@ -46,23 +46,24 @@ public class MavenUtils {
     private static boolean useGgRepo;
 
     /**
-     * Gets a path to an artifact with given version and groupId=org.apache.ignite and artifactId={@code artifactName}.
+     * Gets a path to an artifact with given version and groupId=org.apache.ignite and artifactId={@code artifactId}.
      * <br>
      * At first, artifact is looked for in the Maven local repository, if it isn't exists there, it will be downloaded
      * and stored via Maven.
      * <br>
-     * @param groupName group name, e.g. 'org.apache.ignite'.
+     *
+     * @param groupId group name, e.g. 'org.apache.ignite'.
      * @param ver Version of ignite or 3rd party library artifact.
      * @param classifier Artifact classifier.
      * @return Path to the artifact.
      * @throws Exception In case of an error.
      * @see #getPathToArtifact(String)
      */
-    public static String getPathToIgniteArtifact(@NotNull String groupName,
-        @NotNull String artifactName, @NotNull String ver,
+    public static String getPathToIgniteArtifact(@NotNull String groupId,
+        @NotNull String artifactId, @NotNull String ver,
         @Nullable String classifier) throws Exception {
-        String artifact = groupName +
-            ":" + artifactName + ":" + ver;
+        String artifact = groupId +
+            ":" + artifactId + ":" + ver;
 
         if (classifier != null)
             artifact += ":jar:" + classifier;
@@ -213,6 +214,6 @@ public class MavenUtils {
         if (m2Home == null)
             return "mvn";
 
-        return m2Home + "/bin/mvn" ;
+        return m2Home + "/bin/mvn";
     }
 }