keycloak-aplcache

Merge pull request #745 from mposolda/docker Possibility

10/7/2014 7:42:08 AM

Details

diff --git a/testsuite/docker-cluster/as7/Dockerfile b/testsuite/docker-cluster/as7/Dockerfile
new file mode 100644
index 0000000..f216f84
--- /dev/null
+++ b/testsuite/docker-cluster/as7/Dockerfile
@@ -0,0 +1,13 @@
+FROM mposolda/as7
+
+ADD keycloak-as7-trigger.sh /keycloak-as7-trigger.sh
+RUN chmod u+x /keycloak-as7-trigger.sh
+
+ENV JBOSS_HOME /opt/as7
+ENV JBOSS_MODULES_HOME $JBOSS_HOME/modules
+ENV JBOSS_TYPE as7
+ENV NODE_PREFIX as
+
+EXPOSE 8787
+
+CMD [ "/keycloak-as7-trigger.sh" ]
\ No newline at end of file
diff --git a/testsuite/docker-cluster/as7/keycloak-as7-trigger.sh b/testsuite/docker-cluster/as7/keycloak-as7-trigger.sh
new file mode 100644
index 0000000..a59408c
--- /dev/null
+++ b/testsuite/docker-cluster/as7/keycloak-as7-trigger.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+chmod u+x /keycloak-docker-cluster/shared-files/keycloak-run-node.sh
+chmod u+x /keycloak-docker-cluster/shared-files/keycloak-base-prepare.sh
+chmod u+x /keycloak-docker-cluster/shared-files/deploy-examples.sh
+
+echo "Permissions changed. Triggering keycloak-run-node.sh"
+/keycloak-docker-cluster/shared-files/keycloak-run-node.sh
diff --git a/testsuite/docker-cluster/as7-image/Dockerfile b/testsuite/docker-cluster/as7-image/Dockerfile
new file mode 100644
index 0000000..6c17097
--- /dev/null
+++ b/testsuite/docker-cluster/as7-image/Dockerfile
@@ -0,0 +1,32 @@
+FROM jboss/wildfly
+
+USER root
+
+# Update yum and install required programs
+RUN yum install -y unzip && yum install -y wget && yum install -y mc && yum -y install nc
+RUN yum clean all
+
+# Download mysql driver
+RUN cd /tmp
+RUN wget http://search.maven.org/remotecontent?filepath=mysql/mysql-connector-java/5.1.32/mysql-connector-java-5.1.32.jar
+RUN mv *.jar mysql-connector-java-5.1.32.jar
+
+# Drop wildfly
+RUN rm -rf /opt/wildfly*
+
+ENV AS7_VERSION 7.1.1.Final
+
+# Download and unpack AS7 distribution
+RUN cd /opt
+RUN wget http://download.jboss.org/jbossas/7.1/jboss-as-$AS7_VERSION/jboss-as-$AS7_VERSION.zip
+RUN sleep 3
+RUN unzip -q jboss-as-$AS7_VERSION.zip
+
+# Make sure the distribution is available from a well-known place
+RUN mv jboss-as-$AS7_VERSION /opt/as7
+
+RUN rm -rf jboss-as-$AS7_VERSION.zip
+
+EXPOSE 8787
+
+CMD [ "/bin/bash" ]
diff --git a/testsuite/docker-cluster/assembly.xml b/testsuite/docker-cluster/assembly.xml
index d7c98cf..da0580d 100644
--- a/testsuite/docker-cluster/assembly.xml
+++ b/testsuite/docker-cluster/assembly.xml
@@ -23,8 +23,20 @@
             </excludes>
         </fileSet>
         <fileSet>
-            <directory>target/modules</directory>
-            <outputDirectory>modules</outputDirectory>
+            <directory>target/wildfly-adapter</directory>
+            <outputDirectory>wildfly-adapter</outputDirectory>
+        </fileSet>
+        <fileSet>
+            <directory>target/as7-adapter</directory>
+            <outputDirectory>as7-adapter</outputDirectory>
+        </fileSet>
+        <fileSet>
+            <directory>target/eap63-adapter</directory>
+            <outputDirectory>eap63-adapter</outputDirectory>
+        </fileSet>
+        <fileSet>
+            <directory>shared-files</directory>
+            <outputDirectory>shared-files</outputDirectory>
         </fileSet>
     </fileSets>
 </assembly>
