Skip to content

Commit

Permalink
KEYCLOAK-6541 base changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vramik authored and pdrozd committed Jun 11, 2018
1 parent f293ab8 commit 6a07a7e
Show file tree
Hide file tree
Showing 28 changed files with 493 additions and 139 deletions.
13 changes: 5 additions & 8 deletions testsuite/integration-arquillian/HOW-TO-RUN.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,15 @@ TODO: Add info about Wildfly logging

## Run adapter tests

### Wildfly
### Undertow
mvn -f testsuite/integration-arquillian/tests/base/pom.xml \
-Dtest=org.keycloak.testsuite.adapter.**.*Test

### Wildfly

# Prepare servers
mvn -f testsuite/integration-arquillian/servers/pom.xml clean install \
-Pauth-server-wildfly \
-Papp-server-wildfly

# Run tests
mvn -f testsuite/integration-arquillian/tests/other/adapters/jboss/wildfly/pom.xml \
mvn -f testsuite/integration-arquillian/pom.xml \
clean install \
-Pauth-server-wildfly \
-Papp-server-wildfly


Expand Down
21 changes: 6 additions & 15 deletions testsuite/integration-arquillian/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,14 @@ ifconfig lo multicast

Lifecycle of application server is always tied to a particular TestClass.

Each *adapter* test class is annotated by `@AppServerContainer("app-server-*")` annotation
that links it to a particular Arquillian container in `arquillian.xml`.
The `AppServerTestEnricher` then ensures the server is started during `BeforeClass` event and stopped during `AfterClass` event for that particular test class.
In case the `@AppServerContainer` annotation has no value it's assumed that the application container
is the same as the auth server container - a "relative" adapter test scenario.
Each *adapter* test class is annotated by one or more `@AppServerContainer("app-server-*")` annotations
that links it to a particular Arquillian container.
The `AppServerTestEnricher` then ensures the corresponding server is started during `BeforeClass` event and stopped during `AfterClass` event for that particular test class.

The app-servers with installed Keycloak adapter are prepared in `servers/app-server` submodules, activated by `-Papp-server-MODULE`.
The app-servers with installed Keycloak adapter are prepared in `servers/app-server` submodules, activated by `-Papp-server-MODULE` or `-Dapp.server=MODULE`
[More details.](servers/app-server/README.md)

The corresponding adapter test modules are in `tests/other/adapters` submodules, and are activated by the same profiles.
NOTE: Some corresponding adapter test modules are in `tests/other/adapters` submodules, and are activated by the same profiles. It will be tranferred into base testsuite.

## SuiteContext and TestContext

Expand Down Expand Up @@ -104,13 +102,6 @@ The other test modules depend on this module.
Tests for Keycloak Admin Console are located in a separate module `tests/other/console`
and are **disabled** by default. Can be enabled by `-Pconsole-ui-tests`.

### Adapter Tests

Adapter tests are located in submodules of the `tests/other/adapters` module.

They are **disabled** by default; they can be enabled by corresponding profiles.
Multiple profiles can be enabled for a single test execution.

#### Types of adapter tests

1. Using *custom test servlets*
Expand Down Expand Up @@ -173,7 +164,7 @@ integration-arquillian
└──other (common settings for all test modules dependent on base)
├──adapters (common settings for all adapter test modules)
├──adapters (common settings for all adapter test modules - will be moved into base)
│ ├──jboss
│ ├──tomcat
│ └──karaf
Expand Down
10 changes: 5 additions & 5 deletions testsuite/integration-arquillian/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@
<app.server.java.home>${java.home}</app.server.java.home>

<!--component versions-->
<arquillian-core.version>1.1.13.Final</arquillian-core.version>
<selenium.version>3.5.3</selenium.version>
<arquillian-drone.version>2.4.2</arquillian-drone.version>
<arquillian-graphene.version>2.3.1</arquillian-graphene.version>
<!--to update arquillian-core to 1.3.0.Final or higher see https://issues.jboss.org/browse/ARQ-2181 -->
<arquillian-core.version>1.2.1.Final</arquillian-core.version>
<selenium.version>3.11.0</selenium.version>
<arquillian-drone.version>2.5.1</arquillian-drone.version>
<arquillian-graphene.version>2.3.2</arquillian-graphene.version>
<arquillian-wildfly-container.version>2.1.0.Final</arquillian-wildfly-container.version>
<arquillian-wls-container.version>1.0.1.Final</arquillian-wls-container.version>
<arquillian-container-karaf.version>2.2.0.Final</arquillian-container-karaf.version>
<arquillian-infinispan-container.version>1.2.0.Beta2</arquillian-infinispan-container.version>
<version.shrinkwrap.resolvers>2.2.6</version.shrinkwrap.resolvers>
<undertow-embedded.version>1.0.0.Alpha2</undertow-embedded.version>
<version.org.wildfly.extras.creaper>1.6.1</version.org.wildfly.extras.creaper>
<testcontainers.version>1.5.1</testcontainers.version>
Expand Down
5 changes: 2 additions & 3 deletions testsuite/integration-arquillian/servers/app-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ Submodules are enabled with profiles: `-Papp-server-MODULE`

### Modules

