Merge pull request #1794 from tkyjovsk/karaf-fuse-update
Adapter tests for Karaf: Fuse Example installation now done via JMX i…
This commit is contained in:
commit
076690e21e
9 changed files with 257 additions and 58 deletions
|
@ -13,7 +13,8 @@
|
|||
|
||||
<properties>
|
||||
<karaf.version>3.0.3</karaf.version>
|
||||
<karaf.home>${project.build.directory}/assembly</karaf.home>
|
||||
<karaf.home>${containers.home}/apache-karaf-minimal-${karaf.version}</karaf.home>
|
||||
<!--<karaf.home>${project.build.directory}/assembly</karaf.home>-->
|
||||
|
||||
<!--fuse examples expect auth server on 8080-->
|
||||
<auth.server.port.offset>0</auth.server.port.offset>
|
||||
|
@ -25,82 +26,57 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- for karaf-maven-plugin -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.karaf.features</groupId>
|
||||
<artifactId>framework</artifactId>
|
||||
<groupId>org.apache.karaf</groupId>
|
||||
<artifactId>apache-karaf-minimal</artifactId>
|
||||
<version>${karaf.version}</version>
|
||||
<type>kar</type>
|
||||
<type>zip</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel.karaf</groupId>
|
||||
<artifactId>apache-camel</artifactId>
|
||||
<version>2.12.5</version>
|
||||
<classifier>features</classifier>
|
||||
<type>xml</type>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf.karaf</groupId>
|
||||
<artifactId>apache-cxf</artifactId>
|
||||
<version>2.7.14</version>
|
||||
<classifier>features</classifier>
|
||||
<type>xml</type>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.keycloak</groupId>
|
||||
<artifactId>keycloak-osgi-features</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<classifier>features</classifier>
|
||||
<type>xml</type>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.keycloak.example.demo</groupId>
|
||||
<artifactId>keycloak-fuse-example-features</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<classifier>features</classifier>
|
||||
<type>xml</type>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- for arquillian -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jboss.arquillian.container</groupId>
|
||||
<artifactId>arquillian-container-karaf-managed</artifactId>
|
||||
<version>2.1.0.CR18</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.aries.jmx</groupId>
|
||||
<artifactId>org.apache.aries.jmx</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.karaf.tooling</groupId>
|
||||
<artifactId>karaf-maven-plugin</artifactId>
|
||||
<version>${karaf.version}</version>
|
||||
<extensions>true</extensions>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>prepare-karaf-with-examples</id>
|
||||
<phase>generate-test-resources</phase>
|
||||
<id>unpack-karaf</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<!-- creates custom karaf distro in ${project.build.directory}/assembly -->
|
||||
<goal>install-kars</goal>
|
||||
<goal>unpack</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.apache.karaf</groupId>
|
||||
<artifactId>apache-karaf-minimal</artifactId>
|
||||
<version>${karaf.version}</version>
|
||||
<type>zip</type>
|
||||
<outputDirectory>${containers.home}</outputDirectory>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
<overWriteIfNewer>true</overWriteIfNewer>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<bootFeatures>
|
||||
<!-- this installs all fuse examples -->
|
||||
<feature>keycloak-fuse-example</feature>
|
||||
</bootFeatures>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:xalan="http://xml.apache.org/xalan"
|
||||
xmlns:a="http://jboss.org/schema/arquillian"
|
||||
version="2.0"
|
||||
exclude-result-prefixes="xalan a">
|
||||
|
||||
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" xalan:indent-amount="4" standalone="no"/>
|
||||
<xsl:strip-space elements="*"/>
|
||||
|
||||
<xsl:template match="/a:arquillian">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="node()|@*"/>
|
||||
|
||||
<container qualifier="app-server-karaf" mode="manual" >
|
||||
<configuration>
|
||||
<property name="enabled">${app.server.karaf}</property>
|
||||
<property name="adapterImplClass">org.keycloak.testsuite.arquillian.karaf.CustomKarafContainer</property>
|
||||
<property name="autostartBundle">false</property>
|
||||
<property name="karafHome">${karaf.home}</property>
|
||||
<property name="javaVmArguments">-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=n ${adapter.test.props}</property>
|
||||
<property name="jmxServiceURL">service:jmx:rmi://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root</property>
|
||||
<property name="jmxUsername">admin</property>
|
||||
<property name="jmxPassword">admin</property>
|
||||
|
||||
<property name="commandsAfterStart">
|
||||
features:addurl mvn:org.keycloak/keycloak-osgi-features/1.7.0.Final-SNAPSHOT/xml/features,
|
||||
features:addurl mvn:org.keycloak.example.demo/keycloak-fuse-example-features/1.7.0.Final-SNAPSHOT/xml/features,
|
||||
features:install keycloak-fuse-example
|
||||
</property>
|
||||
|
||||
</configuration>
|
||||
</container>
|
||||
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="@*|node()">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="@*|node()" />
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
</xsl:stylesheet>
|
|
@ -14,13 +14,24 @@
|
|||
<container qualifier="app-server-karaf" mode="manual" >
|
||||
<configuration>
|
||||
<property name="enabled">${app.server.karaf}</property>
|
||||
<property name="adapterImplClass">org.jboss.arquillian.container.osgi.karaf.managed.KarafManagedDeployableContainer</property>
|
||||
<!--<property name="adapterImplClass">org.jboss.arquillian.container.osgi.karaf.managed.KarafManagedDeployableContainer</property>-->
|
||||
<property name="adapterImplClass">org.keycloak.testsuite.arquillian.karaf.CustomKarafContainer</property>
|
||||
<property name="autostartBundle">false</property>
|
||||
<property name="karafHome">${karaf.home}</property>
|
||||
<property name="javaVmArguments">-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=n ${adapter.test.props}</property>
|
||||
<property name="jmxServiceURL">service:jmx:rmi://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root</property>
|
||||
<property name="jmxUsername">karaf</property>
|
||||
<property name="jmxPassword">karaf</property>
|
||||
|
||||
<!-- The following commands are performed by the CustomKarafContainer -->
|
||||
<property name="commandsAfterStart">
|
||||
feature:repo-add mvn:org.apache.camel.karaf/apache-camel/2.15.1/xml/features,
|
||||
feature:repo-add mvn:org.apache.cxf.karaf/apache-cxf/3.0.4/xml/features,
|
||||
feature:repo-add mvn:org.keycloak/keycloak-osgi-features/1.7.0.Final-SNAPSHOT/xml/features,
|
||||
feature:repo-add mvn:org.keycloak.example.demo/keycloak-fuse-example-features/1.7.0.Final-SNAPSHOT/xml/features,
|
||||
feature:install keycloak-fuse-example
|
||||
</property>
|
||||
|
||||
</configuration>
|
||||
</container>
|
||||
|
||||
|
|
|
@ -16,6 +16,14 @@
|
|||
<exclude.account>-</exclude.account>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jboss.arquillian.container</groupId>
|
||||
<artifactId>arquillian-container-karaf-managed</artifactId>
|
||||
<version>2.1.0.CR18</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
|
|
@ -123,7 +123,8 @@ public class ContainersTestEnricher {
|
|||
*/
|
||||
private void checkServerLog() throws IOException {
|
||||
Container container = containers.removeFirst();
|
||||
if (!container.getName().equals("auth-server-undertow")) {
|
||||
if (container.getName().equals("auth-server-wildfly")
|
||||
|| container.getName().matches("auth-server-eap.")) {
|
||||
String jbossHomePath = container.getContainerConfiguration().getContainerProperties().get("jbossHome");
|
||||
log.debug("jbossHome: " + jbossHomePath + "\n");
|
||||
|
||||
|
@ -133,8 +134,8 @@ public class ContainersTestEnricher {
|
|||
= serverLogContent.contains("ERROR")
|
||||
|| serverLogContent.contains("SEVERE")
|
||||
|| serverLogContent.contains("Exception ");
|
||||
//There is expected string "Exception" in server log: Adding provider
|
||||
//singleton org.keycloak.services.resources.ModelExceptionMapper
|
||||
//There is expected string "Exception" in server log: Adding provider
|
||||
//singleton org.keycloak.services.resources.ModelExceptionMapper
|
||||
|
||||
if (containsError) {
|
||||
throw new RuntimeException(container.getName() + ": Server log contains ERROR.");
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.jboss.arquillian.graphene.location.CustomizableURLResourceProvider;
|
|||
import org.jboss.arquillian.test.spi.enricher.resource.ResourceProvider;
|
||||
import org.jboss.arquillian.test.spi.execution.TestExecutionDecider;
|
||||
import org.keycloak.testsuite.arquillian.jira.JiraTestExecutionDecider;
|
||||
import org.keycloak.testsuite.arquillian.karaf.CustomKarafContainer;
|
||||
import org.keycloak.testsuite.arquillian.migration.MigrationTestExecutionDecider;
|
||||
import org.keycloak.testsuite.arquillian.undertow.CustomUndertowContainer;
|
||||
|
||||
|
@ -34,7 +35,8 @@ public class KeycloakArquillianExtension implements LoadableExtension {
|
|||
.observer(ContainersTestEnricher.class);
|
||||
|
||||
builder
|
||||
.service(DeployableContainer.class, CustomUndertowContainer.class);
|
||||
.service(DeployableContainer.class, CustomUndertowContainer.class)
|
||||
.service(DeployableContainer.class, CustomKarafContainer.class);
|
||||
|
||||
builder
|
||||
.service(TestExecutionDecider.class, JiraTestExecutionDecider.class)
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
package org.keycloak.testsuite.arquillian.karaf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import javax.management.InstanceNotFoundException;
|
||||
import javax.management.MBeanServerConnection;
|
||||
import javax.management.ObjectName;
|
||||
import org.jboss.arquillian.container.osgi.jmx.ObjectNameFactory;
|
||||
import org.jboss.arquillian.container.osgi.karaf.managed.KarafManagedDeployableContainer;
|
||||
import org.jboss.arquillian.container.spi.client.container.LifecycleException;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tkyjovsk
|
||||
*/
|
||||
public class CustomKarafContainer extends KarafManagedDeployableContainer<CustomKarafContainerConfiguration> {
|
||||
|
||||
protected final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
private CustomKarafContainerConfiguration config;
|
||||
|
||||
protected MBeanServerConnection mbeanServer = null;
|
||||
protected ObjectName feature;
|
||||
|
||||
@Override
|
||||
public void start() throws LifecycleException {
|
||||
super.start();
|
||||
executePostStartCommands();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup(CustomKarafContainerConfiguration config) {
|
||||
super.setup(config);
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<CustomKarafContainerConfiguration> getConfigurationClass() {
|
||||
return CustomKarafContainerConfiguration.class;
|
||||
}
|
||||
|
||||
protected void executePostStartCommands() throws LifecycleException {
|
||||
try {
|
||||
mbeanServer = getMBeanServerConnection(500, TimeUnit.MILLISECONDS);
|
||||
} catch (TimeoutException ex) {
|
||||
throw new LifecycleException("JMX connection timed out.");
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
feature = ObjectNameFactory.create("org.apache.karaf:type=feature,name=root");
|
||||
try {
|
||||
mbeanServer.getObjectInstance(feature);
|
||||
} catch (InstanceNotFoundException infe) {
|
||||
try {
|
||||
feature = ObjectNameFactory.create("org.apache.karaf:type=features,name=root");
|
||||
mbeanServer.getObjectInstance(feature);
|
||||
} catch (InstanceNotFoundException infe2) {
|
||||
throw new RuntimeException("Feature MBean not found on server.");
|
||||
}
|
||||
}
|
||||
|
||||
featureMBean = getMBeanProxy(mbeanServer, feature, FeatureMBean.class, 30, TimeUnit.SECONDS);
|
||||
|
||||
log.info("Executing karaf after-start commands");
|
||||
for (String command : config.getCommandsAfterStartAsArray()) {
|
||||
String cmd = command.trim().split(" ")[0].trim();
|
||||
String param = command.trim().split(" ")[1].trim();
|
||||
log.info(String.format("command: %s, param: %s", cmd, param));
|
||||
if (cmd.equals("feature:repo-add") || cmd.equals("features:addurl")) {
|
||||
featureMBean.addRepository(param);
|
||||
} else if (cmd.equals("feature:repo-remove") || cmd.equals("features:removeurl")) {
|
||||
featureMBean.removeRepository(param);
|
||||
} else if (cmd.equals("feature:install") || cmd.equals("features:install")) {
|
||||
featureMBean.installFeature(param);
|
||||
} else if (cmd.equals("feature:uninstall") || cmd.equals("features:uninstall")) {
|
||||
featureMBean.uninstallFeature(param);
|
||||
} else {
|
||||
throw new RuntimeException(String.format("Unsupported command: '%s'. "
|
||||
+ "Supported commands on Karaf: 'feature:repo-add', 'feature:install'\n"
|
||||
+ "Supported commands on Fuse: 'features:addurl', 'features:install'", cmd));
|
||||
}
|
||||
}
|
||||
} catch (IOException | RuntimeException | TimeoutException ex) {
|
||||
stop();
|
||||
throw new LifecycleException("Error when executing karaf post-start commands.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
FeatureMBean featureMBean;
|
||||
|
||||
public interface FeatureMBean {
|
||||
|
||||
public void addRepository(String repository);
|
||||
|
||||
public void removeRepository(String repository);
|
||||
|
||||
public void installFeature(String feature);
|
||||
|
||||
public void uninstallFeature(String feature);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package org.keycloak.testsuite.arquillian.karaf;
|
||||
|
||||
import org.jboss.arquillian.container.osgi.karaf.managed.KarafManagedContainerConfiguration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tkyjovsk
|
||||
*/
|
||||
public class CustomKarafContainerConfiguration extends KarafManagedContainerConfiguration {
|
||||
|
||||
private String commandsAfterStart;
|
||||
|
||||
public String getCommandsAfterStart() {
|
||||
return commandsAfterStart;
|
||||
}
|
||||
|
||||
public String[] getCommandsAfterStartAsArray() {
|
||||
return getCommandsAfterStart().trim().split(",");
|
||||
}
|
||||
|
||||
public void setCommandsAfterStart(String commandsAfterStart) {
|
||||
this.commandsAfterStart = commandsAfterStart;
|
||||
}
|
||||
|
||||
}
|
|
@ -340,6 +340,32 @@
|
|||
<artifactId>infinispan-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>jline</groupId>
|
||||
<artifactId>jline</artifactId>
|
||||
<version>2.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.sshd</groupId>
|
||||
<artifactId>sshd-core</artifactId>
|
||||
<version>0.12.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.karaf.shell</groupId>
|
||||
<artifactId>org.apache.karaf.shell.console</artifactId>
|
||||
<version>3.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.karaf</groupId>
|
||||
<artifactId>org.apache.karaf.client</artifactId>
|
||||
<version>3.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.aries.jmx</groupId>
|
||||
<artifactId>org.apache.aries.jmx</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
|
Loading…
Reference in a new issue