diff --git a/testsuite/docker-cluster/eap63/Dockerfile b/testsuite/docker-cluster/eap63/Dockerfile
new file mode 100644
index 0000000..136bc38
--- /dev/null
+++ b/testsuite/docker-cluster/eap63/Dockerfile
@@ -0,0 +1,13 @@
+FROM mposolda/eap63
+
+ADD keycloak-eap63-trigger.sh /keycloak-eap63-trigger.sh
+RUN chmod u+x /keycloak-eap63-trigger.sh
+
+ENV JBOSS_HOME /opt/eap63
+ENV JBOSS_MODULES_HOME $JBOSS_HOME/modules/system/layers/base
+ENV JBOSS_TYPE eap63
+ENV NODE_PREFIX eap
+
+EXPOSE 8787
+
+CMD [ "/keycloak-eap63-trigger.sh" ]
\ No newline at end of file
diff --git a/testsuite/docker-cluster/eap63/keycloak-eap63-trigger.sh b/testsuite/docker-cluster/eap63/keycloak-eap63-trigger.sh
new file mode 100644
index 0000000..a59408c
--- /dev/null
+++ b/testsuite/docker-cluster/eap63/keycloak-eap63-trigger.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+chmod u+x /keycloak-docker-cluster/shared-files/keycloak-run-node.sh
+chmod u+x /keycloak-docker-cluster/shared-files/keycloak-base-prepare.sh
+chmod u+x /keycloak-docker-cluster/shared-files/deploy-examples.sh
+
+echo "Permissions changed. Triggering keycloak-run-node.sh"
+/keycloak-docker-cluster/shared-files/keycloak-run-node.sh
diff --git a/testsuite/docker-cluster/eap63-image/Dockerfile b/testsuite/docker-cluster/eap63-image/Dockerfile
new file mode 100644
index 0000000..fa8a626
--- /dev/null
+++ b/testsuite/docker-cluster/eap63-image/Dockerfile
@@ -0,0 +1,30 @@
+FROM jboss/wildfly
+
+USER root
+
+# Update yum and install required programs
+RUN yum install -y unzip && yum install -y wget && yum install -y mc && yum -y install nc
+RUN yum clean all
+
+# Download mysql driver
+RUN cd /tmp
+RUN wget http://search.maven.org/remotecontent?filepath=mysql/mysql-connector-java/5.1.32/mysql-connector-java-5.1.32.jar
+RUN mv *.jar mysql-connector-java-5.1.32.jar
+
+# Drop wildfly
+RUN rm -rf /opt/wildfly*
+
+# Download and unpack EAP63 distribution TODO: Check if it's an issue for EAP 6.3
+RUN cd /
+RUN wget https://dl.dropboxusercontent.com/u/5525920/jboss-eap-6.3.0.zip
+RUN sleep 3
+RUN unzip -q jboss-eap-6.3.0.zip
+
+# Make sure the distribution is available from a well-known place
+RUN mv jboss-eap-6.3 /opt/eap63
+
+RUN rm -rf jboss-eap-6.3.0.zip
+
+EXPOSE 8787
+
+CMD [ "/bin/bash" ]
\ No newline at end of file
diff --git a/testsuite/docker-cluster/fig.yml b/testsuite/docker-cluster/fig.yml
index 046d73b..e75c7c5 100644
--- a/testsuite/docker-cluster/fig.yml
+++ b/testsuite/docker-cluster/fig.yml
@@ -15,9 +15,9 @@ mysql:
       - /apachelogs
    ports:
       - "33306:3306"
-node:
+wfnode:
    build: wildfly
-   command: /keycloak-run-node.sh
+   command: /keycloak-wildfly-trigger.sh
    volumes:
       - target/keycloak-docker-cluster:/keycloak-docker-cluster
    volumes_from:
