Skip to content

Commit

Permalink
Added tests for eap-datagrid-subsystem
Browse files Browse the repository at this point in the history
  • Loading branch information
gbabcan committed Jun 6, 2018
1 parent cf9e092 commit 3c4b18e
Show file tree
Hide file tree
Showing 10 changed files with 645 additions and 7 deletions.
27 changes: 24 additions & 3 deletions eap-datagrid-subsystem/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Simple start

$EAP_HOME/bin/standalone.sh

4. use the CLI scipts to configure the datagrid subsystem and necessary dependencies
4. use the CLI scripts to configure the datagrid subsystem and necessary dependencies

$EAP_HOME/bin/jboss-cli.sh -c --file=$SRC_HOME/install1-standalone-local.cli
> restart the server !
Expand Down Expand Up @@ -66,7 +66,7 @@ To see the behaviour for JDG caches

$EAP_HOME/bin/standalone.sh [-c standalone-ha.xml]

4. use the CLI scipts to configure the datagrid subsystem and necessary dependencies
4. use the CLI scripts to configure the datagrid subsystem and necessary dependencies

$EAP_HOME/bin/jboss-cli.sh -c --file=$SRC_HOME/install1-standalone-clustered.cli
> restart the server !
Expand All @@ -91,11 +91,32 @@ To see the behaviour for JDG caches
Notes
=======
- You can simple rename the jboss-eap-datagrid-subsystem-AppWeb.war to any other name.war to simulate different applications.
If there are multiple applicatations they share the same cache!
If there are multiple applications they share the same cache!
- Caches are independent from application lifecycles. Undeploying any, or all, applications instances has no affect on a cache's lifecycle or data.
Even if the cache has no persistence the data will be kept as long as the server is not stopped.
- In this example the EAP server is not clustered, but if the cache is configured as clustered with the datagrid-jgroups subsystem and replicated or
distributed caches, the cache will be synchronized between different EAP instances if configured correctly.
- The respective JGroups subsystem needs to be defined for both EAP and JDG as the respective subsystems depend on different JGroups versions and provide different functionality.
- Also it is indespensable that the communication addresses and port for the JGroups subsystems need to be different. This prevent from cross-talking
which cause performance drawback, WARN message or error messages.


Run tests
========================
1. Prepare the server instances and keep EAP server running

2. Run `mvn test -Ptests-eap -DeapHome=$EAP_HOME`



Run tests in clustered cache mode
========================
1. Set variables
$EAP_SERVER_ZIP_PATH - path to jboss-eap.zip
$JDG_MODULES_ZIP_PATH - path to jboss-datagrid-eap-modules-library.zip

2. Prepare two EAP server instances or run prepareTwoEAP.sh from working directory (this will prepare two EAPs)

3. Save path to EAPs directories as $EAP_HOME1 and $EAP_HOME2

4. Run `mvn test -Ptests-eap-clustered -DeapHome1=$EAP_HOME1 -DeapHome2=$EAP_HOME2`
180 changes: 176 additions & 4 deletions eap-datagrid-subsystem/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@
<ear.plugin.version>2.10.1</ear.plugin.version>
<ear.plugin.version>2.10.1</ear.plugin.version>
<war.plugin.version>3.0.0</war.plugin.version>

<!---->
<version.maven.ant.plugin>1.7</version.maven.ant.plugin>
<version.jboss.spec.javaee.7.0>9.0.1.Final</version.jboss.spec.javaee.7.0>
<version.buildhelper.maven.plugin>1.7</version.buildhelper.maven.plugin>
<!-- test dependencies versions -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<browser>phantomjs</browser>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -93,17 +101,33 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- Define the version of JBoss' Java EE 7 APIs we want to import.
Any dependencies from org.wildfly.bom will have their version defined by this
BOM -->
<!-- JBoss distributes a complete set of Java EE 7 APIs including
a Bill of Materials (BOM). A BOM specifies the versions of a "stack" (or
a collection) of artifacts. We use this here so that we always get the correct
versions of artifacts. Here we use the jboss-javaee-7-with-tools stack.
The -with-tools means also versions of other artifacts like Arquillian. -->
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-ejb-client-bom</artifactId>
<version>${version.wildfly}</version>
<scope>import</scope>
<groupId>org.wildfly.bom</groupId>
<artifactId>jboss-javaee-7.0-wildfly-with-tools</artifactId>
<version>${version.jboss.spec.javaee.7.0}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<!-- export browser property to arquillian.xml -->
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>

<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand All @@ -116,5 +140,153 @@
</plugins>
</build>

<profiles>
<profile>
<id>skip.tests.by.default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
</profile>

<!-- This profile is for running tests on EAP standalone -->
<profile>
<id>tests-eap</id>
<activation>
<activeByDefault>false</activeByDefault>
<!--<property>-->
<!--<name>eapHome</name>-->
<!--</property>-->
</activation>
<dependencies>
<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<!-- This plugin will add the src/local/java source
folder -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${version.buildhelper.maven.plugin}</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/local/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!--Test only SubsystemTest for standalone mode-->
<includes>
<include>**/SubsystemTest*</include>
</includes>
<reportNameSuffix>tests-eap</reportNameSuffix>
<systemPropertyVariables>
<subsystem.war.directory>${basedir}/target</subsystem.war.directory>
<subsystem.war.file>${project.artifactId}.war</subsystem.war.file>
</systemPropertyVariables>
<systemProperties>
<arquillian.launch>jbossas-managed</arquillian.launch>
</systemProperties>
<!-- Added so selenium doesn't print it's INFO logs to console (there's a LOT of them -
like 5000 lines for each run) - they are instead appended (important when
there are multiple profiles) to <module>/target/jul-info.log (warnings are printed in console) -->
<argLine>-Djava.util.logging.config.file=${basedir}/web/src/test/resources/logging.properties</argLine>
</configuration>

