Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Migrates cluster tests from the legacy Arquillian suite to the JUnit 5 test framework, adding clustered-server utilities and remote server-side tasks.
Changes:
- Ports invalidation, failover, authentication-session, and certificate-rotation tests.
- Adds node descriptors, clustered testing clients, provider configuration, and remote tasks.
- Updates run-on-server class loading and dependencies.
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
testsuite/.../cluster/SessionFailoverClusterTest.java |
Removes legacy session failover test. |
testsuite/.../cluster/PermissionTicketInvalidationClusterTest.java |
Removes legacy permission-ticket test. |
testsuite/.../cluster/JGroupsCertificateRotationClusterTest.java |
Removes legacy certificate test. |
testsuite/.../cluster/AuthenticationSessionFailoverClusterTest.java |
Removes legacy authentication failover test. |
testsuite/.../cluster/AuthenticationSessionClusterTest.java |
Removes legacy route tests. |
testsuite/.../cluster/AbstractFailoverClusterTest.java |
Removes Arquillian failover base. |
testsuite/.../cluster/AbstractClusterTest.java |
Removes Arquillian cluster base. |
tests/base/.../oid4vc/OID4VCIssuerEndpointTest.java |
Updates OAuth code construction. |
tests/base/.../cluster/UserInvalidationClusterTest.java |
Migrates user invalidation tests. |
tests/base/.../cluster/UserFederationInvalidationClusterTest.java |
Migrates federation invalidation tests. |
tests/base/.../cluster/SessionFailoverClusterTest.java |
Adds JUnit 5 session failover test. |
tests/base/.../cluster/RoleInvalidationClusterTest.java |
Migrates role invalidation tests. |
tests/base/.../cluster/RealmInvalidationClusterTest.java |
Migrates realm invalidation tests. |
tests/base/.../cluster/PermissionTicketInvalidationClusterTest.java |
Adds migrated permission-ticket tests. |
tests/base/.../cluster/JGroupsCertificateRotationClusterTest.java |
Adds migrated certificate tests. |
tests/base/.../cluster/GroupInvalidationClusterTest.java |
Migrates group invalidation tests. |
tests/base/.../cluster/ContainerInfo.java |
Adds cluster-node descriptor. |
tests/base/.../cluster/ComponentInvalidationClusterTest.java |
Migrates component invalidation tests. |
tests/base/.../cluster/ClusterTestingClient.java |
Adds per-node remote-task client. |
tests/base/.../cluster/ClusterCustomProvidersServerConfig.java |
Configures custom test providers. |
tests/base/.../cluster/ClientScopeInvalidationClusterTest.java |
Migrates client-scope tests. |
tests/base/.../cluster/ClientInvalidationClusterTest.java |
Migrates client invalidation tests. |
tests/base/.../cluster/AuthenticationSessionFailoverClusterTest.java |
Adds authentication failover flow. |
tests/base/.../cluster/AuthenticationSessionClusterTest.java |
Adds route-cookie cluster test. |
tests/base/.../cluster/AbstractInvalidationClusterTestWithTestRealm.java |
Migrates generated-realm setup. |
tests/base/.../cluster/AbstractInvalidationClusterTest.java |
Migrates generic invalidation flow. |
tests/base/.../cluster/AbstractFailoverClusterTest.java |
Adds framework-based failover support. |
tests/base/.../cluster/AbstractClusterTest.java |
Adds new cluster test foundation. |
tests/base/pom.xml |
Adds clustering framework dependency. |
test-framework/remote/.../RunOnServerSupplier.java |
Refines injection compatibility. |
test-framework/remote-providers/.../TestClassLoader.java |
Adds system-class fallback. |
test-framework/remote-providers/.../ClusterTestTasks.java |
Adds serializable cluster operations. |
Suppressed comments (1)
tests/base/src/test/java/org/keycloak/tests/cluster/ComponentInvalidationClusterTest.java:193
- Reading the admin representation only verifies persisted configuration; it never resolves
TestComponentProvideron the survivor, so stale provider instances and missed component-cache invalidations now pass. Query the provider instance on each node (for example via a run-on-server task) and assert itsgetDetails()result.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| protected void killBackendNode(ContainerInfo node) { | ||
| unavailableNodes.add(node.getIndex()); | ||
| backendTestingClients.remove(node.getIndex()); |
ce78a1f to
53e2119
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The remote-provider module does not compile, migrated tests are not wired into cluster execution, and container restart handling can route to stale or unready nodes.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 38/38 changed files
- Comments generated: 4
- Review effort level: Balanced
| import org.keycloak.models.KeycloakSession; | ||
| import org.keycloak.models.utils.ModelToRepresentation; | ||
| import org.keycloak.models.RealmModel; | ||
| import org.keycloak.services.managers.AuthenticationSessionManager; |
| <dependency> | ||
| <groupId>org.keycloak.testframework</groupId> | ||
| <artifactId>keycloak-test-framework-clustering</artifactId> | ||
| </dependency> |
There was a problem hiding this comment.
🟡 Changes recommended
Build configuration, container restart behavior, and weakened failover assertions currently prevent reliable execution of the migrated tests.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (5)
Previously missed (2) — in code that hasn't changed since the last review.
quarkus/tests/junit5/src/main/java/org/keycloak/it/utils/DockerKeycloakDistribution.java:232
- This method is used by
killBackendNode, but it delegates to the existing orderlyTERMshutdown path; Infinispan can transfer single-owner entries before leaving, so the failover tests no longer simulate abrupt node loss and may observe sessions surviving unexpectedly. Provide a distinct abrupt-kill operation for failure tests and reserve graceful shutdown for cleanup.
tests/base/src/test/java/org/keycloak/tests/cluster/ClusterComponentTestTasks.java:32 - Constructing the provider directly from the freshly loaded
ComponentModelbypasses Keycloak's component-provider/factory lookup, so this assertion always sees current configuration even if provider invalidation is broken. Restore the original test semantics by resolving the component throughsession.getComponentProvider(...)using a provider whose instantiated state captures the component configuration.
test-framework/remote-providers/src/main/java/org/keycloak/testframework/remote/providers/runonserver/ClusterTestTasks.java:15
AuthenticationSessionManageris defined inkeycloak-services, buttest-framework/remote-providers/pom.xmldoes not depend on that artifact, so this new import makes the remote-providers module fail compilation. Addkeycloak-servicesas an appropriate provided dependency or move this task to a module that already has it.
import org.keycloak.services.managers.AuthenticationSessionManager;
quarkus/tests/junit5/src/main/java/org/keycloak/it/utils/DockerKeycloakDistribution.java:254
- The
removeContainerflag only guards the custom cleanup, while this method still callsGenericContainer.stop(), which removes the container. ConsequentlystopKeepContainer()recreates a container with potentially different mapped ports on restart whileLoadBalancerretains cached origins; either preserve/restart the same Docker container or refresh all cached node URLs.
private void stop(boolean removeContainer) {
tests/base/pom.xml:58
- Adding the clustering provider makes it available but does not select it: supplier selection requires
kc.test.server=cluster(astests/clustering/src/test/resources/keycloak-test.properties:1demonstrates). In the normaltests/baserun the default server is selected, so these tests reachLoadBalancerSupplierwith a non-cluster server and fail; add a dedicated cluster test execution/configuration and keep these tests out of the default server run.
<dependency>
<groupId>org.keycloak.testframework</groupId>
<artifactId>keycloak-test-framework-clustering</artifactId>
</dependency>
- Files reviewed: 37/37 changed files
- Comments generated: 2
- Review effort level: Balanced
There was a problem hiding this comment.
I think PR CI compilation failure is caused by this code changes in this PR.
There was a problem hiding this comment.
🟡 Changes recommended
Duplicate method signatures prevent compilation, while node restart, routing, and coordinator tests contain blocking failures.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 43/43 changed files
- Comments generated: 5
- Review effort level: Balanced
| String routeNumber; | ||
| int portSeparator = route.indexOf('-'); | ||
| if (portSeparator == -1) { | ||
| routeNumber = route.substring(route.length() - 1); |
|
I have built this PR and I get: [INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 53.494 s
[INFO] Finished at: 2026-09-11T17:16:08+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project keycloak-test-framework-core: Compilation failure
[ERROR] /home/mvavrik/sources/keycloak/test-framework/core/src/main/java/org/keycloak/testframework/server/ReadinessProbe.java:[33,24] method waitUntilReady(java.util.function.IntFunction<java.lang.String>,int,long) is already defined in class org.keycloak.testframework.server.ReadinessProbe
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :keycloak-test-framework-core |
|
Fixed the compilation failure: |
There was a problem hiding this comment.
🟡 Changes recommended
The added OID4VC session-code helper contains unresolved symbols and prevents compilation.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 43/43 changed files
- Comments generated: 1
- Review effort level: Balanced
baffea6 to
ec57d1b
Compare
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Fix compilation, restore failover test assertions, add real container stop/restart support, and verify component provider invalidation on nodes. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
The deprecation check forbids adding new files under testsuite/. Inline the cookie lookup in RequiredActionEmailVerificationTest instead. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Register the cluster package in ClusterTestSuite, update clustering CI to run the new test framework suite, and harden node stop/restart handling for failover scenarios. Closes keycloak#47809 Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Rename the single-node readiness probe to avoid a duplicate overload, configure predictable node names for route-based cluster tests, restart killed containers via Docker start, and assert cluster size only on survivors after coordinator failure. Closes keycloak#47809 Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
The method was added during cluster migration without imports and broke tests/base test compilation in CI. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
The cluster tests were moved to tests/base, so keeping cluster in the legacy base-suite file makes base-suite.sh fail before Maven runs. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Drop composites and cluster entries after migrating those packages to tests/base so base-suite.sh no longer fails before Maven runs. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Use graceful TERM shutdown when keeping containers for restart, restart via docker restart with a longer port wait timeout, and allow cluster rebalance time after failback. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Stopped containers were not reliably coming back with restartContainerCmd. Fully recreate the node with the original startup arguments and wait for cluster reunion before continuing failover tests. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Pass session.cache.owners and related properties to Keycloak containers so session failover tests use the same replication settings as CI expects. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Use the realm app callback URI when verifying session cookies after failover, and move ClusterComponentTestTasks to custom-providers so run-on-server can deserialize it inside cluster containers. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Create test component providers via factory.create() like ComponentsTest, and expose component details through ClusterTestingClient. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Fix ComponentFactory cast and JSON deserialization for component test tasks, use SIGKILL for simulated node failures, capture container IDs in cleanup to avoid restart races, restore load balancer node selection, and restore CI surefire retries for cluster tests. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
The migrated cluster test suite needs more time than the previous 35-minute limit; all tests were passing before the job was cancelled. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Clean up per-method test realms, verify session failover via SSO, resolve component providers through the session, and fix multi-node failback membership waits. Restore Surefire retries in the stability clustering workflow. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Remove the invalid docker base-suite entry, rebind the load balancer after node refresh, probe /realms/master for node readiness, use SPI node-name options for mixed-version clusters, disable persistent sessions for owner failover tests, and assert remaining cluster size after coordinator loss. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Volatile session caches with owners=1 are raised to 2 when there is no shared store, so the migrated test should not expect logout after node failure. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
The SPI cluster-name option is not accepted by current validation when the stateless feature is enabled; set the first-class option instead. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
bfe230c to
512b9c1
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Cluster tests break unfiltered base runs on the incompatible default server, and the rotation assertion can race asynchronous task scheduling.
13 open issues
Restrict cluster tests to clustered server runs · New When more than one node is down, restarting the first node waits for the full configured cluster…FetchOnServer.run(...)is typically a no-checked-exception functional contract; declaring `throws…FetchOnServer.run(...)is typically a no-checked-exception functional contract; declaring `throws… This module does not depend onkeycloak-services, whereAuthenticationSessionManageris… Wait for rotation scheduling after the asynchronous certificate reload · New Account for persistent sessions in failover outcome Constructing the component provider directly from the freshly readComponentModelbypasses… This no longer verifies successful session failover:/realms/{realm}/app/authis not the new…failure()now stops the node through a gracefulTERMshutdown, so Infinispan can transfer state… The new clustered server never assignsnode1/node2node names, so Keycloak falls back to the… Adding the clustering artifact does not select itsclusterserver supplier or schedule these…killBackendNodeonly records the index and repoints the proxy; the container remains running and…
Review effort: Balanced
| @InjectLoadBalancer | ||
| protected LoadBalancer loadBalancer; |
| int survivorIdx = (coordinatorIdx + 1) % getClusterSize(); | ||
| assertClusterSize(getClusterSize() - 1, survivorIdx); | ||
| assertTrue(isCoordinator(survivorIdx)); | ||
| assertTrue(hasRotationTask(survivorIdx)); |
getComponentProvider can return null for custom component SPIs during cluster invalidation; create via the factory like ComponentsTest does. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
There was a problem hiding this comment.
🟡 Changes recommended
A raw factory causes a compilation error, and missing cluster-only gating makes the migrated tests fail resource injection in default test runs.
14 open issues
Cast or parameterize the test component provider factory · New Restrict cluster tests to clustered server runs When more than one node is down, restarting the first node waits for the full configured cluster…FetchOnServer.run(...)is typically a no-checked-exception functional contract; declaring `throws…FetchOnServer.run(...)is typically a no-checked-exception functional contract; declaring `throws… This module does not depend onkeycloak-services, whereAuthenticationSessionManageris… Wait for rotation scheduling after the asynchronous certificate reload Account for persistent sessions in failover outcome Constructing the component provider directly from the freshly readComponentModelbypasses… This no longer verifies successful session failover:/realms/{realm}/app/authis not the new…failur 10BC8 e()now stops the node through a gracefulTERMshutdown, so Infinispan can transfer state… The new clustered server never assignsnode1/node2node names, so Keycloak falls back to the… Adding the clustering artifact does not select itsclusterserver supplier or schedule these…killBackendNodeonly records the index and repoints the proxy; the container remains running and…
Review effort: Balanced
| + "' for '" + componentModel.getName() + "' (id=" + componentModel.getId() | ||
| + ") could not be resolved"); | ||
| } | ||
| return ((TestComponentProviderFactory) factory).create(session, componentModel); |


Related issue
Closes #47809