You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2019/01/18 16:12:54 UTC

[GitHub] dspavlov commented on a change in pull request #5662: IGNITE-8227 Research possibility and implement JUnit test failure handler for TeamCity

dspavlov commented on a change in pull request #5662: IGNITE-8227 Research possibility and implement JUnit test failure handler for TeamCity
URL: https://github.com/apache/ignite/pull/5662#discussion_r249099127
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/failure/TestFailingFailureHandler.java
 ##########
 @@ -0,0 +1,64 @@
+/*
+ * 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.ignite.failure;
+
+import junit.framework.TestCase;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.testframework.junits.GridAbstractTest;
+
+import static org.apache.ignite.testframework.junits.GridAbstractTest.testIsRunning;
+
+/**
+ * Stops node and fails test.
+ */
+public class TestFailingFailureHandler extends StopNodeFailureHandler {
+    /** Test. */
+    @GridToStringExclude
+    protected final GridAbstractTest test;
+
+    /**
+     * @param test Test.
+     */
+    public TestFailingFailureHandler(GridAbstractTest test) {
+        this.test = test;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean handle(Ignite ignite, FailureContext failureCtx) {
+        if (!testIsRunning.getAndSet(false)) {
+            ignite.log().info("Critical issue detected after test finished. Test failure handler ignore it.");
+
+            return true;
+        }
+
+        boolean nodeStopped = super.handle(ignite, failureCtx);
+
+        TestCase.fail(failureCtx.toString());
 
 Review comment:
   why this line is needed here? This will result in Assertion failed error and no handling will be performed later.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services