keycloak-aplcache

KEYCLOAK-5968 Move configuration of Infinispan server from

12/19/2017 9:42:26 AM

Details

diff --git a/testsuite/performance/infinispan/configure.xml b/testsuite/performance/infinispan/configure.xml
new file mode 100644
index 0000000..2484ac7
--- /dev/null
+++ b/testsuite/performance/infinispan/configure.xml
@@ -0,0 +1,79 @@
+<project name="keycloak-server-configuration" basedir="." >
+
+    <target name="check-configuration-state">
+        <available property="configured" file="${infinispan.unpacked.home}/../configured"/>
+        <available property="management.configured" file="${infinispan.unpacked.home}/../management-configured"/>
+        <echo>configured: ${configured}</echo>
+        <echo>management.configured: ${management.configured}</echo>
+    </target>
+    
+    <target name="configure-infinispan" unless="configured" depends="check-configuration-state">
+        <!-- configuration common for both DC sites-->
+        <chmod perm="ug+x">
+            <fileset dir="${infinispan.unpacked.home}/bin">
+                <include name="*.sh"/>
+            </fileset>
+        </chmod>
+        <copy file="${scripts.dir}/jboss-cli/add-private-network-interface.cli" todir="${infinispan.unpacked.home}/bin" />
+        <exec executable="./${jboss.cli.script}" dir="${infinispan.unpacked.home}/bin" failonerror="true">
+            <arg value="--file=add-private-network-interface.cli"/>
+        </exec>
+
+        <!-- DC-specific configuration (dc1 and dc2) -->
+        <copy file="${infinispan.unpacked.home}/standalone/configuration/clustered.xml"
+              tofile="${infinispan.unpacked.home}/standalone/configuration/clustered-dc1.xml" />
+        <move file="${infinispan.unpacked.home}/standalone/configuration/clustered.xml"
+              tofile="${infinispan.unpacked.home}/standalone/configuration/clustered-dc2.xml" />
+        <copy file="${scripts.dir}/jboss-cli/add-keycloak-caches.cli" tofile="${infinispan.unpacked.home}/bin/add-keycloak-caches-dc1.cli" >
+            <filterset>
+                <filter token="LOCAL_SITE" value="dc1"/>
+                <filter token="REMOTE_SITE" value="dc2"/>
+            </filterset>
+        </copy>
+        <copy file="${scripts.dir}/jboss-cli/add-keycloak-caches.cli" tofile="${infinispan.unpacked.home}/bin/add-keycloak-caches-dc2.cli" >
+            <filterset>
+                <filter token="LOCAL_SITE" value="dc2"/>
+                <filter token="REMOTE_SITE" value="dc1"/>
+            </filterset>
+        </copy>
+        <exec executable="./${jboss.cli.script}" dir="${infinispan.unpacked.home}/bin" failonerror="true">
+            <arg value="--file=add-keycloak-caches-dc1.cli"/>
+        </exec>
+        <exec executable="./${jboss.cli.script}" dir="${infinispan.unpacked.home}/bin" failonerror="true">
+            <arg value="--file=add-keycloak-caches-dc2.cli"/>
+        </exec>
+
+        <!--cleanup-->        
+        <delete dir="${infinispan.unpacked.home}/standalone/configuration/standalone_xml_history"/>
+        <delete dir="${infinispan.unpacked.home}/standalone/log"/>
+        <delete dir="${infinispan.unpacked.home}/standalone/data"/>
+        <delete dir="${infinispan.unpacked.home}/standalone/tmp"/>
+        <touch file="${infinispan.unpacked.home}/../configured"/>
+    </target>
+
+    <target name="add-management-user" unless="management.configured" depends="check-configuration-state">
+        <echo>Adding management user: `${management.user}`</echo>
+        <exec executable="./${add.user.script}" dir="${infinispan.unpacked.home}/bin" failonerror="true">
+            <arg value="-u"/>
+            <arg value="${management.user}"/>
+            <arg value="-p"/>
+            <arg value="${management.user.password}"/>
+        </exec>
+        <touch file="${infinispan.unpacked.home}/../management-configured"/>
+    </target>
+    
+    <target name="prepare-docker-config">
+        <copy todir="${infinispan.unpacked.home}/../docker" overwrite="false">
+            <fileset dir="${scripts.dir}">
+                <include name="Dockerfile"/>
+                <include name="*.sh"/>
+            </fileset>
+        </copy>
+        <copy todir="${infinispan.unpacked.home}/../docker/infinispan-server" overwrite="false">
+            <fileset dir="${infinispan.unpacked.home}">
+                <exclude name="bin/*.cli"/>
+            </fileset>
+        </copy>
+    </target>
+
+</project>
diff --git a/testsuite/performance/infinispan/pom.xml b/testsuite/performance/infinispan/pom.xml
new file mode 100644
index 0000000..85d7a30
--- /dev/null
+++ b/testsuite/performance/infinispan/pom.xml
@@ -0,0 +1,157 @@
+<?xml version="1.0"?>
+<!--
+~ 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <groupId>org.keycloak.testsuite</groupId>
+        <artifactId>performance</artifactId>
+        <version>4.0.0.CR1-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>performance-keycloak-infinispan-server</artifactId>
+    <name>Keycloak Performance TestSuite - Infinispan Server</name>
+    <packaging>pom</packaging>
+    
+    <properties>
+        <infinispan.groupId>org.infinispan.server</infinispan.groupId>
+        <infinispan.artifactId>infinispan-server-build</infinispan.artifactId>
+        <!--infinispan.version is located in the root pom.xml--> 
+        <infinispan.unpacked.folder.name>infinispan-server-${infinispan.version}</infinispan.unpacked.folder.name>
+        <infinispan.unpacked.home>${project.build.directory}/${infinispan.unpacked.folder.name}</infinispan.unpacked.home>
+        
+        <script.extension>sh</script.extension>
+        <jboss.cli.script>ispn-cli.${script.extension}</jboss.cli.script>
+        <add.user.script>add-user.${script.extension}</add.user.script>
+        
+        <scripts.dir>${project.build.scriptSourceDirectory}</scripts.dir>
+        <resources.dir>${project.basedir}/src/main/resources</resources.dir>
+        
+        <skip.add.management.user>true</skip.add.management.user>
+        <skip.docker.config>false</skip.docker.config>
+    </properties>
+
+    <build>
+        
+        <plugins>
+            <plugin>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>unpack-infinispan-servers</id>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>unpack</goal>
+                        </goals>
+                        <configuration>
+                            <overWriteIfNewer>true</overWriteIfNewer>
+                            <artifactItems>
+                                <artifactItem>
+                                    <groupId>${infinispan.groupId}</groupId>
+                                    <artifactId>${infinispan.artifactId}</artifactId>
+                                    <version>${infinispan.version}</version>
+                                    <type>zip</type>
+                                    <outputDirectory>${project.build.directory}</outputDirectory>
+                                </artifactItem>
+                            </artifactItems>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-antrun-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>configure-infinispan</id>
+                        <phase>process-resources</phase>
+                        <goals>
+                            <goal>run</goal>
+                        </goals>
+                        <configuration>
+                            <target>
+                                <ant antfile="configure.xml" target="configure-infinispan" />
+                            </target>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>add-management-user</id>
+                        <phase>process-resources</phase>
+                        <goals>
+                            <goal>run</goal>
+                        </goals>
+                        <configuration>
+                            <skip>${skip.add.management.user}</skip>
+                            <target>
+                                <ant antfile="configure.xml" target="add-management-user" />
+                            </target>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>prepare-docker-config</id>
+                        <phase>process-resources</phase>
+                        <goals>
+                            <goal>run</goal>
+                        </goals>
+                        <configuration>
+                            <skip>${skip.docker.config}</skip>
+                            <target>
+                                <ant antfile="configure.xml" target="prepare-docker-config" />
+                            </target>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+    
+    <profiles>
+        
+        <profile>        
+            <id>add-management-user</id>
+            <activation>
+                <property>
+                    <name>management.user</name>
+                </property>
+            </activation>
+            <properties>
+                <skip.add.management.user>false</skip.add.management.user>
+                <!--it seems to be necessary to explicitly re-set these properties here
+                otherwise the antrun plugin won't pick them up-->
+                <management.user>${management.user}</management.user>
+                <management.user.password>${management.user.password}</management.user.password>
+            </properties>
+        </profile>
+
+        <profile>
+            <id>windows</id>
+            <activation>
+                <os>
+                    <family>windows</family>
+                </os>
+            </activation>
+            <properties>
+                <script.extension>ps1</script.extension>
+            </properties>
+        </profile>
+        
+    </profiles>
+    
+</project>
\ No newline at end of file
diff --git a/testsuite/performance/infinispan/src/main/scripts/Dockerfile b/testsuite/performance/infinispan/src/main/scripts/Dockerfile
new file mode 100644
index 0000000..3001c15
--- /dev/null
+++ b/testsuite/performance/infinispan/src/main/scripts/Dockerfile
@@ -0,0 +1,18 @@
+FROM jboss/base-jdk:8
+
+ENV LAUNCH_JBOSS_IN_BACKGROUND 1
+ENV CONFIGURATION clustered.xml
+ENV INFINISPAN_SERVER_HOME /opt/jboss/infinispan-server
+WORKDIR $INFINISPAN_SERVER_HOME
+
+USER root
+RUN yum -y install iproute
+
+ADD infinispan-server ./
+ADD *.sh /usr/local/bin/
+RUN chown -R jboss .; chgrp -R jboss .; chmod -R -v ug+x bin/*.sh ; chmod -R -v ug+x /usr/local/bin/ 
+
+USER jboss
+EXPOSE 7600 8080 8181 8888 9990 11211 11222 57600
+HEALTHCHECK  --interval=5s --timeout=5s --retries=12 CMD ["infinispan-healthcheck.sh"]
+ENTRYPOINT [ "docker-entrypoint-custom.sh" ]
diff --git a/testsuite/performance/pom.xml b/testsuite/performance/pom.xml
index b1b778d..089fcd0 100644
--- a/testsuite/performance/pom.xml
+++ b/testsuite/performance/pom.xml
@@ -39,6 +39,7 @@
     <modules>
         <module>keycloak</module>
         <module>load-balancer/wildfly-modcluster</module>
+        <module>infinispan</module>
         <module>tests</module>
     </modules>
     
diff --git a/testsuite/performance/tests/pom.xml b/testsuite/performance/tests/pom.xml
index 7173a17..e12cdba 100644
--- a/testsuite/performance/tests/pom.xml
+++ b/testsuite/performance/tests/pom.xml
@@ -339,10 +339,12 @@
                                         <copy todir="${project.build.directory}/docker-compose" overwrite="false" >
                                             <fileset dir="${project.basedir}/..">
                                                 <include name="db/**"/>
-                                                <include name="infinispan/**"/>
                                                 <include name="monitoring/**"/>
                                             </fileset>
                                         </copy>
+                                        <copy todir="${project.build.directory}/docker-compose/infinispan" overwrite="false" >
+                                            <fileset dir="${project.basedir}/../infinispan/target/docker"/>
+                                        </copy>
                                         <copy todir="${project.build.directory}/docker-compose/load-balancer/wildfly-modcluster" overwrite="false" >
                                             <fileset dir="${project.basedir}/../load-balancer/wildfly-modcluster/target/docker"/>
                                         </copy>
diff --git a/testsuite/performance/tests/src/main/docker-compose/crossdc/docker-compose-base.yml b/testsuite/performance/tests/src/main/docker-compose/crossdc/docker-compose-base.yml
index 2b6a252..2d6c95f 100644
--- a/testsuite/performance/tests/src/main/docker-compose/crossdc/docker-compose-base.yml
+++ b/testsuite/performance/tests/src/main/docker-compose/crossdc/docker-compose-base.yml
@@ -30,20 +30,15 @@ networks:
 services:
 
     infinispan_dc1:
-        build: 
-            context: infinispan
-            args:
-                LOCAL_SITE: dc1
-                REMOTE_SITE: dc2
-                MANAGEMENT_USER: ${MANAGEMENT_USER}
-                MANAGEMENT_USER_PASS: ${MANAGEMENT_USER_PASS}
-        image: keycloak_test_infinispan_dc1:${KEYCLOAK_VERSION:-latest}
+        build: infinispan
+        image: keycloak_test_infinispan:${KEYCLOAK_VERSION:-latest}
         cpuset: ${INFINISPAN_DC1_CPUSET:-1}
         mem_limit: ${INFINISPAN_MEMLIMIT:-1500m}
         networks:
             - ispn_replication
             - dc1_keycloak
         environment:
+            CONFIGURATION: clustered-dc1.xml
             PUBLIC_SUBNET: 10.1.1.0/24
             PRIVATE_SUBNET: 10.0.4.0/24
             MGMT_USER: admin
@@ -54,14 +49,8 @@ services:
             - "9990"
 
     infinispan_dc2:
-        build: 
-            context: infinispan
-            args:
-                LOCAL_SITE: dc2
-                REMOTE_SITE: dc1
-                MANAGEMENT_USER: ${MANAGEMENT_USER}
-                MANAGEMENT_USER_PASS: ${MANAGEMENT_USER_PASS}
-        image: keycloak_test_infinispan_dc2:${KEYCLOAK_VERSION:-latest}
+        build: infinispan
+        image: keycloak_test_infinispan:${KEYCLOAK_VERSION:-latest}
         depends_on:
             infinispan_dc1:
                 condition: service_healthy
@@ -71,6 +60,7 @@ services:
             - ispn_replication
             - dc2_keycloak
         environment:
+            CONFIGURATION: clustered-dc2.xml
             PUBLIC_SUBNET: 10.2.1.0/24
             PRIVATE_SUBNET: 10.0.4.0/24
             MGMT_USER: admin