You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by bi...@apache.org on 2022/07/20 18:16:34 UTC

[storm] branch master updated: STORM-3873: Remove junit4 dependency (#3488)

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

bipinprasad pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/storm.git


The following commit(s) were added to refs/heads/master by this push:
     new e694f5959 STORM-3873: Remove junit4 dependency (#3488)
e694f5959 is described below

commit e694f59595669565e9963133a6c290fd5a9cfce9
Author: snikhil5 <ns...@yahoo.com>
AuthorDate: Wed Jul 20 13:16:27 2022 -0500

    STORM-3873: Remove junit4 dependency (#3488)
    
    * STORM-3873: Remove junit4 dependency
    
    * STORM-3877: use unittest pkg for mock
    
    Co-authored-by: snikhil5 <ni...@nik.com>
---
 DEPENDENCY-LICENSES                                |  6 ----
 external/storm-hdfs-blobstore/pom.xml              |  7 -----
 external/storm-hdfs/pom.xml                        |  7 -----
 .../hdfs/testing/MiniDFSClusterExtension.java      | 33 ++++++++++++++++++++++
 .../testing/MiniDFSClusterExtensionClassLevel.java |  5 ++++
 storm-client/test/py/test_storm_cli.py             |  4 +--
 6 files changed, 40 insertions(+), 22 deletions(-)

diff --git a/DEPENDENCY-LICENSES b/DEPENDENCY-LICENSES
index f991a7fa9..54c68199d 100644
--- a/DEPENDENCY-LICENSES
+++ b/DEPENDENCY-LICENSES
@@ -563,7 +563,6 @@ List of third-party dependencies grouped by their license type.
         * ASM Core (asm:asm:3.1 - http://asm.objectweb.org/asm/)
         * ASM Tree (asm:asm-tree:3.1 - http://asm.objectweb.org/asm-tree/)
         * Commons Compiler (org.codehaus.janino:commons-compiler:2.7.6 - http://docs.codehaus.org/display/JANINO/Home/commons-compiler)
-        * Hamcrest Core (org.hamcrest:hamcrest-core:1.3 - https://github.com/hamcrest/JavaHamcrest/hamcrest-core)
         * Janino (org.codehaus.janino:janino:2.7.6 - http://docs.codehaus.org/display/JANINO/Home/janino)
         * JPMML evaluator (org.jpmml:pmml-evaluator:1.0.22 - http://www.jpmml.org/pmml-evaluator)
         * JPMML manager (org.jpmml:pmml-manager:1.0.22 - http://www.jpmml.org/pmml-manager)
@@ -602,10 +601,6 @@ List of third-party dependencies grouped by their license type.
         * Stax2 API (org.codehaus.woodstox:stax2-api:3.1.4 - http://wiki.fasterxml.com/WoodstoxStax2)
         * xmlenc Library (xmlenc:xmlenc:0.52 - http://xmlenc.sourceforge.net)
 
-    BSD style
-
-        * Hamcrest Core (org.hamcrest:hamcrest-core:1.1 - no url defined)
-
     CC0 1.0 Universal
 
         * JSR166e (com.twitter:jsr166e:1.1.0 - http://github.com/twitter/jsr166e)
@@ -660,7 +655,6 @@ List of third-party dependencies grouped by their license type.
         * Aether Utilities (org.eclipse.aether:aether-util:0.9.0.M2 - http://www.eclipse.org/aether/aether-util/)
         * clojure (org.clojure:clojure:1.10.0 - http://clojure.org/)
         * core.specs.alpha (org.clojure:core.specs.alpha:0.2.44 - https://github.com/clojure/build.poms/core.specs.alpha)
-        * JUnit (junit:junit:4.12 - http://junit.org)
         * org.eclipse.sisu.inject (org.eclipse.sisu:org.eclipse.sisu.inject:0.3.3 - http://www.eclipse.org/sisu/org.eclipse.sisu.inject/)
         * org.eclipse.sisu.plexus (org.eclipse.sisu:org.eclipse.sisu.plexus:0.3.3 - http://www.eclipse.org/sisu/org.eclipse.sisu.plexus/)
         * spec.alpha (org.clojure:spec.alpha:0.2.176 - https://github.com/clojure/build.poms/spec.alpha)
diff --git a/external/storm-hdfs-blobstore/pom.xml b/external/storm-hdfs-blobstore/pom.xml
index f61257daa..586d194b4 100644
--- a/external/storm-hdfs-blobstore/pom.xml
+++ b/external/storm-hdfs-blobstore/pom.xml
@@ -30,8 +30,6 @@
     <properties>
         <!-- Required downgrade by hadoop-hdfs 2.8.5 -->
         <guava.version>16.0.1</guava.version>
-        <!-- Required downgrade by hadoop-hdfs 2.8.5 (org.apache.hadoop.test.GenericTestUtils.getTestDir)-->
-        <junit.version>4.12</junit.version>
     </properties>
 
     <developers>
@@ -214,11 +212,6 @@
             <artifactId>guava</artifactId>
             <version>${guava.version}</version>
         </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>${junit.version}</version>
-        </dependency>
         <dependency>
             <groupId>org.junit.jupiter</groupId>
             <artifactId>junit-jupiter-params</artifactId>
diff --git a/external/storm-hdfs/pom.xml b/external/storm-hdfs/pom.xml
index 14f16d436..259ce073a 100644
--- a/external/storm-hdfs/pom.xml
+++ b/external/storm-hdfs/pom.xml
@@ -30,8 +30,6 @@
     <properties>
         <!-- Required downgrade by hadoop-hdfs 2.8.5 -->
         <guava.version>16.0.1</guava.version>
-        <!-- Required downgrade by hadoop-hdfs 2.8.5 (org.apache.hadoop.test.GenericTestUtils.getTestDir)-->
-        <junit.version>4.12</junit.version>
     </properties>
 
     <developers>
@@ -237,11 +235,6 @@
             <artifactId>storm-autocreds</artifactId>
             <version>${project.version}</version>
         </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>${junit.version}</version>
-        </dependency>
         <dependency>
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
diff --git a/external/storm-hdfs/src/test/java/org/apache/storm/hdfs/testing/MiniDFSClusterExtension.java b/external/storm-hdfs/src/test/java/org/apache/storm/hdfs/testing/MiniDFSClusterExtension.java
index f88fef583..93a0eab10 100644
--- a/external/storm-hdfs/src/test/java/org/apache/storm/hdfs/testing/MiniDFSClusterExtension.java
+++ b/external/storm-hdfs/src/test/java/org/apache/storm/hdfs/testing/MiniDFSClusterExtension.java
@@ -17,6 +17,7 @@
  */
 package org.apache.storm.hdfs.testing;
 
+import java.io.File;
 import java.util.function.Supplier;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
@@ -24,6 +25,10 @@ import org.junit.jupiter.api.extension.AfterEachCallback;
 import org.junit.jupiter.api.extension.BeforeEachCallback;
 import org.junit.jupiter.api.extension.ExtensionContext;
 
+import static org.apache.hadoop.test.GenericTestUtils.DEFAULT_TEST_DATA_DIR;
+import static org.apache.hadoop.test.GenericTestUtils.SYSPROP_TEST_DATA_DIR;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 public class MiniDFSClusterExtension implements BeforeEachCallback, AfterEachCallback {
 
     private static final String TEST_BUILD_DATA = "test.build.data";
@@ -52,6 +57,8 @@ public class MiniDFSClusterExtension implements BeforeEachCallback, AfterEachCal
     public void beforeEach(ExtensionContext arg0) throws Exception {
         System.setProperty(TEST_BUILD_DATA, "target/test/data");
         hadoopConf = hadoopConfSupplier.get();
+        String tempDir = getTestDir("dfs").getAbsolutePath() + File.separator;
+        hadoopConf.set("hdfs.minidfs.basedir", tempDir);
         dfscluster = new MiniDFSCluster.Builder(hadoopConf).numDataNodes(3).build();
         dfscluster.waitActive();
     }
@@ -61,4 +68,30 @@ public class MiniDFSClusterExtension implements BeforeEachCallback, AfterEachCal
         dfscluster.shutdown();
         System.clearProperty(TEST_BUILD_DATA);
     }
+
+    /**
+     * Get an uncreated directory for tests.
+     * We use this method to get rid of getTestDir() in GenericTestUtils in Hadoop code
+     * which uses assert from junit4.
+     * @return the absolute directory for tests. Caller is expected to create it.
+     */
+    public static File getTestDir(String subdir) {
+        return new File(getTestDir(), subdir).getAbsoluteFile();
+    }
+
+    /**
+     * Get the (created) base directory for tests.
+     * @return the absolute directory
+     */
+    public static File getTestDir() {
+        String prop = System.getProperty(SYSPROP_TEST_DATA_DIR, DEFAULT_TEST_DATA_DIR);
+        if (prop.isEmpty()) {
+            // corner case: property is there but empty
+            prop = DEFAULT_TEST_DATA_DIR;
+        }
+        File dir = new File(prop).getAbsoluteFile();
+        dir.mkdirs();
+        assertTrue(dir.exists(), "File " + dir + " should exist");
+        return dir;
+    }
 }
diff --git a/external/storm-hdfs/src/test/java/org/apache/storm/hdfs/testing/MiniDFSClusterExtensionClassLevel.java b/external/storm-hdfs/src/test/java/org/apache/storm/hdfs/testing/MiniDFSClusterExtensionClassLevel.java
index 820421dff..d13208a7c 100644
--- a/external/storm-hdfs/src/test/java/org/apache/storm/hdfs/testing/MiniDFSClusterExtensionClassLevel.java
+++ b/external/storm-hdfs/src/test/java/org/apache/storm/hdfs/testing/MiniDFSClusterExtensionClassLevel.java
@@ -17,6 +17,7 @@
  */
 package org.apache.storm.hdfs.testing;
 
+import java.io.File;
 import java.util.function.Supplier;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
@@ -24,6 +25,8 @@ import org.junit.jupiter.api.extension.AfterAllCallback;
 import org.junit.jupiter.api.extension.BeforeAllCallback;
 import org.junit.jupiter.api.extension.ExtensionContext;
 
+import static org.apache.storm.hdfs.testing.MiniDFSClusterExtension.getTestDir;
+
 public class MiniDFSClusterExtensionClassLevel implements BeforeAllCallback, AfterAllCallback {
 
     private static final String TEST_BUILD_DATA = "test.build.data";
@@ -52,6 +55,8 @@ public class MiniDFSClusterExtensionClassLevel implements BeforeAllCallback, Aft
     public void beforeAll(ExtensionContext arg0) throws Exception {
         System.setProperty(TEST_BUILD_DATA, "target/test/data");
         hadoopConf = hadoopConfSupplier.get();
+        String tempDir = getTestDir("dfs").getAbsolutePath() + File.separator;
+        hadoopConf.set("hdfs.minidfs.basedir", tempDir);
         dfscluster = new MiniDFSCluster.Builder(hadoopConf).numDataNodes(3).build();
         dfscluster.waitActive();
     }
diff --git a/storm-client/test/py/test_storm_cli.py b/storm-client/test/py/test_storm_cli.py
index 14b8bd781..104baa60f 100644
--- a/storm-client/test/py/test_storm_cli.py
+++ b/storm-client/test/py/test_storm_cli.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -17,7 +17,7 @@
 # limitations under the License.
 
 from unittest import TestCase, main as test_main
-import mock
+from unittest import mock
 import sys
 import os