You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "rpuch (via GitHub)" <gi...@apache.org> on 2023/01/26 11:06:07 UTC

[GitHub] [ignite-3] rpuch opened a new pull request, #1585: IGNITE-18638 Make tests print thread dump when timing out

rpuch opened a new pull request, #1585:
URL: https://github.com/apache/ignite-3/pull/1585

   https://issues.apache.org/jira/browse/IGNITE-18638


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] rpuch commented on a diff in pull request #1585: IGNITE-18638 Make tests print thread dump when timing out

Posted by "rpuch (via GitHub)" <gi...@apache.org>.
rpuch commented on code in PR #1585:
URL: https://github.com/apache/ignite-3/pull/1585#discussion_r1087927550


##########
modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/junit/DumpThreadsOnTimeout.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.internal.testframework.junit;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.ThreadInfo;
+import java.lang.management.ThreadMXBean;
+import java.util.concurrent.TimeoutException;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.LifecycleMethodExecutionExceptionHandler;
+import org.junit.jupiter.api.extension.TestExecutionExceptionHandler;
+
+/**
+ * This extension prints a thread dump (to the standard out) if a testable method (for instance, a method annotated with
+ * {@link org.junit.jupiter.api.Test} or a lifecycle method (like {@link org.junit.jupiter.api.BeforeEach} method) times out.
+ *
+ * <p>This extension is designed to be
+ * <a href="https://junit.org/junit5/docs/current/user-guide/#extensions-registration-automatic">automatically registered</a>
+ * via META-INF/services/org.junit.jupiter.api.extension.Extension.
+ * For this to work, system property {@code junit.jupiter.extensions.autodetection.enabled} must be set to {@code true}.
+ * If the property is set (currently, this is done via Gradle build scripts), it is enough to add this module as a dependency
+ * to make tests automatically register this extension, like this:
+ *
+ * <pre>
+ * integrationTestImplementation(testFixtures(project(':ignite-core')))
+ * </pre>
+ */
+public class DumpThreadsOnTimeout implements TestExecutionExceptionHandler, LifecycleMethodExecutionExceptionHandler {
+    @Override
+    public void handleTestExecutionException(ExtensionContext context, Throwable throwable) throws Throwable {
+        handleThrowable(throwable, "Test method");
+    }
+
+    private static void handleThrowable(Throwable throwable, String category) throws Throwable {
+        if (isJunitMethodTimeout(throwable)) {
+            System.out.println(category + " " + throwable.getMessage() + ", dumping threads");

Review Comment:
   https://ci.ignite.apache.org/buildConfiguration/ApacheIgnite3xGradle_Test_RunAllTests/7032302?hideProblemsFromDependencies=false&hideTestsFromDependencies=false&expandBuildChangesSection=true&expandBuildTestsSection=true&expandBuildProblemsSection=true&expandCode+Inspection=true&pluginCoverage=true
   
   It's just after the failure stack trace:
   
   `Test method testIntLocking() timed out after 60 seconds, dumping threads`
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] sashapolo commented on a diff in pull request #1585: IGNITE-18638 Make tests print thread dump when timing out

Posted by "sashapolo (via GitHub)" <gi...@apache.org>.
sashapolo commented on code in PR #1585:
URL: https://github.com/apache/ignite-3/pull/1585#discussion_r1087915817


##########
modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/junit/DumpThreadsOnTimeout.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.internal.testframework.junit;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.ThreadInfo;
+import java.lang.management.ThreadMXBean;
+import java.util.concurrent.TimeoutException;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.LifecycleMethodExecutionExceptionHandler;
+import org.junit.jupiter.api.extension.TestExecutionExceptionHandler;
+
+/**
+ * This extension prints a thread dump (to the standard out) if a testable method (for instance, a method annotated with
+ * {@link org.junit.jupiter.api.Test} or a lifecycle method (like {@link org.junit.jupiter.api.BeforeEach} method) times out.
+ *
+ * <p>This extension is designed to be
+ * <a href="https://junit.org/junit5/docs/current/user-guide/#extensions-registration-automatic">automatically registered</a>
+ * via META-INF/services/org.junit.jupiter.api.extension.Extension.
+ * For this to work, system property {@code junit.jupiter.extensions.autodetection.enabled} must be set to {@code true}.
+ * If the property is set (currently, this is done via Gradle build scripts), it is enough to add this module as a dependency
+ * to make tests automatically register this extension, like this:
+ *
+ * <pre>
+ * integrationTestImplementation(testFixtures(project(':ignite-core')))
+ * </pre>
+ */
+public class DumpThreadsOnTimeout implements TestExecutionExceptionHandler, LifecycleMethodExecutionExceptionHandler {
+    @Override
+    public void handleTestExecutionException(ExtensionContext context, Throwable throwable) throws Throwable {
+        handleThrowable(throwable, "Test method");
+    }
+
+    private static void handleThrowable(Throwable throwable, String category) throws Throwable {
+        if (isJunitMethodTimeout(throwable)) {
+            System.out.println(category + " " + throwable.getMessage() + ", dumping threads");

Review Comment:
   Can you provide an example how this message will look like?



##########
modules/core/src/testFixtures/resources/META-INF/services/org.junit.jupiter.api.extension.Extension:
##########
@@ -0,0 +1 @@
+org.apache.ignite.internal.testframework.junit.DumpThreadsOnTimeout

Review Comment:
   Can we use auto-service instead?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] ibessonov merged pull request #1585: IGNITE-18638 Make tests print thread dump when timing out

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov merged PR #1585:
URL: https://github.com/apache/ignite-3/pull/1585


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] rpuch commented on a diff in pull request #1585: IGNITE-18638 Make tests print thread dump when timing out

Posted by "rpuch (via GitHub)" <gi...@apache.org>.
rpuch commented on code in PR #1585:
URL: https://github.com/apache/ignite-3/pull/1585#discussion_r1087943087


##########
modules/core/src/testFixtures/resources/META-INF/services/org.junit.jupiter.api.extension.Extension:
##########
@@ -0,0 +1 @@
+org.apache.ignite.internal.testframework.junit.DumpThreadsOnTimeout

Review Comment:
   Yes we can! Switched to auto-service.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org