falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pisayc...@apache.org
Subject falcon git commit: FALCON-1819 Improve test class entity cleanup logic
Date Fri, 12 Feb 2016 10:01:52 GMT
Repository: falcon
Updated Branches:
  refs/heads/master d7c1a1e72 -> 6a29ae114


FALCON-1819 Improve test class entity cleanup logic

Improve entity clean up logic to handle entities belonging to different users.

Author: Paul Isaychuk <pisaychuk@apache.org>

Reviewers: Pragya Mittal <mittal.pragya23@gmail.com>

Closes #30 from pisaychuk/master


Project: http://git-wip-us.apache.org/repos/asf/falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/falcon/commit/6a29ae11
Tree: http://git-wip-us.apache.org/repos/asf/falcon/tree/6a29ae11
Diff: http://git-wip-us.apache.org/repos/asf/falcon/diff/6a29ae11

Branch: refs/heads/master
Commit: 6a29ae1147cd75b75115d8886469c7eac8ae7429
Parents: d7c1a1e
Author: Paul Isaychuk <pisaychuk@apache.org>
Authored: Fri Feb 12 12:01:33 2016 +0200
Committer: Paul Isaychuk <pisaychuk@apache.org>
Committed: Fri Feb 12 12:01:33 2016 +0200

----------------------------------------------------------------------
 falcon-regression/CHANGES.txt                   |  2 ++
 .../regression/core/util/CleanupUtil.java       | 20 +++++++-------
 .../regression/testHelper/BaseTestClass.java    | 28 +++++++++++++++-----
 3 files changed, 32 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/falcon/blob/6a29ae11/falcon-regression/CHANGES.txt
----------------------------------------------------------------------
diff --git a/falcon-regression/CHANGES.txt b/falcon-regression/CHANGES.txt
index b3769f0..d22d662 100644
--- a/falcon-regression/CHANGES.txt
+++ b/falcon-regression/CHANGES.txt
@@ -121,6 +121,8 @@ Trunk (Unreleased)
    via Samarth Gupta)
 
   IMPROVEMENTS
+   FALCON-1819 Improve test class entity cleanup logic (Paul Isaychuk)
+
    FALCON-1697 Stabilization of scenarios which are based on instances lifecycle(Paul Isaychuk
via Ajay Yadava)
 
    FALCON-1543 Upgrade Falcon regression to use Active MQ 5.12(Pragya Mittal via Pallavi
Rao)

http://git-wip-us.apache.org/repos/asf/falcon/blob/6a29ae11/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/CleanupUtil.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/CleanupUtil.java
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/CleanupUtil.java
index a7695fb..225bc5b 100644
--- a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/CleanupUtil.java
+++ b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/CleanupUtil.java
@@ -80,28 +80,26 @@ public final class CleanupUtil {
             new StringReader(clusterResponse.getMessage()));
     }
 
-
-
-    public static void cleanEntitiesWithPrefix(ColoHelper prism, String namePrefix) {
-        final List<String> processes = getEntitiesWithPrefix(prism.getProcessHelper(),
null, namePrefix);
-        final List<String> feeds = getEntitiesWithPrefix(prism.getFeedHelper(), null,
namePrefix);
-        final List<String> clusters = getEntitiesWithPrefix(prism.getClusterHelper(),
null, namePrefix);
+    public static void cleanEntitiesWithPrefix(ColoHelper prism, String namePrefix, String
user) {
+        final List<String> processes = getEntitiesWithPrefix(prism.getProcessHelper(),
user, namePrefix);
+        final List<String> feeds = getEntitiesWithPrefix(prism.getFeedHelper(), user,
namePrefix);
+        final List<String> clusters = getEntitiesWithPrefix(prism.getClusterHelper(),
user, namePrefix);
 
         for (String process : processes) {
-            deleteQuietlyByName(prism.getProcessHelper(), process);
+            deleteQuietlyByName(prism.getProcessHelper(), process, user);
         }
         for (String feed : feeds) {
-            deleteQuietlyByName(prism.getFeedHelper(), feed);
+            deleteQuietlyByName(prism.getFeedHelper(), feed, user);
         }
 
         for (String cluster : clusters) {
-            deleteQuietlyByName(prism.getClusterHelper(), cluster);
+            deleteQuietlyByName(prism.getClusterHelper(), cluster, user);
         }
     }
 
-    private static void deleteQuietlyByName(AbstractEntityHelper helper, String entityName)
{
+    private static void deleteQuietlyByName(AbstractEntityHelper helper, String entityName,
String user) {
         try {
-            helper.deleteByName(entityName, null);
+            helper.deleteByName(entityName, user);
         } catch (Exception e) {
             LOGGER.info("Caught exception: " + ExceptionUtils.getStackTrace(e));
         }

http://git-wip-us.apache.org/repos/asf/falcon/blob/6a29ae11/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/testHelper/BaseTestClass.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/testHelper/BaseTestClass.java
b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/testHelper/BaseTestClass.java
index 00ef79d..f32da2d 100644
--- a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/testHelper/BaseTestClass.java
+++ b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/testHelper/BaseTestClass.java
@@ -108,16 +108,30 @@ public class BaseTestClass {
         }
     }
 
+    /**
+     * Method removes test class entities which belong to default test user.
+     */
     public final void removeTestClassEntities() {
-        for (Bundle bundle : this.bundles) {
-            if (bundle != null) {
-                bundle.deleteBundle(prism);
+        removeTestClassEntities(new String[]{null});
+    }
+
+    /**
+     * This method removes all entities which name starts with prefix derived from test class
name. As entities can
+     * belong to different users, that users need to be listed as parameters. Note that null
is a default test user.
+     * @param users users whose entities should be removed.
+     */
+    public final void removeTestClassEntities(String...users) {
+        for (String user : users) {
+            for (Bundle bundle : this.bundles) {
+                if (bundle != null) {
+                    bundle.deleteBundle(prism);
+                }
             }
+            String className = this.getClass().getSimpleName();
+            CleanupUtil.cleanEntitiesWithPrefix(prism, className, user);
+            String deprecatedPrefix = 'A' + Integer.toHexString(className.hashCode());
+            CleanupUtil.cleanEntitiesWithPrefix(prism, deprecatedPrefix, user);
         }
-        String className = this.getClass().getSimpleName();
-        CleanupUtil.cleanEntitiesWithPrefix(prism, className);
-        String deprecatedPrefix = 'A' + Integer.toHexString(className.hashCode());
-        CleanupUtil.cleanEntitiesWithPrefix(prism, deprecatedPrefix);
     }
 
 


Mime
View raw message