diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d41014c9cb5..f61009f6ea4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,8 @@ env: MAVEN_ARGS: "-B -nsu -Daether.connector.http.connectionMaxTtl=25" SUREFIRE_RERUN_FAILING_COUNT: 2 SUREFIRE_RETRY: "-Dsurefire.rerunFailingTestsCount=2" - KC_TEST_GITHUB_SLOW: "10" + KC_TEST_GITHUB_SLOW_METHOD: "10" + KC_TEST_GITHUB_SLOW_CLASS: "60" concurrency: # Only cancel jobs for PR updates diff --git a/test-framework/core/src/main/java/org/keycloak/testframework/LogHandler.java b/test-framework/core/src/main/java/org/keycloak/testframework/LogHandler.java index 2c96f396238..4b022a63e2b 100644 --- a/test-framework/core/src/main/java/org/keycloak/testframework/LogHandler.java +++ b/test-framework/core/src/main/java/org/keycloak/testframework/LogHandler.java @@ -44,6 +44,7 @@ public class LogHandler implements AutoCloseable { public void beforeAll(ExtensionContext context) { logDivider(Logger.Level.INFO); logTestClassStatus(context, Status.RUNNING, Logger.Level.INFO); + gitHubActionReport.onClassStart(); } public void beforeEachStarting(ExtensionContext context) { @@ -60,6 +61,8 @@ public class LogHandler implements AutoCloseable { Status status = context.getExecutionException().isPresent() ? Status.FAILED : Status.SUCCESS; if (status == Status.FAILED) { gitHubActionReport.onClassError(context); + } else { + gitHubActionReport.onClassSuccess(context); } logTestClassStatus(context, status, Logger.Level.DEBUG); } diff --git a/test-framework/core/src/main/java/org/keycloak/testframework/github/GitHubActionReport.java b/test-framework/core/src/main/java/org/keycloak/testframework/github/GitHubActionReport.java index 150cbaea6d4..39be8233e41 100644 --- a/test-framework/core/src/main/java/org/keycloak/testframework/github/GitHubActionReport.java +++ b/test-framework/core/src/main/java/org/keycloak/testframework/github/GitHubActionReport.java @@ -26,8 +26,10 @@ public class GitHubActionReport { private final File gitHubStepSummary; private final String gitRoot = findGitRoot(); + private final long slowTestClassTimeout; private final long slowTestTimeout; + private long testClassStartedAt; private long testStartedAt; private List failures = new LinkedList<>(); @@ -36,7 +38,28 @@ public class GitHubActionReport { public GitHubActionReport() { this.gitHubStepSummary = GITHUB_STEP_SUMMARY != null ? new File(GITHUB_STEP_SUMMARY) : null; this.enabled = Config.get("kc.test.github.enabled", true, Boolean.class) && gitHubStepSummary != null; - this.slowTestTimeout = TimeUnit.SECONDS.toMillis(Config.get("kc.test.github.slow", 30L, Long.class)); + this.slowTestClassTimeout = TimeUnit.SECONDS.toMillis(Config.get("kc.test.github.slow.class", 120L, Long.class)); + this.slowTestTimeout = TimeUnit.SECONDS.toMillis(Config.get("kc.test.github.slow.method", 30L, Long.class)); + } + + public void onClassStart() { + if (enabled) { + testClassStartedAt = System.currentTimeMillis(); + } + } + + public void onClassSuccess(ExtensionContext context) { + if (enabled) { + if (slowTestClassTimeout >= -1) { + long executionTime = System.currentTimeMillis() - testClassStartedAt; + if (executionTime > slowTestClassTimeout) { + Class testClass = context.getRequiredTestClass(); + String file = findJavaClass(testClass); + String link = getLink(file, -1); + slowTests.add(new Slow(context.getRequiredTestClass().getName(), "", executionTime, link)); + } + } + } } public void onClassError(ExtensionContext context) {