diff --git a/testsuite/docker-cluster/fig-as7.yml b/testsuite/docker-cluster/fig-as7.yml
new file mode 100644
index 0000000..9d11d69
--- /dev/null
+++ b/testsuite/docker-cluster/fig-as7.yml
@@ -0,0 +1,31 @@
+httpd:
+   build: httpd
+   ports:
+      - "8000:80"
+      - "10001:10001"
+   volumes_from:
+      - mysql
+mysql:
+   image: mysql:5.6.20
+   environment:
+      - MYSQL_ROOT_PASSWORD=mysecretpassword
+      - MYSQL_DATABASE=keycloak_db
+   volumes:
+      - /keycloak-docker-shared
+      - /apachelogs
+   ports:
+      - "33306:3306"
+asnode:
+   build: as7
+   command: /keycloak-as7-trigger.sh
+   volumes:
+      - target/keycloak-docker-cluster:/keycloak-docker-cluster
+   volumes_from:
+      - mysql
+   links:
+      - httpd:httpd
+      - mysql:mysql
+   ports:
+      - "8787"
+      - "8080"
+      - "9990"
\ No newline at end of file
diff --git a/testsuite/docker-cluster/fig-eap63.yml b/testsuite/docker-cluster/fig-eap63.yml
new file mode 100644
index 0000000..b7ed7fe
--- /dev/null
+++ b/testsuite/docker-cluster/fig-eap63.yml
@@ -0,0 +1,31 @@
+httpd:
+   build: httpd
+   ports:
+      - "8000:80"
+      - "10001:10001"
+   volumes_from:
+      - mysql
+mysql:
+   image: mysql:5.6.20
+   environment:
+      - MYSQL_ROOT_PASSWORD=mysecretpassword
+      - MYSQL_DATABASE=keycloak_db
+   volumes:
+      - /keycloak-docker-shared
+      - /apachelogs
+   ports:
+      - "33306:3306"
+eapnode:
+   build: eap63
+   command: /keycloak-eap63-trigger.sh
+   volumes:
+      - target/keycloak-docker-cluster:/keycloak-docker-cluster
+   volumes_from:
+      - mysql
+   links:
+      - httpd:httpd
+      - mysql:mysql
+   ports:
+      - "8787"
+      - "8080"
+      - "9990"
\ No newline at end of file
diff --git a/testsuite/docker-cluster/pom.xml b/testsuite/docker-cluster/pom.xml
index d552ddf..d3a4dbc 100644
--- a/testsuite/docker-cluster/pom.xml
+++ b/testsuite/docker-cluster/pom.xml
@@ -51,7 +51,21 @@
                                     <artifactId>keycloak-wildfly-adapter-dist</artifactId>
                                     <version>${project.version}</version>
                                     <type>zip</type>
-                                    <outputDirectory>${project.build.directory}</outputDirectory>
+                                    <outputDirectory>${project.build.directory}/wildfly-adapter</outputDirectory>
+                                </artifactItem>
+                                <artifactItem>
+                                    <groupId>org.keycloak</groupId>
+                                    <artifactId>keycloak-as7-adapter-dist</artifactId>
+                                    <version>${project.version}</version>
+                                    <type>zip</type>
+                                    <outputDirectory>${project.build.directory}/as7-adapter</outputDirectory>
+                                </artifactItem>
+                                <artifactItem>
+                                    <groupId>org.keycloak</groupId>
+                                    <artifactId>keycloak-eap6-adapter-dist</artifactId>
+                                    <version>${project.version}</version>
+                                    <type>zip</type>
+                                    <outputDirectory>${project.build.directory}/eap63-adapter</outputDirectory>
                                 </artifactItem>
                             </artifactItems>
                         </configuration>
diff --git a/testsuite/docker-cluster/README.md b/testsuite/docker-cluster/README.md
index 2aaa4bf..c51cd80 100644
--- a/testsuite/docker-cluster/README.md
+++ b/testsuite/docker-cluster/README.md
@@ -3,7 +3,7 @@ How to test Keycloak cluster with Docker
 Docker+Fig allows to easily setup and test the whole environment with:
 * Apache HTTPD 2.4 + modcluster 1.3 as Load Balancer
 * MySQL 5.6.1 as database
