You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by "Michael Blow (Code Review)" <do...@asterixdb.incubator.apache.org> on 2016/09/21 15:54:12 UTC

Change in asterixdb[master]: Add JUnit Rule Implementation To Trace Test Methods

Michael Blow has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/1194

Change subject: Add JUnit Rule Implementation To Trace Test Methods
......................................................................

Add JUnit Rule Implementation To Trace Test Methods

Change-Id: I8ecc73825881714d33c7937a1de4eda32d51a85c
---
M asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/AsterixTestHelper.java
A asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/RetainLogsRule.java
A asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java
M asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AbstractExecutionIT.java
M asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixExternalLibraryIT.java
M asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/DmlRecoveryIT.java
M asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/RecoveryIT.java
7 files changed, 124 insertions(+), 42 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/94/1194/1

diff --git a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/AsterixTestHelper.java b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/AsterixTestHelper.java
index adb0d7a..4953ac8 100644
--- a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/AsterixTestHelper.java
+++ b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/AsterixTestHelper.java
@@ -27,8 +27,6 @@
 import java.util.ArrayList;
 
 import org.apache.commons.io.FileUtils;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
 
 public class AsterixTestHelper {
 
@@ -100,36 +98,4 @@
         }
     }
 
-    public static class RetainLogsRule extends TestWatcher {
-        private final File baseDir;
-        private final File destDir;
-        private long startTime;
-
-        public RetainLogsRule(File baseDir, File destDir) {
-            this.baseDir = baseDir;
-            this.destDir = destDir;
-        }
-
-        public RetainLogsRule(String baseDir, String destDir) {
-            this(new File(baseDir), new File(destDir));
-        }
-
-        @Override
-        protected void starting(Description description) {
-            startTime = System.currentTimeMillis();
-        }
-
-        @Override
-        protected void failed(Throwable e, Description description) {
-            File reportDir = new File(destDir, description.getTestClass().getName() + "." + description.getMethodName());
-            reportDir.mkdirs();
-            try {
-                AsterixTestHelper.deepSelectiveCopy(baseDir, reportDir,
-                        pathname -> pathname.getName().endsWith("log") &&
-                                pathname.lastModified() > startTime);
-            } catch (Exception e1) {
-                e1.printStackTrace();
-            }
-        }
-    }
 }
diff --git a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/RetainLogsRule.java b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/RetainLogsRule.java
new file mode 100644
index 0000000..39bd5e7
--- /dev/null
+++ b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/RetainLogsRule.java
@@ -0,0 +1,57 @@
+/*
+ * 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.asterix.test.base;
+
+import java.io.File;
+
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+
+public class RetainLogsRule extends TestWatcher {
+    private final File baseDir;
+    private final File destDir;
+    private long startTime;
+
+    public RetainLogsRule(File baseDir, File destDir) {
+        this.baseDir = baseDir;
+        this.destDir = destDir;
+    }
+
+    public RetainLogsRule(String baseDir, String destDir) {
+        this(new File(baseDir), new File(destDir));
+    }
+
+    @Override
+    protected void starting(Description description) {
+        startTime = System.currentTimeMillis();
+    }
+
+    @Override
+    protected void failed(Throwable e, Description description) {
+        File reportDir = new File(destDir, description.getTestClass().getName() + "." + description.getMethodName());
+        reportDir.mkdirs();
+        try {
+            AsterixTestHelper.deepSelectiveCopy(baseDir, reportDir,
+                    pathname -> pathname.getName().endsWith("log") &&
+                            pathname.lastModified() > startTime);
+        } catch (Exception e1) {
+            e1.printStackTrace();
+        }
+    }
+}
diff --git a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java
new file mode 100644
index 0000000..99664a8
--- /dev/null
+++ b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java
@@ -0,0 +1,59 @@
+/*
+ * 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.asterix.test.base;
+
+import java.io.PrintStream;
+
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+
+/*
+ * Traces method entry/exit to System.out (or supplied PrintStream).  To use, add the following to your test class:
+ *
+ *   @Rule
+ *   public TestRule watcher = new TestMethodTracer();
+ */
+
+public class TestMethodTracer extends TestWatcher {
+
+    private final PrintStream out;
+
+    public TestMethodTracer(PrintStream out) {
+        this.out = out;
+    }
+
+    public TestMethodTracer() {
+        this(System.out);
+    }
+
+    @Override
+    protected void starting(Description description) {
+        out.println("+" + description.getMethodName());
+    }
+
+    @Override
+    protected void failed(Throwable e, Description description) {
+        out.println("-" + description.getMethodName() + ": FAILED");
+    }
+
+    @Override
+    protected void succeeded(Description description) {
+        out.println("-" + description.getMethodName() + ": SUCCEEDED");
+    }
+}
diff --git a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AbstractExecutionIT.java b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AbstractExecutionIT.java
index 676137c..d9c902e 100644
--- a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AbstractExecutionIT.java
+++ b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AbstractExecutionIT.java
@@ -24,7 +24,7 @@
 import org.apache.asterix.external.util.ExternalDataConstants;
 import org.apache.asterix.external.util.IdentitiyResolverFactory;
 import org.apache.asterix.test.aql.TestExecutor;
