diff --git a/testsuite/integration-arquillian/test-apps/servlets/src/main/java/org/keycloak/testsuite/adapter/servlet/SessionServlet.java b/testsuite/integration-arquillian/test-apps/servlets/src/main/java/org/keycloak/testsuite/adapter/servlet/SessionServlet.java
index 7fa5d49268..f9d2f1a038 100644
--- a/testsuite/integration-arquillian/test-apps/servlets/src/main/java/org/keycloak/testsuite/adapter/servlet/SessionServlet.java
+++ b/testsuite/integration-arquillian/test-apps/servlets/src/main/java/org/keycloak/testsuite/adapter/servlet/SessionServlet.java
@@ -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("
%s", "Session Test");
pw.printf("Counter=%s", counter);
+ pw.printf("Node name=%s", System.getProperty("jboss.node.name", "property not specified"));
pw.print("");
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");
diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/cluster/OIDCAdapterClusterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/cluster/OIDCAdapterClusterTest.java
index 1a4e66a934..340a3cc38f 100644
--- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/cluster/OIDCAdapterClusterTest.java
+++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/cluster/OIDCAdapterClusterTest.java
@@ -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 Pedro Igor
@@ -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));
}
}