* __`as7` JBossAS 7__
* __`wildfly8` Wildfly 8__
* __`wildfly9` Wildfly 9__
* __`wildfly` Wildfly 10__
* __`wildfly10` Wildfly 10__
* __`wildfly` Wildfly 11__
* __`eap6` EAP 6__ Requires access to EAP product repo, or setting `-Deap6.version` to public EAP 6 Alpha.
* __`eap` EAP 7__ Requires access to EAP product repo.
* __`relative`__ Activate with `-Papp-server-relative`.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0"?>
<!--
~ Copyright 2018 Red Hat, Inc. and/or its affiliates
~ and other contributors as indicated by the @author tags.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<parent>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-servers-app-server</artifactId>
<version>4.0.0.Final-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>integration-arquillian-servers-app-server-spi</artifactId>
<packaging>jar</packaging>
<name>App Server - SPI</name>

<dependencies>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.keycloak.testsuite.arquillian.container;

import java.util.List;
import org.jboss.shrinkwrap.descriptor.spi.node.Node;

/**
* @author <a href="mailto:[email protected]">Vlasta Ramik</a>
*/
public interface AppServerContainerSPI {

public static final String APP_SERVER = "app-server";

/**
* @return string name of container
*/
public String getName();

/**
* @return List of available containers or null if there are none
*/
public List<Node> getContainers();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.keycloak.testsuite.arquillian.container;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import org.jboss.shrinkwrap.descriptor.spi.node.Node;

/**
* @author <a href="mailto:[email protected]">Vlasta Ramik</a>
*/
public class AppServerContainerService {

private static AppServerContainerService service;
private final ServiceLoader<AppServerContainerSPI> loader;

private AppServerContainerService() {
loader = ServiceLoader.load(AppServerContainerSPI.class);
}

public static synchronized AppServerContainerService getInstance() {
if (service == null) {
service = new AppServerContainerService();
}
return service;
}

public List<Node> getContainers(String appServerName) {
List<Node> containers = null;
try {
Iterator<AppServerContainerSPI> definitions = loader.iterator();

List<AppServerContainerSPI> availableDefinitions = new ArrayList<>();
while (definitions != null && definitions.hasNext()) {
availableDefinitions.add(definitions.next());
}
for (AppServerContainerSPI def : availableDefinitions) {
if (def.getName().equals(appServerName)) {
containers = def.getContainers();
}
}
} catch (ServiceConfigurationError serviceError) {
containers = null;
throw serviceError;
}
return containers;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
</properties>

<modules>
<module>app-server-spi</module>
<module>jboss</module>
<module>karaf</module>
<module>tomcat</module>
Expand Down
30 changes: 27 additions & 3 deletions testsuite/integration-arquillian/tests/base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
<exclude.x509>**/x509/*Test.java</exclude.x509>
<!-- KEYCLOAK-6771 exclude Mutual TLS Holder of Key Token x509 tests by default, enabled by 'ssl' profile -->
<exclude.HoK>**/hok/**/*Test.java</exclude.HoK>
<!-- exclude undertow adapter tests. They can be added by -Dtest=org.keycloak.testsuite.adapter.undertow.**.*Test -->
<exclude.undertow.adapter>**/adapter/undertow/**/*Test.java</exclude.undertow.adapter>
<!-- see include-CORS-tests profile -->
<exclude.cors.tests>**/cors/*Test.java</exclude.cors.tests>
</properties>

<dependencies>
Expand Down Expand Up @@ -121,6 +121,11 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-servers-app-server-spi</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -162,6 +167,7 @@
<exclude>${exclude.crossdc}</exclude>
<exclude>${exclude.undertow.adapter}</exclude>
<exclude>${exclude.x509}</exclude>
<exclude>${exclude.cors.tests}</exclude>
<exclude>${exclude.HoK}</exclude>
</excludes>
</configuration>
Expand Down Expand Up @@ -330,7 +336,25 @@
</kie.maven.settings>
</properties>
</profile>

<profile>
<id>include-CORS-tests</id>
<!--
If you want to run CORS tests it is necessary to put
127.0.0.1 localhost-auth
127.0.0.1 localhost-db
to your /etc/hosts file
-->
<activation>
<property>
<name>includeCorsTests</name>
</property>
</activation>
<properties>
<exclude.cors.tests>-</exclude.cors.tests>
</properties>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.testsuite.arquillian;

import java.lang.reflect.Method;
import org.jboss.arquillian.test.spi.execution.ExecutionDecision;
import org.jboss.arquillian.test.spi.execution.TestExecutionDecider;
import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.logging.Logger;

/**
* @author <a href="mailto:[email protected]">Vlastislav Ramik</a>
*/
public class AdapterTestExecutionDecider implements TestExecutionDecider {

private final Logger log = Logger.getLogger(AdapterTestExecutionDecider.class);

@Inject private Instance<TestContext> testContextInstance;

@Override
public ExecutionDecision decide(Method method) {
TestContext testContext = testContextInstance.get();
if (!testContext.isAdapterTest()) return ExecutionDecision.execute();
if (testContext.isAdapterContainerEnabled() || testContext.isAdapterContainerEnabledCluster()) {
return ExecutionDecision.execute();
} else {
log.debug("Skipping test: Not enabled by @AppServerContainer annotations.");
return ExecutionDecision.dontExecute("Not enabled by @AppServerContainer annotations.");
}
}

@Override
public int precedence() {
return 1;
}

}
Loading

0 comments on commit 6a07a7e

Please sign in to comment.