support for smoke test - clean start domain mode

This commit is contained in:
Vlasta Ramik 2016-05-23 13:17:20 +02:00
parent ff20c530cd
commit a37d43714d
8 changed files with 129 additions and 39 deletions

View file

@ -45,7 +45,7 @@
<selenium.version>2.52.0</selenium.version>
<arquillian-drone.version>2.0.0.Beta1</arquillian-drone.version>
<arquillian-graphene.version>2.1.0.Alpha3</arquillian-graphene.version>
<arquillian-wildfly-container.version>8.2.0.Final</arquillian-wildfly-container.version>
<arquillian-wildfly-container.version>2.0.0.Final</arquillian-wildfly-container.version>
<version.shrinkwrap.resolvers>2.2.2</version.shrinkwrap.resolvers>
<undertow-embedded.version>1.0.0.Alpha2</undertow-embedded.version>
</properties>
@ -74,15 +74,20 @@
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<version>${arquillian-wildfly-container.version}</version>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-remote</artifactId>
<version>${arquillian-wildfly-container.version}</version>
</dependency>
<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-domain-managed</artifactId>
<version>${arquillian-wildfly-container.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

View file

@ -34,8 +34,11 @@ import org.jboss.arquillian.container.spi.client.deployment.TargetDescription;
import org.jboss.arquillian.core.api.Injector;
import org.jboss.arquillian.core.spi.ServiceLoader;
import org.jboss.arquillian.core.spi.Validate;
import static org.keycloak.testsuite.arquillian.containers.RegistryCreator.ADAPTER_IMPL_CONFIG_STRING;
import static org.keycloak.testsuite.arquillian.containers.RegistryCreator.getAdapterImplClassValue;
import static org.keycloak.testsuite.arquillian.containers.RegistryCreator.getContainerAdapter;
import static org.keycloak.testsuite.arquillian.containers.SecurityActions.isClassPresent;
import static org.keycloak.testsuite.arquillian.containers.SecurityActions.loadClass;
/**
* This class registers all adapters which are specified in the arquillian.xml.
@ -78,6 +81,10 @@ public class Registry implements ContainerRegistry {
// just one container on cp
dcService = containerAdapters.iterator().next();
} else {
Container domainContainer = domainContainer(loader, definition);
if (domainContainer != null) {
return domainContainer;
}
if (dcService == null) {
dcService = getContainerAdapter(getAdapterImplClassValue(definition), containerAdapters);
}
@ -94,6 +101,42 @@ public class Registry implements ContainerRegistry {
throw new ContainerCreationException("Could not create Container " + definition.getContainerName(), e);
}
}
private Container domainContainer(ServiceLoader loader, ContainerDef definition) {
for (Container container : containers) {
String adapterImplClassValue = container.getContainerConfiguration().getContainerProperties()
.get(ADAPTER_IMPL_CONFIG_STRING);
if (isServiceLoaderClassAssignableFromAdapterImplClass(loader, adapterImplClassValue.trim())) {
try {
return addContainer((Container) injector.inject(
new ContainerImpl(
definition.getContainerName(),
(DeployableContainer) loader.onlyOne(DeployableContainer.class),
definition)));
} catch (Exception ex) {
throw new ContainerCreationException(
"Could not create Container " + definition.getContainerName(), ex);
}
}
}
return null;
}
private boolean isServiceLoaderClassAssignableFromAdapterImplClass(ServiceLoader loader, String adapterImplClassValue) {
if (adapterImplClassValue == null && loader == null) {
return false;
}
if (isClassPresent(adapterImplClassValue)) {
Class<?> aClass = loadClass(adapterImplClassValue);
String loaderClassName = loader.getClass().getName();
if (loaderClassName.contains("$")) {
loaderClassName = loaderClassName.substring(0, loaderClassName.indexOf("$"));
}
return loadClass(loaderClassName).isAssignableFrom(aClass);
}
return false;
}
@Override
public List<Container> getContainers() {

View file

@ -17,6 +17,7 @@
package org.keycloak.testsuite.arquillian.containers;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.jboss.arquillian.config.descriptor.api.ArquillianDescriptor;
@ -71,7 +72,17 @@ public class RegistryCreator {
throw new IllegalStateException("There are not any container adapters on the classpath");
}
for (ContainerDef container : event.getContainers()) {
createRegistry(event.getContainers(), containers, reg, serviceLoader);
for (GroupDef group : event.getGroups()) {
createRegistry(group.getGroupContainers(), containers, reg, serviceLoader);
}
registry.set(reg);
}
private void createRegistry(List<ContainerDef> containerDefs, Collection<DeployableContainer> containers, ContainerRegistry reg, ServiceLoader serviceLoader) {
for (ContainerDef container : containerDefs) {
if (isCreatingContainer(container, containers)) {
if (isEnabled(container)) {
log.info("Registering container: " + container.getContainerName());
@ -81,21 +92,6 @@ public class RegistryCreator {
}
}
}
for (GroupDef group : event.getGroups()) {
for (ContainerDef container : group.getGroupContainers()) {
if (isCreatingContainer(container, containers)) {
if (isEnabled(container)) {
log.info("Registering container: " + container.getContainerName());
reg.create(container, serviceLoader);
} else {
log.info("Container is disabled: " + container.getContainerName());
}
}
}
}
registry.set(reg);
}
private static final String ENABLED = "enabled";
@ -138,7 +134,7 @@ public class RegistryCreator {
Validate.notNullOrEmpty(adapterImplClass, "The value of " + ADAPTER_IMPL_CONFIG_STRING + " can not be a null object "
+ "nor an empty string!");
Class<?> foundAdapter = null;
Class<?> foundAdapter;
if (isClassPresent(adapterImplClass)) {
foundAdapter = loadClass(adapterImplClass);

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 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.util;
import org.apache.commons.io.FileUtils;
@ -21,20 +37,20 @@ public class LogChecker {
log.info(String.format("Checking server log: '%s'", logFile.getAbsolutePath()));
String[] logContent = FileUtils.readFileToString(logFile).split("\n");
for (String log : logContent) {
boolean containsError = log.contains("ERROR") || log.contains("SEVERE") || log.contains("Exception ");
for (String logText : logContent) {
boolean containsError = logText.contains("ERROR") || logText.contains("SEVERE") || logText.contains("Exception ");
//There is expected string "Exception" in server log: Adding provider
//singleton org.keycloak.services.resources.ModelExceptionMapper
if (containsError) {
boolean ignore = false;
for (String i : IGNORED) {
if (log.matches(i)) {
if (logText.matches(i)) {
ignore = true;
break;
}
}
if (!ignore) {
throw new RuntimeException(String.format("Server log file contains ERROR: '%s'", log));
throw new RuntimeException(String.format("Server log file contains ERROR: '%s'", logText));
}
}
}
@ -42,7 +58,15 @@ public class LogChecker {
}
public static void checkJBossServerLog(String jbossHome) throws IOException {
checkServerLog(new File(jbossHome + "/standalone/log/server.log"));
boolean domain = System.getProperty("auth.server.config.property.name", "standalone").contains("domain");
if (domain) {
checkServerLog(new File(jbossHome + "/domain/log/process-controller.log"));
checkServerLog(new File(jbossHome + "/domain/log/host-controller.log"));
checkServerLog(new File(jbossHome + "/domain/servers/load-balancer/log/server.log"));
checkServerLog(new File(jbossHome + "/domain/servers/server-one/log/server.log"));
} else {
checkServerLog(new File(jbossHome + "/standalone/log/server.log"));
}
}
}
}

View file

@ -57,9 +57,11 @@
<container qualifier="auth-server-${auth.server}" mode="suite" >
<configuration>
<property name="enabled">${auth.server.jboss}</property>
<property name="adapterImplClass">org.jboss.as.arquillian.container.managed.ManagedDeployableContainer</property>
<property name="adapterImplClass">${auth.server.adapter.impl.class}</property>
<property name="jbossHome">${auth.server.home}</property>
<property name="serverConfig">${auth.server.config}</property>
<property name="${auth.server.config.property.name}">${auth.server.config.property.value}</property>
<!-- This is required for domain mode -->
<property name="allowConnectingToRunningServer">true</property>
<property name="jbossArguments">
-Djboss.socket.binding.port-offset=${auth.server.port.offset}
-Djboss.bind.address=0.0.0.0
@ -221,4 +223,4 @@
</configuration>
</container>
</arquillian>
</arquillian>

View file

@ -129,9 +129,8 @@
</activation>
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-${app.server.type}</artifactId>
<version>${arquillian-wildfly-container.version}</version>
</dependency>
</dependencies>
</profile>

View file

@ -62,8 +62,24 @@
<profile>
<id>standalone-ha</id>
<properties>
<auth.server.config>standalone-ha.xml</auth.server.config>
<auth.server.config.property.value>standalone-ha.xml</auth.server.config.property.value>
</properties>
</profile>
<profile>
<id>domain</id>
<properties>
<auth.server.config.property.name>domainConfig</auth.server.config.property.name>
<auth.server.config.property.value>domain.xml</auth.server.config.property.value>
<auth.server.config.dir>${auth.server.home}/domain/configuration</auth.server.config.dir>
<auth.server.adapter.impl.class>org.jboss.as.arquillian.container.domain.managed.ManagedDomainDeployableContainer</auth.server.adapter.impl.class>
<auth.server.management.port>9990</auth.server.management.port>
</properties>
<dependencies>
<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-domain-managed</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
</project>

View file

@ -56,7 +56,9 @@
<auth.server.ssl.required>false</auth.server.ssl.required>
<auth.server.jboss.startup.timeout>60</auth.server.jboss.startup.timeout>
<auth.server.memory.settings>-Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m</auth.server.memory.settings>
<auth.server.config.property.name>serverConfig</auth.server.config.property.name>
<auth.server.adapter.impl.class>org.jboss.as.arquillian.container.managed.ManagedDeployableContainer</auth.server.adapter.impl.class>
<auth.server.jboss.artifactId>integration-arquillian-servers-auth-server-${auth.server}</auth.server.jboss.artifactId>
<auth.server.jboss.skip.unpack>${auth.server.undertow}</auth.server.jboss.skip.unpack>
<auth.server.jboss.startup.timeout>300</auth.server.jboss.startup.timeout>
@ -155,7 +157,10 @@
<auth.server.ssl.required>${auth.server.ssl.required}</auth.server.ssl.required>
<auth.server.jboss.startup.timeout>${auth.server.jboss.startup.timeout}</auth.server.jboss.startup.timeout>
<auth.server.config.dir>${auth.server.config.dir}</auth.server.config.dir>
<auth.server.config>${auth.server.config}</auth.server.config>
<auth.server.config.property.name>${auth.server.config.property.name}</auth.server.config.property.name>
<auth.server.config.property.value>${auth.server.config.property.value}</auth.server.config.property.value>
<auth.server.adapter.impl.class>${auth.server.adapter.impl.class}</auth.server.adapter.impl.class>
<frontend.console.output>${frontend.console.output}</frontend.console.output>
<backends.console.output>${backend.console.output}</backends.console.output>
@ -205,13 +210,13 @@
<auth.server>wildfly</auth.server>
<auth.server.jboss>true</auth.server.jboss>
<auth.server.undertow>false</auth.server.undertow>
<auth.server.config>standalone.xml</auth.server.config>
<auth.server.config.property.value>standalone.xml</auth.server.config.property.value>
<auth.server.config.dir>${auth.server.home}/standalone/configuration</auth.server.config.dir>
<h2.version>1.3.173</h2.version>
</properties>
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
</dependency>
</dependencies>
@ -223,13 +228,13 @@
<auth.server>eap</auth.server>
<auth.server.jboss>true</auth.server.jboss>
<auth.server.undertow>false</auth.server.undertow>
<auth.server.config>standalone.xml</auth.server.config>
<auth.server.config.property.value>standalone.xml</auth.server.config.property.value>
<auth.server.config.dir>${auth.server.home}/standalone/configuration</auth.server.config.dir>
<h2.version>1.3.173</h2.version>
</properties>
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
</dependency>
</dependencies>