Search in sources :

Example 6 with ContainerInfo

use of org.keycloak.testsuite.arquillian.ContainerInfo in project keycloak by keycloak.

the class AbstractAdapterClusteredTest method startServers.

@Before
public void startServers() throws Exception {
    prepareServerDirectories();
    for (ContainerInfo containerInfo : testContext.getAppServerBackendsInfo()) {
        controller.start(containerInfo.getQualifier());
    }
    deploy();
}
Also used : ContainerInfo(org.keycloak.testsuite.arquillian.ContainerInfo) Before(org.junit.Before)

Example 7 with ContainerInfo

use of org.keycloak.testsuite.arquillian.ContainerInfo in project keycloak by keycloak.

the class InfinispanTestTimeServiceRule method before.

@Override
protected void before() throws Throwable {
    if (!this.test.getTestContext().getSuiteContext().isAuthServerCrossDc()) {
        // No cross-dc environment
        test.getTestingClient().testing().setTestingInfinispanTimeService();
    } else {
        AtomicInteger count = new AtomicInteger(0);
        // Cross-dc environment - Set on all started nodes
        forAllBackendNodesStream().filter(ContainerInfo::isStarted).map(CrossDCTestEnricher.getBackendTestingClients()::get).forEach(testingClient -> {
            testingClient.testing().setTestingInfinispanTimeService();
            count.incrementAndGet();
        });
        // 
        log.infof("Totally set infinispanTimeService rule in %d servers", count.get());
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ContainerInfo(org.keycloak.testsuite.arquillian.ContainerInfo)

Example 8 with ContainerInfo

use of org.keycloak.testsuite.arquillian.ContainerInfo in project keycloak by keycloak.

the class AbstractSAMLAdapterClusteredTest method testNodeRestartResiliency.

@Test
public void testNodeRestartResiliency(@ArquillianResource @OperateOnDeployment(value = EmployeeServletDistributable.DEPLOYMENT_NAME) URL employeeUrl) throws Exception {
    ContainerInfo containerInfo = testContext.getAppServerBackendsInfo().get(0);
    setPasswordFor(bburkeUser, CredentialRepresentation.PASSWORD);
    String employeeUrlString = getProxiedUrl(employeeUrl);
    SamlClient samlClient = new SamlClientBuilder().navigateTo(employeeUrlString).processSamlResponse(Binding.POST).build().login().user(bburkeUser).build().processSamlResponse(Binding.POST).build().assertResponse(Matchers.bodyHC(containsString("principal=bburke"))).execute();
    controller.stop(containerInfo.getQualifier());
    // Update the proxy to forward to the second node.
    updateProxy(NODE_2_NAME, NODE_2_URI, NODE_1_URI);
    samlClient.execute(new SamlClientBuilder().navigateTo(employeeUrlString).doNotFollowRedirects().assertResponse(Matchers.bodyHC(containsString("principal=bburke"))).getSteps());
    controller.start(containerInfo.getQualifier());
    // Update the proxy to forward to the first node.
    updateProxy(NODE_1_NAME, NODE_1_URI, NODE_2_URI);
    samlClient.execute(new SamlClientBuilder().navigateTo(employeeUrlString).doNotFollowRedirects().assertResponse(Matchers.bodyHC(containsString("principal=bburke"))).getSteps());
}
Also used : SamlClientBuilder(org.keycloak.testsuite.util.SamlClientBuilder) ContainerInfo(org.keycloak.testsuite.arquillian.ContainerInfo) Matchers.containsString(org.hamcrest.Matchers.containsString) SamlClient(org.keycloak.testsuite.util.SamlClient)

Example 9 with ContainerInfo

use of org.keycloak.testsuite.arquillian.ContainerInfo in project keycloak by keycloak.

the class AbstractCrossDCTest method enableLoadBalancerNode.

/**
 * Enables routing requests to the given node within the given data center in the load balancer.
 * @param dc
 * @param nodeIndex
 */
public void enableLoadBalancerNode(DC dc, int nodeIndex) {
    int dcIndex = dc.ordinal();
    log.infof("--DC: Enabling load balancer for dc=%d, node=%d", dcIndex, nodeIndex);
    final ContainerInfo backendNode = this.suiteContext.getDcAuthServerBackendsInfo().get(dcIndex).get(nodeIndex);
    if (backendNode == null) {
        throw new IllegalArgumentException("Invalid node with index " + nodeIndex + " for DC " + dcIndex);
    }
    if (!backendNode.isStarted()) {
        log.warnf("--DC: Node %s is not started in DC %d", backendNode.getQualifier(), dcIndex);
    }
    loadBalancerCtrl.enableBackendNodeByName(backendNode.getQualifier());
}
Also used : ContainerInfo(org.keycloak.testsuite.arquillian.ContainerInfo)

Example 10 with ContainerInfo

use of org.keycloak.testsuite.arquillian.ContainerInfo in project keycloak by keycloak.

the class AbstractClusterTest method logFailoverSetup.

protected void logFailoverSetup() {
    log.info("Current failover setup");
    boolean started = controller.isStarted(getCurrentFailNode().getQualifier());
    log.info("Fail node: " + getCurrentFailNode() + (started ? "" : " (stopped)"));
    for (ContainerInfo survivor : getCurrentSurvivorNodes()) {
        started = controller.isStarted(survivor.getQualifier());
        log.info("Survivor:  " + survivor + (started ? "" : " (stopped)"));
    }
}
Also used : ContainerInfo(org.keycloak.testsuite.arquillian.ContainerInfo)

Aggregations

ContainerInfo (org.keycloak.testsuite.arquillian.ContainerInfo)14 Container (org.jboss.arquillian.container.spi.Container)3 KeycloakQuarkusServerDeployableContainer (org.keycloak.testsuite.arquillian.containers.KeycloakQuarkusServerDeployableContainer)3 Before (org.junit.Before)2 Annotation (java.lang.annotation.Annotation)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 LinkedList (java.util.LinkedList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 URIBuilder (org.apache.http.client.utils.URIBuilder)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Test (org.junit.Test)1 ComponentRepresentation (org.keycloak.representations.idm.ComponentRepresentation)1 RealmRepresentation (org.keycloak.representations.idm.RealmRepresentation)1 RoleRepresentation (org.keycloak.representations.idm.RoleRepresentation)1 SamlClient (org.keycloak.testsuite.util.SamlClient)1 SamlClientBuilder (org.keycloak.testsuite.util.SamlClientBuilder)1