-import org.apache.asterix.test.base.AsterixTestHelper;
+import org.apache.asterix.test.base.RetainLogsRule;
 import org.apache.asterix.test.runtime.HDFSCluster;
 import org.apache.asterix.testframework.context.TestCaseContext;
 import org.apache.asterix.testframework.context.TestFileContext;
@@ -65,7 +65,7 @@
             new File(StringUtils.join(new String[] { "target", "failsafe-reports" }, File.separator)).getAbsolutePath();
 
     @Rule
-    public TestRule retainLogs = new AsterixTestHelper.RetainLogsRule(
+    public TestRule retainLogs = new RetainLogsRule(
             AsterixInstallerIntegrationUtil.getManagixHome(), reportPath);
 
     @BeforeClass
diff --git a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixExternalLibraryIT.java b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixExternalLibraryIT.java
index 57aaeee..ae98d19 100644
--- a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixExternalLibraryIT.java
+++ b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixExternalLibraryIT.java
@@ -24,7 +24,7 @@
 
 import org.apache.asterix.event.model.AsterixInstance.State;
 import org.apache.asterix.test.aql.TestExecutor;
-import org.apache.asterix.test.base.AsterixTestHelper;
+import org.apache.asterix.test.base.RetainLogsRule;
 import org.apache.asterix.testframework.context.TestCaseContext;
 import org.apache.commons.lang3.StringUtils;
 import org.junit.AfterClass;
@@ -49,7 +49,7 @@
     private final TestExecutor testExecutor = new TestExecutor();
 
     @Rule
-    public TestRule retainLogs = new AsterixTestHelper.RetainLogsRule(
+    public TestRule retainLogs = new RetainLogsRule(
             AsterixInstallerIntegrationUtil.getManagixHome(), reportPath);
 
     @BeforeClass
diff --git a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/DmlRecoveryIT.java b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/DmlRecoveryIT.java
index 68c009a..b55510a 100644
--- a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/DmlRecoveryIT.java
+++ b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/DmlRecoveryIT.java
@@ -26,7 +26,7 @@
 import java.util.logging.Logger;
 
 import org.apache.asterix.test.aql.TestExecutor;
-import org.apache.asterix.test.base.AsterixTestHelper;
+import org.apache.asterix.test.base.RetainLogsRule;
 import org.apache.asterix.testframework.context.TestCaseContext;
 import org.apache.commons.io.FileUtils;
 import org.junit.AfterClass;
@@ -60,7 +60,7 @@
     private final TestExecutor testExecutor = new TestExecutor();
 
     @Rule
-    public TestRule retainLogs = new AsterixTestHelper.RetainLogsRule(managixHomePath, reportPath);
+    public TestRule retainLogs = new RetainLogsRule(managixHomePath, reportPath);
 
     @BeforeClass
     public static void setUp() throws Exception {
diff --git a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/RecoveryIT.java b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/RecoveryIT.java
index 9795702..98c0853 100644
--- a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/RecoveryIT.java
+++ b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/RecoveryIT.java
@@ -26,7 +26,7 @@
 import java.util.logging.Logger;
 
 import org.apache.asterix.test.aql.TestExecutor;
-import org.apache.asterix.test.base.AsterixTestHelper;
+import org.apache.asterix.test.base.RetainLogsRule;
 import org.apache.asterix.test.runtime.HDFSCluster;
 import org.apache.asterix.testframework.context.TestCaseContext;
 import org.apache.commons.io.FileUtils;
@@ -58,7 +58,7 @@
     private final TestExecutor testExecutor = new TestExecutor();
 
     @Rule
-    public TestRule retainLogs = new AsterixTestHelper.RetainLogsRule(managixHomePath, reportPath);
+    public TestRule retainLogs = new RetainLogsRule(managixHomePath, reportPath);
 
     @BeforeClass
     public static void setUp() throws Exception {

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1194
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8ecc73825881714d33c7937a1de4eda32d51a85c
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>

Change in asterixdb[master]: Add JUnit Rule Implementation To Trace Test Methods

Posted by "Till Westmann (Code Review)" <do...@asterixdb.incubator.apache.org>.
Till Westmann has posted comments on this change.

Change subject: Add JUnit Rule Implementation To Trace Test Methods
......................................................................


Patch Set 1:

(1 comment)

https://asterix-gerrit.ics.uci.edu/#/c/1194/1/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java
File asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java:

Line 33: public class TestMethodTracer extends TestWatcher {
It seems that this is never used. Is that on purpose?


-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1194
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I8ecc73825881714d33c7937a1de4eda32d51a85c
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>
Gerrit-HasComments: Yes

Change in asterixdb[master]: Add JUnit Rule Implementation To Trace Test Methods

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: Add JUnit Rule Implementation To Trace Test Methods
......................................................................


Patch Set 1:

Integration Tests Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-integration-tests/696/

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1194
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I8ecc73825881714d33c7937a1de4eda32d51a85c
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-HasComments: No

Change in asterixdb[master]: Add JUnit Rule Implementation To Trace Test Methods

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: Add JUnit Rule Implementation To Trace Test Methods
......................................................................


Patch Set 1:

Build Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-notopic/2724/

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1194
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I8ecc73825881714d33c7937a1de4eda32d51a85c
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-HasComments: No

Change in asterixdb[master]: Add JUnit Rule Implementation To Trace Test Methods

Posted by "Till Westmann (Code Review)" <do...@asterixdb.incubator.apache.org>.
Till Westmann has posted comments on this change.

Change subject: Add JUnit Rule Implementation To Trace Test Methods
......................................................................


Patch Set 2: Code-Review+2

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1194
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I8ecc73825881714d33c7937a1de4eda32d51a85c
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>
Gerrit-HasComments: No

Change in asterixdb[master]: Add JUnit Rule Implementation To Trace Test Methods

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: Add JUnit Rule Implementation To Trace Test Methods
......................................................................


Patch Set 2:

Build Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-notopic/2729/

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1194
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I8ecc73825881714d33c7937a1de4eda32d51a85c
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>
Gerrit-HasComments: No

Change in asterixdb[master]: Add JUnit Rule Implementation To Trace Test Methods

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: Add JUnit Rule Implementation To Trace Test Methods
......................................................................


Patch Set 2:

Integration Tests Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-integration-tests/700/

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1194
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I8ecc73825881714d33c7937a1de4eda32d51a85c
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>
Gerrit-HasComments: No

Change in asterixdb[master]: Add JUnit Rule Implementation To Trace Test Methods

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: Add JUnit Rule Implementation To Trace Test Methods
......................................................................


Patch Set 2: Integration-Tests+1

Integration Tests Successful

https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-integration-tests/700/ : SUCCESS

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1194
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I8ecc73825881714d33c7937a1de4eda32d51a85c
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>
Gerrit-HasComments: No

Change in asterixdb[master]: Add JUnit Rule Implementation To Trace Test Methods

Posted by "Michael Blow (Code Review)" <do...@asterixdb.incubator.apache.org>.
Michael Blow has submitted this change and it was merged.

Change subject: Add JUnit Rule Implementation To Trace Test Methods
......................................................................


Add JUnit Rule Implementation To Trace Test Methods

Change-Id: I8ecc73825881714d33c7937a1de4eda32d51a85c
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1194
Sonar-Qube: Jenkins <je...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <ti...@apache.org>
---
M asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/AsterixTestHelper.java
A asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/RetainLogsRule.java
A asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java
M asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AbstractExecutionIT.java
M asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixExternalLibraryIT.java
M asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/DmlRecoveryIT.java
M asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/RecoveryIT.java
M asterixdb/asterix-server/src/test/java/org/apache/asterix/server/test/SampleLocalClusterIT.java
8 files changed, 134 insertions(+), 46 deletions(-)

Approvals:
  Till Westmann: Looks good to me, approved
  Jenkins: Verified; No violations found; Verified



diff --git a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/AsterixTestHelper.java b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/AsterixTestHelper.java
index adb0d7a..4953ac8 100644
--- a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/AsterixTestHelper.java
+++ b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/AsterixTestHelper.java
@@ -27,8 +27,6 @@
 import java.util.ArrayList;
 
 import org.apache.commons.io.FileUtils;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
 
 public class AsterixTestHelper {
 
@@ -100,36 +98,4 @@
         }
     }
 
-    public static class RetainLogsRule extends TestWatcher {
-        private final File baseDir;
-        private final File destDir;
-        private long startTime;
-
-        public RetainLogsRule(File baseDir, File destDir) {
-            this.baseDir = baseDir;
-            this.destDir = destDir;
-        }
-
-        public RetainLogsRule(String baseDir, String destDir) {
-            this(new File(baseDir), new File(destDir));
-        }
-
-        @Override
-        protected void starting(Description description) {
-            startTime = System.currentTimeMillis();
-        }
-
-        @Override
-        protected void failed(Throwable e, Description description) {
-            File reportDir = new File(destDir, description.getTestClass().getName() + "." + description.getMethodName());
-            reportDir.mkdirs();
-            try {
-                AsterixTestHelper.deepSelectiveCopy(baseDir, reportDir,
-                        pathname -> pathname.getName().endsWith("log") &&
-                                pathname.lastModified() > startTime);
-            } catch (Exception e1) {
-                e1.printStackTrace();
-            }
-        }
-    }
 }
diff --git a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/RetainLogsRule.java b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/RetainLogsRule.java
new file mode 100644
index 0000000..39bd5e7
--- /dev/null
+++ b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/RetainLogsRule.java
@@ -0,0 +1,57 @@
+/*
+ * 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.asterix.test.base;
+
+import java.io.File;
+
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+
+public class RetainLogsRule extends TestWatcher {
+    private final File baseDir;
+    private final File destDir;
+    private long startTime;
+
+    public RetainLogsRule(File baseDir, File destDir) {
+        this.baseDir = baseDir;
+        this.destDir = destDir;
+    }
+
+    public RetainLogsRule(String baseDir, String destDir) {
+        this(new File(baseDir), new File(destDir));
+    }
+
+    @Override
+    protected void starting(Description description) {
+        startTime = System.currentTimeMillis();
+    }
+
+    @Override
+    protected void failed(Throwable e, Description description) {
+        File reportDir = new File(destDir, description.getTestClass().getName() + "." + description.getMethodName());
+        reportDir.mkdirs();
+        try {
+            AsterixTestHelper.deepSelectiveCopy(baseDir, reportDir,
+                    pathname -> pathname.getName().endsWith("log") &&
+                            pathname.lastModified() > startTime);
+        } catch (Exception e1) {
+            e1.printStackTrace();
+        }
+    }
+}
diff --git a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java
new file mode 100644
index 0000000..692805f
--- /dev/null
+++ b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java
@@ -0,0 +1,62 @@
+/*
+ * 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.asterix.test.base;
+
+import java.io.PrintStream;
+
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+
+/*
+ * Traces method entry/exit to System.out (or supplied PrintStream).  To use, add the following to your test class:
+ *
+ *   @Rule
+ *   public TestRule watcher = new TestMethodTracer();
+ *
+ *   @Rule
+ *   public TestRule watcher = new TestMethodTracer(System.err);
+ */
+
+public class TestMethodTracer extends TestWatcher {
+
+    private final PrintStream out;
+
+    public TestMethodTracer(PrintStream out) {
+        this.out = out;
+    }
+
+    public TestMethodTracer() {
+        this(System.out);
+    }
+
+    @Override
+    protected void starting(Description description) {
+        out.println("## " + description.getMethodName() + " START");
+    }
+
+    @Override
+    protected void failed(Throwable e, Description description) {
+        out.println("## " + description.getMethodName() + " FAILED (" + e.getClass().getName() + ")");
+    }
+
+    @Override
+    protected void succeeded(Description description) {
+        out.println("## " + description.getMethodName() + " SUCCEEDED");
+    }
+}
diff --git a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AbstractExecutionIT.java b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AbstractExecutionIT.java
index 676137c..d9c902e 100644
--- a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AbstractExecutionIT.java
+++ b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AbstractExecutionIT.java
@@ -24,7 +24,7 @@
 import org.apache.asterix.external.util.ExternalDataConstants;
 import org.apache.asterix.external.util.IdentitiyResolverFactory;
 import org.apache.asterix.test.aql.TestExecutor;
-import org.apache.asterix.test.base.AsterixTestHelper;
+import org.apache.asterix.test.base.RetainLogsRule;
 import org.apache.asterix.test.runtime.HDFSCluster;
 import org.apache.asterix.testframework.context.TestCaseContext;
 import org.apache.asterix.testframework.context.TestFileContext;
@@ -65,7 +65,7 @@
             new File(StringUtils.join(new String[] { "target", "failsafe-reports" }, File.separator)).getAbsolutePath();
 
     @Rule
-    public TestRule retainLogs = new AsterixTestHelper.RetainLogsRule(
+    public TestRule retainLogs = new RetainLogsRule(
             AsterixInstallerIntegrationUtil.getManagixHome(), reportPath);
 
     @BeforeClass
diff --git a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixExternalLibraryIT.java b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixExternalLibraryIT.java
index 57aaeee..ae98d19 100644
--- a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixExternalLibraryIT.java
+++ b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixExternalLibraryIT.java
@@ -24,7 +24,7 @@
 
 import org.apache.asterix.event.model.AsterixInstance.State;
 import org.apache.asterix.test.aql.TestExecutor;
-import org.apache.asterix.test.base.AsterixTestHelper;
+import org.apache.asterix.test.base.RetainLogsRule;
 import org.apache.asterix.testframework.context.TestCaseContext;
 import org.apache.commons.lang3.StringUtils;
 import org.junit.AfterClass;
@@ -49,7 +49,7 @@
     private final TestExecutor testExecutor = new TestExecutor();
 
     @Rule
-    public TestRule retainLogs = new AsterixTestHelper.RetainLogsRule(
+    public TestRule retainLogs = new RetainLogsRule(
             AsterixInstallerIntegrationUtil.getManagixHome(), reportPath);
 
     @BeforeClass
diff --git a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/DmlRecoveryIT.java b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/DmlRecoveryIT.java
index 68c009a..b55510a 100644
--- a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/DmlRecoveryIT.java
+++ b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/DmlRecoveryIT.java
@@ -26,7 +26,7 @@
 import java.util.logging.Logger;
 
 import org.apache.asterix.test.aql.TestExecutor;
-import org.apache.asterix.test.base.AsterixTestHelper;
+import org.apache.asterix.test.base.RetainLogsRule;
 import org.apache.asterix.testframework.context.TestCaseContext;
 import org.apache.commons.io.FileUtils;
 import org.junit.AfterClass;
@@ -60,7 +60,7 @@
     private final TestExecutor testExecutor = new TestExecutor();
 
     @Rule
-    public TestRule retainLogs = new AsterixTestHelper.RetainLogsRule(managixHomePath, reportPath);
+    public TestRule retainLogs = new RetainLogsRule(managixHomePath, reportPath);
 
     @BeforeClass
     public static void setUp() throws Exception {
diff --git a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/RecoveryIT.java b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/RecoveryIT.java
index 9795702..98c0853 100644
--- a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/RecoveryIT.java
+++ b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/RecoveryIT.java
@@ -26,7 +26,7 @@
 import java.util.logging.Logger;
 
 import org.apache.asterix.test.aql.TestExecutor;
-import org.apache.asterix.test.base.AsterixTestHelper;
+import org.apache.asterix.test.base.RetainLogsRule;
 import org.apache.asterix.test.runtime.HDFSCluster;
 import org.apache.asterix.testframework.context.TestCaseContext;
 import org.apache.commons.io.FileUtils;
@@ -58,7 +58,7 @@
     private final TestExecutor testExecutor = new TestExecutor();
 
     @Rule
-    public TestRule retainLogs = new AsterixTestHelper.RetainLogsRule(managixHomePath, reportPath);
+    public TestRule retainLogs = new RetainLogsRule(managixHomePath, reportPath);
 
     @BeforeClass
     public static void setUp() throws Exception {
diff --git a/asterixdb/asterix-server/src/test/java/org/apache/asterix/server/test/SampleLocalClusterIT.java b/asterixdb/asterix-server/src/test/java/org/apache/asterix/server/test/SampleLocalClusterIT.java
index e98262a..a49086b 100644
--- a/asterixdb/asterix-server/src/test/java/org/apache/asterix/server/test/SampleLocalClusterIT.java
+++ b/asterixdb/asterix-server/src/test/java/org/apache/asterix/server/test/SampleLocalClusterIT.java
@@ -18,16 +18,18 @@
  */
 package org.apache.asterix.server.test;
 
+import static org.apache.asterix.test.common.TestHelper.joinPath;
+
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringWriter;
 import java.net.URL;
 import java.util.Collections;
-import java.util.logging.Logger;
 
 import org.apache.asterix.common.utils.ServletUtil.Servlets;
 import org.apache.asterix.test.aql.TestExecutor;
+import org.apache.asterix.test.base.TestMethodTracer;
 import org.apache.asterix.test.common.TestHelper;
 import org.apache.asterix.testframework.context.TestCaseContext.OutputFormat;
 import org.apache.commons.io.FileUtils;
@@ -35,10 +37,10 @@
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.FixMethodOrder;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TestRule;
 import org.junit.runners.MethodSorters;
-
-import static org.apache.asterix.test.common.TestHelper.joinPath;
 
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 public class SampleLocalClusterIT {
@@ -54,7 +56,8 @@
 
     private static final String LOCAL_SAMPLES_DIR = joinPath(OUTPUT_DIR, "samples", "local");
 
-    private static final Logger LOGGER = Logger.getLogger(SampleLocalClusterIT.class.getName());
+    @Rule
+    public TestRule watcher = new TestMethodTracer();
 
     @BeforeClass
     public static void setUp() throws Exception {

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1194
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I8ecc73825881714d33c7937a1de4eda32d51a85c
Gerrit-PatchSet: 3
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>

Change in asterixdb[master]: Add JUnit Rule Implementation To Trace Test Methods

Posted by "Michael Blow (Code Review)" <do...@asterixdb.incubator.apache.org>.
Hello Jenkins,

I'd like you to reexamine a change.  Please visit

    https://asterix-gerrit.ics.uci.edu/1194

to look at the new patch set (#2).

Change subject: Add JUnit Rule Implementation To Trace Test Methods
......................................................................

Add JUnit Rule Implementation To Trace Test Methods

Change-Id: I8ecc73825881714d33c7937a1de4eda32d51a85c
---
M asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/AsterixTestHelper.java
A asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/RetainLogsRule.java
A asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java
M asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AbstractExecutionIT.java
M asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixExternalLibraryIT.java
M asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/DmlRecoveryIT.java
M asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/transaction/RecoveryIT.java
M asterixdb/asterix-server/src/test/java/org/apache/asterix/server/test/SampleLocalClusterIT.java
8 files changed, 134 insertions(+), 46 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/94/1194/2
-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1194
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I8ecc73825881714d33c7937a1de4eda32d51a85c
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>