KEYCLOAK-9869 Fix stability of cluster tests on EAP6
This commit is contained in:
parent
ad1a72ef8b
commit
0d0eec8790
2 changed files with 33 additions and 1 deletions
|
@ -38,18 +38,30 @@ public class SessionServlet extends HttpServlet {
|
|||
req.logout();
|
||||
return;
|
||||
}
|
||||
String counter = increaseAndGetCounter(req);
|
||||
|
||||
String counter;
|
||||
if (req.getRequestURI().endsWith("/donotincrease")) {
|
||||
counter = getCounter(req);
|
||||
} else {
|
||||
counter = increaseAndGetCounter(req);
|
||||
}
|
||||
|
||||
resp.setContentType("text/html");
|
||||
PrintWriter pw = resp.getWriter();
|
||||
pw.printf("<html><head><title>%s</title></head><body>", "Session Test");
|
||||
pw.printf("Counter=%s", counter);
|
||||
pw.printf("Node name=%s", System.getProperty("jboss.node.name", "property not specified"));
|
||||
pw.print("</body></html>");
|
||||
pw.flush();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private String getCounter(HttpServletRequest req) {
|
||||
HttpSession session = req.getSession();
|
||||
return String.valueOf(session.getAttribute("counter"));
|
||||
}
|
||||
|
||||
private String increaseAndGetCounter(HttpServletRequest req) {
|
||||
HttpSession session = req.getSession();
|
||||
Integer counter = (Integer)session.getAttribute("counter");
|
||||
|
|
|
@ -21,6 +21,7 @@ import static org.hamcrest.CoreMatchers.containsString;
|
|||
import static org.junit.Assert.assertThat;
|
||||
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlEquals;
|
||||
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith;
|
||||
import static org.keycloak.testsuite.util.WaitUtils.waitForPageToLoad;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
|
@ -44,6 +45,8 @@ import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
|
|||
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
|
||||
import org.keycloak.testsuite.auth.page.AuthRealm;
|
||||
import org.keycloak.testsuite.auth.page.login.OIDCLogin;
|
||||
import org.keycloak.testsuite.util.DroneUtils;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>
|
||||
|
@ -136,9 +139,26 @@ public class OIDCAdapterClusterTest extends AbstractAdapterClusteredTest {
|
|||
assertCurrentUrlStartsWith(loginPage);
|
||||
}
|
||||
|
||||
private void waitForCacheReplication(String appUrl, int expectedCount) {
|
||||
new WebDriverWait(DroneUtils.getCurrentDriver(), 5) // Check every 500ms of 5 seconds
|
||||
.until((driver) -> {
|
||||
driver.navigate().to(appUrl + "/donotincrease");
|
||||
waitForPageToLoad();
|
||||
|
||||
return driver.getPageSource().contains("Counter=" + expectedCount);
|
||||
});
|
||||
}
|
||||
|
||||
private void assertSessionCounter(String hostToPointToName, URI hostToPointToUri, URI hostToRemove, String appUrl, int expectedCount) {
|
||||
updateProxy(hostToPointToName, hostToPointToUri, hostToRemove);
|
||||
|
||||
// Wait for cache replication, this is necessary due to https://access.redhat.com/solutions/20861
|
||||
waitForCacheReplication(appUrl, expectedCount - 1); // Not increased yet therefore -1
|
||||
|
||||
driver.navigate().to(appUrl);
|
||||
waitForPageToLoad();
|
||||
|
||||
assertThat(driver.getPageSource(), containsString("Counter=" + expectedCount));
|
||||
assertThat(driver.getPageSource(), containsString("Node name=" + hostToPointToName));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue