Allow ignoring patterns in LogChecker
This commit is contained in:
parent
d722e53108
commit
cd2f6e83b3
1 changed files with 23 additions and 12 deletions
|
@ -1,9 +1,10 @@
|
||||||
package org.keycloak.testsuite.util;
|
package org.keycloak.testsuite.util;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.jboss.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -14,20 +15,30 @@ public class LogChecker {
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger(LogChecker.class);
|
private static final Logger log = Logger.getLogger(LogChecker.class);
|
||||||
|
|
||||||
|
private static final String[] IGNORED = new String[] { ".*Jetty ALPN support not found.*" };
|
||||||
|
|
||||||
public static void checkServerLog(File logFile) throws IOException {
|
public static void checkServerLog(File logFile) throws IOException {
|
||||||
log.info(String.format("Checking server log: '%s'", logFile.getAbsolutePath()));
|
log.info(String.format("Checking server log: '%s'", logFile.getAbsolutePath()));
|
||||||
String logContent = FileUtils.readFileToString(logFile);
|
String[] logContent = FileUtils.readFileToString(logFile).split("\n");
|
||||||
|
|
||||||
boolean containsError
|
for (String log : logContent) {
|
||||||
= logContent.contains("ERROR")
|
boolean containsError = log.contains("ERROR") || log.contains("SEVERE") || log.contains("Exception ");
|
||||||
|| logContent.contains("SEVERE")
|
//There is expected string "Exception" in server log: Adding provider
|
||||||
|| logContent.contains("Exception ");
|
//singleton org.keycloak.services.resources.ModelExceptionMapper
|
||||||
|
if (containsError) {
|
||||||
//There is expected string "Exception" in server log: Adding provider
|
boolean ignore = false;
|
||||||
//singleton org.keycloak.services.resources.ModelExceptionMapper
|
for (String i : IGNORED) {
|
||||||
if (containsError) {
|
if (log.matches(i)) {
|
||||||
throw new RuntimeException(String.format("Server log file contains ERROR: '%s'", logFile.getPath()));
|
ignore = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!ignore) {
|
||||||
|
throw new RuntimeException(String.format("Server log file contains ERROR: '%s'", log));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkJBossServerLog(String jbossHome) throws IOException {
|
public static void checkJBossServerLog(String jbossHome) throws IOException {
|
||||||
|
|
Loading…
Reference in a new issue