Merge pull request #2447 from tkyjovsk/KEYCLOAK-2641-fix

KEYCLOAK-2641 fix
This commit is contained in:
Bill Burke 2016-03-30 15:15:54 -04:00
commit 1d2fef5b9b
6 changed files with 102 additions and 70 deletions

View file

@ -1,33 +1,36 @@
# Keycloak Arquillian Integration Testsuite # Keycloak Arquillian Integration Testsuite
## Overview
For overview see the **Modules Overview** section at the bottom of this README.
## Container Lifecycles ## Container Lifecycles
### Keycloak Auth Server ### Auth Server
There is only one instance of Keycloak server running during a single test run. Keycloak server is automatically started by the testsuite on the `BeforeSuite` event and stopped on `AfterSuite` event.
It is automatically started by Arquillian on the `BeforeSuite` event and stopped `AfterSuite`.
The type of container can be determined by property `-Dauth.server.container`. Default value is `auth-server-undertow`, By default the server runs in embedded Undertow.
other options are: `auth-server-wildfly` and `auth-server-eap7`. The values correspond to Arquillian *container qualifiers* in `arquillian.xml` config file.
**Note 1:** For the non-default options it's necessary to build a corresponding server module prior to running any of the test modules. #### Wildfly/EAP
This can be done by building the server module directly (from `servers/wildfly`/`servers/eap7`),
or by activating `auth-server-wildfly`/`auth-server-eap7` profile when building from the top level module.
**Note 2:** Most server-side configurations are done during the build of the server module Testsuite supports running server on Wildfly/EAP. For this it's necessary to:
and included in the output artifact - which is then consumed by the test modules( if a corresponding profile is activated). - build the project including the `distribution` module
To reflect a change in server config in the test (e.g. a datasource) it's necessary to rebuild the server module after each change. (artifact `keycloak-server-dist`/`-overlay` needs to be available before running the testsuite),
- activate profile `auth-server-wildfly` or `auth-server-eap7`.
#### Migration [More details...](servers/auth-server/README.md)
Migration tests can be enabled by setting `-Dmigrated.auth.server.version` property. Supported versions can be found at the bottom of `tests/pom.xml`.
When enabled, the `AuthServerTestEnricher` class will start and stop the selected migrated instance
*before* the current auth server instance is started.
#### Cluster Setup #### Cluster Setup
Cluster setup can be enabled with profile `auth-server-wildfly-cluster`. The cluster setup for server can be enabled by activating profile `auth-server-cluster`.
(It is also necessary to build the server modules with this profile before running the test. See *Notes 1 and 2* above.)
The cluster setup is not supported for server on Undetow. Profile `auth-server-wildfly` or `auth-server-eap` needs to be activated.
The setup includes:
- a `mod_cluster` load balancer on Wildfly
- two clustered nodes of Keycloak server on Wildfly/EAP
Clustering tests require MULTICAST to be enabled on machine's `loopback` network interface. Clustering tests require MULTICAST to be enabled on machine's `loopback` network interface.
This can be done by running the following commands under root privileges: This can be done by running the following commands under root privileges:
@ -36,20 +39,20 @@ route add -net 224.0.0.0 netmask 240.0.0.0 dev lo
ifconfig lo multicast ifconfig lo multicast
``` ```
### App Servers ### App Servers / Adapter Tests
Lifecycle of application server is always tied to a particular TestClass. Lifecycle of application server is always tied to a particular TestClass.
Each *adapter* test class is annotated by `@AppServerContainer("app-server-*")` annotation Each *adapter* test class is annotated by `@AppServerContainer("app-server-*")` annotation
that links it to a particular Arquillian container in `arquillian.xml`. that links it to a particular Arquillian container in `arquillian.xml`.
The `AppServerTestEnricher` then ensures the server is started before and stopped after all tests methods in the class. 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 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). is the same as the auth server container - a "relative" adapter test scenario.
Adapter tests are separated into submodules because different app containers require different configurations The app-servers with installed Keycloak adapter are prepared in `servers/app-server` submodules, activated by `-Papp-server-MODULE`.
(installation of adapter libs, etc.). [More details.](servers/app-server/README.md)
Container entries of app servers are not present in the main `arquillian.xml` in the `base` module.
Each adapter submodule adds it's own entry before it runs the tests. The corresponding adapter test modules are in `tests/other/adapters` submodules, and are activated by the same profiles.
## SuiteContext and TestContext ## SuiteContext and TestContext
@ -130,32 +133,6 @@ It automatically modifies imported test realms and deployments' adapter configs
2. **Bundled** - In the deployed war in `/WEB-INF/keycloak.json`. **Default.** 2. **Bundled** - In the deployed war in `/WEB-INF/keycloak.json`. **Default.**
## Maven Modules Structure
```
integration-arquillian
├──servers
│ ├──wildfly (activated by -Pauth-server-wildfly)
│ └──eap7 (activated by -Pauth-server-eap7)
└──tests (common settings for all test modules)
├──base (custom ARQ extensions + base functional tests)
└──other (common settings for all modules dependent on base)
├──adapters (common settings for all adapter submodules)
│ ├──wildfly (activated by -Papp-server-wildfly)
│ ├──wildfly-relative (activated by -Papp-server-wildfly-relative,auth-server-wildfly)
│ ├──...
│ ├──tomcat (activated by -Papp-server-tomcat)
│ └──karaf (activated by -Papp-server-karaf)
├──console (activated by -Pconsole-ui-tests)
├──mod_auth_mellon (activated by -Pmod_auth_mellon)
├──console_no_users (activated by -Pconsole-ui-no-users-tests)
└──...
```
## Custom Arquillian Extensions ## Custom Arquillian Extensions
Custom extensions are registered in `META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension`. Custom extensions are registered in `META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension`.
@ -173,6 +150,37 @@ Custom extensions are registered in `META-INF/services/org.jboss.arquillian.core
* `DeploymentTargetModifier` - Ensures all test app deployments are targeted at app server containers. * `DeploymentTargetModifier` - Ensures all test app deployments are targeted at app server containers.
* `URLProvider` - Fixes URLs injected by Arquillian Graphene which contain value `127.0.0.1` instead of required `localhost`. * `URLProvider` - Fixes URLs injected by Arquillian Graphene which contain value `127.0.0.1` instead of required `localhost`.
### CustomKarafContainerExtension ## Modules Overview
```
integration-arquillian
├──servers (preconfigured test servers)
│ │
│ ├──auth-server
│ │ ├──jboss (wildfly/eap)
│ │ └──undertow (arq. extension)
│ │
│ ├──app-server
│ │ ├──jboss (wildfly/eap/as)
│ │ ├──tomcat
│ │ └──karaf
│ │
│ └──wildfly-balancer
└──tests (common settings for all test modules)
├──base (custom ARQ extensions + base functional tests)
└──other (common settings for all test modules dependent on base)
├──adapters (common settings for all adapter test modules)
│ ├──jboss
│ ├──tomcat
│ └──karaf
├──console
├──console_no_users
└──...
```
Extension for executing karaf commands after container is started. Used for installation of bundles (test apps and adapter libs).

View file

@ -1,6 +1,9 @@
# Keycloak Arquillian Integration TestSuite # Keycloak Arquillian Integration TestSuite - Test Servers
[Keycloak Arquillian Integration TestSuite](../README.md) - [Keycloak Arquillian Integration TestSuite](../README.md)
- Keycloak Arquillian Integration TestSuite - Test Servers
- [Keycloak Arquillian Integration TestSuite - Test Servers - Auth Server](auth-server/README.md)
- [Keycloak Arquillian Integration TestSuite - Test Servers - App Servers](app-server/README.md)
## Test Servers ## Test Servers
@ -14,8 +17,6 @@ The artifacts are used by the Arquillian TestSuite.
- EAP 7 - EAP 7
- Undertow - Undertow
[Details...](auth-server/README.md)
### App Server ### App Server
@ -30,7 +31,6 @@ The artifacts are used by the Arquillian TestSuite.
- Tomcat - Tomcat
- Tomcat 7, 8 - Tomcat 7, 8
[Details...](app-server/README.md)
### Load Balancer ### Load Balancer

View file

@ -1,6 +1,9 @@
# Keycloak Arquillian Integration TestSuite - Test Servers # Keycloak Arquillian Integration TestSuite - Test Servers - App Servers
[Up...](../README.md) - [Keycloak Arquillian Integration TestSuite](../../README.md)
- [Keycloak Arquillian Integration TestSuite - Test Servers](../README.md)
- [Keycloak Arquillian Integration TestSuite - Test Servers - Auth Server](../auth-server/README.md)
- Keycloak Arquillian Integration TestSuite - Test Servers - App Servers
## App Server - JBoss ## App Server - JBoss

View file

@ -1,16 +1,21 @@
# Keycloak Arquillian Integration TestSuite - Test Servers # Keycloak Arquillian Integration TestSuite - Test Servers - Auth Server
[Up...](../README.md) - [Keycloak Arquillian Integration TestSuite](../../README.md)
- [Keycloak Arquillian Integration TestSuite - Test Servers](../README.md)
- Keycloak Arquillian Integration TestSuite - Test Servers - Auth Server
- [Keycloak Arquillian Integration TestSuite - Test Servers - App Servers](../app-server/README.md)
## Auth Server - JBoss `auth-server/jboss` ## Auth Server - JBoss
### Modules Common configurations of Keycloak server on JBoss-based container (Wildfly/EAP).
* __`wildfly` Wildfly 10__ ### Submodules
#### `wildfly` Wildfly 10
- Builds keycloak server on top of latest Wildfly. - Builds keycloak server on top of latest Wildfly.
- Activated by __`-Pauth-server-wildfly`__ - Activated by __`-Pauth-server-wildfly`__
* __`eap` EAP 7__ #### `eap` EAP 7
- Builds keycloak server on top of latest EAP. - Builds keycloak server on top of latest EAP.
- Activated by __`-Pauth-server-eap`__ - Activated by __`-Pauth-server-eap`__
- Requires access to product repo. - Requires access to product repo.
@ -39,6 +44,6 @@ Configures in `standalone-ha.xml`:
See profile `auth-server-cluster`. See profile `auth-server-cluster`.
## Auth Server - Undertow `auth-server/undertow` ## Auth Server - Undertow
Arquillian extension for running Keycloak server in embedded Undertow. Arquillian extension for running Keycloak server in embedded Undertow.

View file

@ -57,6 +57,9 @@
<unpacked.artifact.version>${auth.server.dist.version}</unpacked.artifact.version> <unpacked.artifact.version>${auth.server.dist.version}</unpacked.artifact.version>
<auth.server.home>${project.build.directory}/unpacked/${auth.server.dist.unpacked.folder.name}</auth.server.home> <auth.server.home>${project.build.directory}/unpacked/${auth.server.dist.unpacked.folder.name}</auth.server.home>
<!--used in profile auth-server-cluster. profile jpa sets this to true-->
<skip.h2.tcp>false</skip.h2.tcp>
</properties> </properties>
<profiles> <profiles>
@ -268,6 +271,7 @@
<id>jpa</id> <id>jpa</id>
<properties> <properties>
<jdbc.mvn.driver.deployment.dir>${auth.server.home}/modules/system/layers/base/com/${jdbc.mvn.artifactId}/main</jdbc.mvn.driver.deployment.dir> <jdbc.mvn.driver.deployment.dir>${auth.server.home}/modules/system/layers/base/com/${jdbc.mvn.artifactId}/main</jdbc.mvn.driver.deployment.dir>
<skip.h2.tcp>true</skip.h2.tcp>
</properties> </properties>
<build> <build>
<pluginManagement> <pluginManagement>
@ -344,7 +348,7 @@
<!-- create module.xml in modules --> <!-- create module.xml in modules -->
<transformationSet> <transformationSet>
<dir>${auth.server.home}/modules/system/layers/base/com/h2database/h2/main</dir> <dir>${auth.server.home}/modules/system/layers/base/com/h2database/h2/main</dir>
<stylesheet>src/main/resources/module.xsl</stylesheet> <stylesheet>src/main/resources/xslt/module.xsl</stylesheet>
<includes> <includes>
<include>module.xml</include> <include>module.xml</include>
</includes> </includes>
@ -366,6 +370,7 @@
<stylesheet>${common.resources}/datasource.xsl</stylesheet> <stylesheet>${common.resources}/datasource.xsl</stylesheet>
<includes> <includes>
<include>standalone.xml</include> <include>standalone.xml</include>
<include>standalone-ha.xml</include>
</includes> </includes>
<outputDir>${auth.server.home}/standalone/configuration</outputDir> <outputDir>${auth.server.home}/standalone/configuration</outputDir>
<parameters> <parameters>
@ -421,14 +426,13 @@
<artifactId>xml-maven-plugin</artifactId> <artifactId>xml-maven-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<id>configure-wildfly-datasource</id> <id>jpa-h2-tcp</id>
<phase>process-resources</phase> <phase>process-resources</phase>
<goals> <goals>
<goal>transform</goal> <goal>transform</goal>
</goals> </goals>
<configuration> <configuration>
<transformationSets> <transformationSets>
<!-- point KeycloakDS datasource to H2 running on TCP port -->
<transformationSet> <transformationSet>
<dir>${auth.server.home}/standalone/configuration</dir> <dir>${auth.server.home}/standalone/configuration</dir>
<includes> <includes>
@ -447,6 +451,18 @@
</parameter> </parameter>
</parameters> </parameters>
</transformationSet> </transformationSet>
</transformationSets>
<skip>${skip.h2.tcp}</skip>
</configuration>
</execution>
<execution>
<id>keycloak-ispn-caches</id>
<phase>process-resources</phase>
<goals>
<goal>transform</goal>
</goals>
<configuration>
<transformationSets>
<transformationSet> <transformationSet>
<dir>${auth.server.home}/standalone/configuration</dir> <dir>${auth.server.home}/standalone/configuration</dir>
<includes> <includes>