-* Various number of Keycloak cluster nodes running on WildFly (with "demo" examples deployed)
+* Various number of Keycloak cluster nodes running on WildFly with "demo" examples deployed. (See below for EAP 6.3 and AS7)
 
 You don't need to setup Apache with modcluster + MySQL on your laptop as Docker will do it for you and all will run in Docker containers.
 
@@ -42,7 +42,6 @@ be able to access Apache modCluster status page: [http://localhost:10001/mod_clu
 with deployed "auth-server.war" and few other WARs (keycloak demo). 
 
 Also you can access Keycloak admin console via loadBalancer on [http://localhost:8000/auth/admin](http://localhost:8000/auth/admin) and similarly Account mgmt. 
-TODO: Examples currently doesn't work and I am looking at it..
 
 MySQL can be directly accessed from your machine (if you have MySQL client installed):
 ```shell
@@ -74,7 +73,7 @@ Scale / more cluster nodes
 
 Run this in separate terminal to add more (in this case 2) cluster nodes:
 ```shell
-$ fig scale node=2
+$ fig scale wfnode=2
 ````
 
 Now it should be visible on mod_cluster_manager page that they are 2 nodes.
@@ -89,7 +88,7 @@ to see output of MySql and Keycloak server consoles.
 
 To see Apache and debug logs of keycloak server:
 ```shell
-$ fig run node /bin/bash
+$ fig run wfnode /bin/bash
 ````
   
 Then you're in shell inside docker container, which has some mounted volumes with apache logs and keycloak nodes. Apache logs are at:
@@ -133,3 +132,26 @@ In this case you might need to stop and remove existing containers. Then start f
 changed jars, then rebuild distribution and testsuite/docker-cluster 
 (or just copy changed JAR into $KEYCLOAK_HOME/testsuite/docker-cluster/target/keycloak-docker-cluster/deployments/auth-server.war/WEB-INF/lib if it's not adapter stuff. 
 But 'fig rm' is safer to call anyway)
+
+Test with Keycloak and examples on EAP 6.3
+------------------------------------------
+Steps are quite similar like for WildFly but we need to pass different file "fig-eap63.yml" instead of default "fig.yml" which is used for WildFly. 
+Also name of the node is "eapnode" instead of "wfnode". 
+ 
+So your commands will look like
+```shell 
+$ fig -f fig-eap63.yml build
+$ fig -f fig-eap63.yml up
+$ fig -f fig-eap63.yml scale eapnode=2
+```` 
+and viceversa.
+ 
+Test with Keycloak and examples on AS 7.1.1
+-------------------------------------------
+Also arguments need to be passed with different fig file and node name: TODO: AS7 cluster setup doesn't work correctly yet
+ 
+ ```shell 
+$ fig -f fig-as7.yml build
+$ fig -f fig-as7.yml up
+$ fig -f fig-as7.yml scale asnode=2
+````
\ No newline at end of file
diff --git a/testsuite/docker-cluster/shared-files/keycloak-base-prepare.sh b/testsuite/docker-cluster/shared-files/keycloak-base-prepare.sh
new file mode 100644
index 0000000..137e5c6
--- /dev/null
+++ b/testsuite/docker-cluster/shared-files/keycloak-base-prepare.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+# Copy MySQL driver
+cd /tmp
+mkdir -p mysql/main && mv /mysql-connector-java-5.1.32.jar mysql/main/
+cp /keycloak-docker-cluster/shared-files/mysql-module.xml mysql/main/module.xml
+mv mysql $JBOSS_MODULES_HOME/com/
+
+if [ $JBOSS_TYPE == "eap63" ]; then
+  EXT="as7";
+else
+  EXT=$JBOSS_TYPE;
+fi;
+
+sed -i -e "s/<extensions>/&\n <extension module=\"org.keycloak.keycloak-$EXT-subsystem\"\/>/" $JBOSS_HOME/standalone/configuration/standalone-ha.xml
+sed -i -e 's/<profile>/&\n <subsystem xmlns="urn:jboss:domain:keycloak:1.0"\/>/' $JBOSS_HOME/standalone/configuration/standalone-ha.xml && \
+sed -i -e 's/<security-domains>/&\n <security-domain name="keycloak">\n  <authentication>\n   <login-module code="org.keycloak.adapters.jboss.KeycloakLoginModule" flag="required"\/>\n  <\/authentication>\n <\/security-domain>/' $JBOSS_HOME/standalone/configuration/standalone-ha.xml && \
+sed -i -e 's/<drivers>/&\n <driver name="mysql" module="com.mysql">\n  <xa-datasource-class>com.mysql.jdbc.Driver<\/xa-datasource-class>\n  <driver-class>com.mysql.jdbc.Driver<\/driver-class>\n <\/driver>/' $JBOSS_HOME/standalone/configuration/standalone-ha.xml && \
+sed -i -e 's/<\/periodic-rotating-file-handler>/&\n <logger category=\"org.keycloak\">\n  <level name=\"DEBUG\" \/> \n <\/logger>\n <logger category=\"org.jboss.resteasy.core.ResourceLocator\">\n  <level name=\"ERROR\" \/> \n <\/logger>/' $JBOSS_HOME/standalone/configuration/standalone-ha.xml
+
+sed -i -e 's/<subsystem xmlns=\"urn:jboss:domain:infinispan:[0-9]\.[0-9]\">/&\n <cache-container name=\"keycloak\" jndi-name=\"infinispan\/Keycloak\" start=\"EAGER\"> \
+\n  <transport lock-timeout=\"60000\"\/>\n  <distributed-cache name=\"sessions\" mode=\"SYNC\" owners=\"2\" segments=\"60\"\/> \
+\n  <invalidation-cache name=\"realms\" mode=\"SYNC\"\/>\n <\/cache-container>/' $JBOSS_HOME/standalone/configuration/standalone-ha.xml
+
+sed -i "s|<mod-cluster-config .*>|<mod-cluster-config advertise-socket=\"modcluster\" proxy-list=\"\$\{httpd.proxyList\}\" proxy-url=\"\/\" balancer=\"mycluster\" advertise=\"false\" connector=\"ajp\" sticky-session=\"true\">|" $JBOSS_HOME/standalone/configuration/standalone-ha.xml
+
+sed -i "s|#JAVA_OPTS=\"\$JAVA_OPTS -agentlib:jdwp=transport=dt_socket|JAVA_OPTS=\"\$JAVA_OPTS -agentlib:jdwp=transport=dt_socket|" $JBOSS_HOME/bin/standalone.conf
+
+cp /keycloak-docker-cluster/shared-files/mysql-keycloak-ds.xml $JBOSS_HOME/standalone/deployments/
diff --git a/testsuite/docker-cluster/wildfly/Dockerfile b/testsuite/docker-cluster/wildfly/Dockerfile
index 3fde5bc..6aff50b 100644
--- a/testsuite/docker-cluster/wildfly/Dockerfile
+++ b/testsuite/docker-cluster/wildfly/Dockerfile
@@ -1,37 +1,25 @@
 FROM jboss/wildfly
 
 USER root
+
+# Update yum and install required programs
 RUN yum install -y unzip && yum install -y wget && yum install -y mc && yum -y install nc
 RUN yum clean all
 
+# Download mysql driver
 RUN cd /tmp
 RUN wget http://search.maven.org/remotecontent?filepath=mysql/mysql-connector-java/5.1.32/mysql-connector-java-5.1.32.jar
-RUN mv *.jar mysql-connector-java-5.1.32.jar
-
-RUN mkdir -p mysql/main && mv mysql-connector-java-5.1.32.jar mysql/main/ 
-ADD mysql-module.xml mysql/main/module.xml
-RUN mv mysql /opt/wildfly/modules/system/layers/base/com/
-
-RUN sed -i -e 's/<extensions>/&\n <extension module="org.keycloak.keycloak-wildfly-subsystem"\/>/' /opt/wildfly/standalone/configuration/standalone-ha.xml && \
-sed -i -e 's/<profile>/&\n <subsystem xmlns="urn:jboss:domain:keycloak:1.0"\/>/' /opt/wildfly/standalone/configuration/standalone-ha.xml && \
-sed -i -e 's/<security-domains>/&\n <security-domain name="keycloak">\n  <authentication>\n   <login-module code="org.keycloak.adapters.jboss.KeycloakLoginModule" flag="required"\/>\n  <\/authentication>\n <\/security-domain>/' /opt/wildfly/standalone/configuration/standalone-ha.xml && \
-sed -i -e 's/<drivers>/&\n <driver name="mysql" module="com.mysql">\n  <xa-datasource-class>com.mysql.jdbc.Driver<\/xa-datasource-class>\n <\/driver>/' /opt/wildfly/standalone/configuration/standalone-ha.xml && \
-sed -i -e 's/<\/periodic-rotating-file-handler>/&\n <logger category=\"org.keycloak\">\n  <level name=\"DEBUG\" \/> \n <\/logger>/' /opt/wildfly/standalone/configuration/standalone-ha.xml
+RUN mv *.jar /mysql-connector-java-5.1.32.jar
 
-RUN sed -i -e 's/<subsystem xmlns=\"urn:jboss:domain:infinispan:2\.0\">/&\n <cache-container name=\"keycloak\" jndi-name=\"infinispan\/Keycloak\" start=\"EAGER\"> \
-\n  <transport lock-timeout=\"60000\"\/>\n  <distributed-cache name=\"sessions\" mode=\"SYNC\" owners=\"2\" segments=\"60\"\/> \
-\n  <invalidation-cache name=\"realms\" mode=\"SYNC\"\/>\n <\/cache-container>/' /opt/wildfly/standalone/configuration/standalone-ha.xml
+ADD keycloak-wildfly-trigger.sh /keycloak-wildfly-trigger.sh
+RUN chmod u+x /keycloak-wildfly-trigger.sh
 
-RUN sed -i "s|<mod-cluster-config .*>|<mod-cluster-config advertise-socket=\"modcluster\" proxy-list=\"\$\{httpd.proxyList\}\" proxy-url=\"\/\" balancer=\"mycluster\" advertise=\"false\" connector=\"ajp\" sticky-session=\"true\">|" /opt/wildfly/standalone/configuration/standalone-ha.xml
-
-RUN sed -i "s|#JAVA_OPTS=\"\$JAVA_OPTS -agentlib:jdwp=transport=dt_socket|JAVA_OPTS=\"\$JAVA_OPTS -agentlib:jdwp=transport=dt_socket|" /opt/wildfly/bin/standalone.conf
-
-ADD mysql-keycloak-ds.xml /opt/wildfly/standalone/deployments/
-ADD keycloak-run-node.sh /keycloak-run-node.sh
-RUN chmod u+x /keycloak-run-node.sh
-ADD deploy-examples.sh /deploy-examples.sh
-RUN chmod u+x /deploy-examples.sh
+ENV JBOSS_HOME /opt/wildfly-8.1.0.Final
+ENV JBOSS_MODULES_HOME $JBOSS_HOME/modules/system/layers/base
+ENV JBOSS_TYPE wildfly
+ENV NODE_PREFIX wf
 
 EXPOSE 8787
 
-CMD [ "/keycloak-run-node.sh" ]
+CMD [ "/keycloak-wildfly-trigger.sh" ]
+
diff --git a/testsuite/docker-cluster/wildfly/keycloak-wildfly-trigger.sh b/testsuite/docker-cluster/wildfly/keycloak-wildfly-trigger.sh
new file mode 100644
index 0000000..a59408c
--- /dev/null
+++ b/testsuite/docker-cluster/wildfly/keycloak-wildfly-trigger.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+chmod u+x /keycloak-docker-cluster/shared-files/keycloak-run-node.sh
+chmod u+x /keycloak-docker-cluster/shared-files/keycloak-base-prepare.sh
+chmod u+x /keycloak-docker-cluster/shared-files/deploy-examples.sh
+
+echo "Permissions changed. Triggering keycloak-run-node.sh"
+/keycloak-docker-cluster/shared-files/keycloak-run-node.sh