</plugin>
</plugins>
</build>
</profile>

<!-- This profile is for running tests on clustered EAPs -->
<profile>
<id>tests-eap-clustered</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<!-- This plugin will add the src/local/java source
folder -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${version.buildhelper.maven.plugin}</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/local/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!--Test only SubsystemClusteredTest for clustered mode-->
<includes>
<include>**/SubsystemClusteredTest*</include>
</includes>
<reportNameSuffix>tests-eap-clustered</reportNameSuffix>
<systemPropertyVariables>
<subsystem.war.directory>${basedir}/target</subsystem.war.directory>
<subsystem.war.file>${project.artifactId}.war</subsystem.war.file>
</systemPropertyVariables>
<systemProperties>
<arquillian.launch>jbossas-cluster</arquillian.launch>
<!--<arquillian.launch>clustered-jbossas-managed-1</arquillian.launch>-->
<!--<arquillian.launch>clustered-jbossas-managed-2</arquillian.launch>-->
</systemProperties>
<!-- Added so selenium doesn't print it's INFO logs to console (there's a LOT of them -
like 5000 lines for each run) - they are instead appended (important when
there are multiple profiles) to <module>/target/jul-info.log (warnings are printed in console) -->
<argLine>-Djava.util.logging.config.file=${basedir}/web/src/test/resources/logging.properties</argLine>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>

51 changes: 51 additions & 0 deletions eap-datagrid-subsystem/prepareTwoEAP.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

export SRC_HOME=`pwd`

echo "Removing directories from previous run ..."
rm -rf eap-server
rm -rf jdg-modules
rm -rf eap1
rm -rf eap2

echo "Unzipping EAP server ..."
unzip -q ${EAP_SERVER_ZIP_PATH} -d eap-server
export EAP_HOME=`cd eap-server/*;pwd`
echo $EAP_HOME

echo "Unzipping JDG eap modules library ..."
unzip -q ${JDG_MODULES_ZIP_PATH} -d jdg-modules
export JDG_MODULES=`cd jdg-modules/*;pwd`
echo $JDG_MODULES

echo "Copying the JDG modules to EAP home directory"
cp -a "${JDG_MODULES}/modules" "${EAP_HOME}"

echo "Starting EAP server"
sh "${EAP_HOME}"/bin/standalone.sh > "${EAP_HOME}/server.log" &
sleep 10

echo "Executing install1-standalone-clustered.cli console scripts"
"${EAP_HOME}"/bin/jboss-cli.sh -c --file="${SRC_HOME}"/install1-standalone-clustered.cli
sleep 2

echo "Restarting EAP server"
(ps -ef | grep 'Standalone' | grep -v grep | awk '{print $2}' | xargs kill) > /dev/null 2>&1
sleep 2
sh "${EAP_HOME}"/bin/standalone.sh > "${EAP_HOME}/server.log" &
sleep 10

echo "Executing install2-standalone-clustered.cli console scripts"
"${EAP_HOME}"/bin/jboss-cli.sh -c --file="${SRC_HOME}"/install2-standalone-clustered.cli
sleep 5

echo "Stopping EAP server"
(ps -ef | grep 'Standalone' | grep -v grep | awk '{print $2}' | xargs kill) > /dev/null 2>&1

echo "Making the first copy of EAP server ..."
cp -R "${EAP_HOME}" eap1
export EAP_HOME1=`cd eap1;pwd`

echo "Making the second copy of EAP server ..."
cp -R "${EAP_HOME}" eap2
export EAP_HOME1=`cd eap2;pwd`
20 changes: 20 additions & 0 deletions eap-datagrid-subsystem/web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@

<url>http://maven.apache.org</url>
<packaging>war</packaging>
<properties>
<browser>phantomjs</browser>
</properties>

<dependencies>
<!-- add dependencies to all related EJB applications which are used.
Expand Down Expand Up @@ -68,6 +71,23 @@
<version>${version.org.infinispan}</version>
<scope>provided</scope>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.graphene</groupId>
<artifactId>graphene-webdriver</artifactId>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.jboss.as.quickstarts.datagrid.subsystem;

import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.importer.ZipImporter;
import org.jboss.shrinkwrap.api.spec.WebArchive;

import java.io.File;

public class Deployments {
private static final String ARCHIVE_NAME = System.getProperty("subsystem.war.file");
private static final String BUILD_DIRECTORY = System.getProperty("subsystem.war.directory");

public static WebArchive createDeployment() {
System.out.println(BUILD_DIRECTORY + '/' + ARCHIVE_NAME);
return ShrinkWrap.create(ZipImporter.class, ARCHIVE_NAME).importFrom(new File(BUILD_DIRECTORY + '/' + ARCHIVE_NAME))
.as(WebArchive.class);
}

}
Loading

0 comments on commit 3c4b18e

Please sign in to comment.