Skip to content

Commit

Permalink
Jenkins jobs - JPA.WDF, MOXY test environment fix (#693)
Browse files Browse the repository at this point in the history
This is fix for JPA.WDF, MOXY tests.
JPA.WDF tests - JEE server platform is required there, WildFly platform is added to JPA tests
MOXY tests - JMockit 1.10 is required there

Signed-off-by: Radek Felcman <[email protected]>
  • Loading branch information
rfelcman authored Jan 29, 2020
1 parent 970e3f0 commit 9a8ec38
Show file tree
Hide file tree
Showing 3 changed files with 305 additions and 1 deletion.
2 changes: 1 addition & 1 deletion etc/jenkins/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mkdir -p $HOME/extension.lib.external/mavenant
#DOWNLOAD SOME DEPENDENCIES
wget -nc https://repo1.maven.org/maven2/junit/junit/4.12/junit-4.12.jar -O $HOME/extension.lib.external/junit-4.12.jar
wget -nc https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar -O $HOME/extension.lib.external/hamcrest-core-1.3.jar
wget -nc https://repo1.maven.org/maven2/org/jmockit/jmockit/1.35/jmockit-1.35.jar -O $HOME/extension.lib.external/jmockit-1.35.jar
wget -nc https://repo1.maven.org/maven2/org/jmockit/jmockit/1.10/jmockit-1.10.jar -O $HOME/extension.lib.external/jmockit-1.10.jar
wget -nc https://repo1.maven.org/maven2/org/hibernate/validator/hibernate-validator/6.0.7.Final/hibernate-validator-6.0.7.Final.jar -O $HOME/extension.lib.external/hibernate-validator-6.0.7.Final.jar
wget -nc https://repo1.maven.org/maven2/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar -O $HOME/extension.lib.external/jboss-logging-3.3.0.Final.jar
wget -nc https://repo1.maven.org/maven2/org/glassfish/javax.el/3.0.1-b08/javax.el-3.0.1-b08.jar -O $HOME/extension.lib.external/javax.el-3.0.1-b08.jar
Expand Down
50 changes: 50 additions & 0 deletions jpa/eclipselink.jpa.test/wildfly.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#
# Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0,
# or the Eclipse Distribution License v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#

## JBoss Server Testing Environment Properties.

## Standard server properties.
server.platform=JBoss
server.platform.class=jboss-platform
server.factory=org.jboss.naming.remote.client.InitialContextFactory
java.naming.factory.url.pkgs=org.jboss.ejb.client.naming
server.depend=jboss-client.jar

wildfly.server=${wildfly.home}
server.lib=${wildfly.home}/bin/client
server.url=http-remoting://localhost:8080/
server.user=admin
server.pwd=admin

## WildFly specific properties.
wildfly.home=/Users/lukas/java/wildfly-11.0.0.Final
wildfly.config=standalone-full.xml

server.testrunner=TestRunner!org.eclipse.persistence.testing.framework.server.TestRunner
server.testrunner1=TestRunner1!org.eclipse.persistence.testing.framework.server.TestRunner1
server.testrunner2=TestRunner2!org.eclipse.persistence.testing.framework.server.TestRunner2
server.testrunner3=TestRunner3!org.eclipse.persistence.testing.framework.server.TestRunner3
server.testrunner4=TestRunner4!org.eclipse.persistence.testing.framework.server.TestRunner4
server.testrunner5=TestRunner5!org.eclipse.persistence.testing.framework.server.TestRunner5
server.testrunner6=TestRunner6!org.eclipse.persistence.testing.framework.server.TestRunner6
server.testrunner.wdf=ServerTestRunner/remote-org.eclipse.persistence.testing.framework.wdf.server.ServerTestRunner
persistence10.jar=${jboss.home}/common/lib/ejb3-persistence.jar

# The following only for JBoss-eap 5.0 testing,and it actually point to JPA1.0 unsigned jar (javax.persistence_unsigned_for_testing_1.0.0.jar),
# and this jar will be added at very beginning of client classpath
server.persistence20.lib=${jboss.server}/lib
server.persistence20.jar=${persistence10.jar}

wildfly.jtaDs.name=EclipseLinkDS
wildfly.nonJtaDs.name=ELNonJTADS
wildfly.jtaDs.jndi=java:/${wildfly.jtaDs.name}
wildfly.nonJtaDs.jndi=java:/${wildfly.nonJtaDs.name}
254 changes: 254 additions & 0 deletions jpa/eclipselink.jpa.test/wildfly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
<!--
Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0,
or the Eclipse Distribution License v. 1.0 which is available at
http://www.eclipse.org/org/documents/edl-v10.php.
SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
-->

<!--
Contributors:
Lukas - initial API and implementation
-->

<!-- This ant project includes the following tasks:
- wildfly-install : install binary and drivers on the server
- wildfly-setup : creates connection pools and prepares environment for tests
- wildfly-reset : removes connection pool, cleans up installation
- wildfly-start : starts server
- wildfly-stop : stops server
- wildfly-deploy : deploys ear
- wildfly-undeploy : undeploys ear
It requires some configuration of the wildfly.properties, it should be run through antbuild.xml, not directly.
To connect to the wildfly admin console use http://localhost:9990/console/App.html,
this may be useful for debugging deployment failures.
Sometimes if a test or deployment fails, your server gets screwed up
and you need to re-install your domain (ant -f antbuld.xml server-reset server-install server-setup).
-->
<!--
* Ant naming conventions:
* - regardless of the actual OS platform,'/' is the directory separator
* (Ant will convert as appropriate).
* - multi-word properties use periods '.'
* - properties ending in .jar define jarfile names only (no path)
* - properties ending in .lib are fully qualified jars (path and filename)
* - properties ending in .dir are directory paths
* - properties ending in .path are path refid names (classpath fragments)
* - multi-word targets use hyphens '-'
* - targets beginning with test- are reserved for high level test targets,
* and are used in test results parsing
* - targets typically use the form <action>-<object>-<type> (ie. package-bundle-zip)
* - multi-word macros use underscores '_'
* - multi-word macro attributes are concatenated
* e.g. 'runpathref'
* - multi-word tasks (taskdef) names are concatenated
* e.g. 'validateconnection'
* - OS environment variables are in ALLCAPS and have 'env' as a prefix
* e.g. ${env.XXX}.
* - Ant properties are lower case.
-->
<project name="Eclipse Persistence Services JPA Wildfly Testing" basedir=".">

<property name="env" environment="env" value="env"/>
<!-- Allows a user to overide certain user specific properties. -->
<property file="${user.home}/wildfly.properties"/>
<property file="./wildfly.properties"/>

<property name="jdbc.driver.lib" value="${jdbc.driver.jar}"/>
<property name="w.jpa.api.jar" value="${persistence22.jar}"/>
<path id="eclipselink.lib">
<fileset dir="${jpatest.basedir}/../../plugins/">
<include name="org.eclipse.persistence.*"/>
<exclude name="*.source_*"/>
</fileset>
<pathelement location="${jpatest.2.sdo.plugins.dir}/${commonj.sdo.jar}"/>
</path>

<!-- Set db name by check db.driver -->
<condition property="db.name" value="oracle">
<contains string="${db.driver}" substring="oracle"/>
</condition>

<condition property="db.name" value="mysql">
<contains string="${db.driver}" substring="mysql"/>
</condition>

<condition property="db.name" value="mssql">
<contains string="${db.driver}" substring="sqlserver"/>
</condition>

<condition property="db.name" value="db2">
<contains string="${db.driver}" substring="db2"/>
</condition>

<condition property="db.name" value="sybase">
<contains string="${db.driver}" substring="sybase"/>
</condition>

<condition property="is.eap">
<contains string="${server.version}" substring="eap"/>
</condition>

<!-- JVM used to run tests -->
<property name="test.junit.jvm" value="${env.JAVA_HOME}"/>
<property name="test.junit.jvm.exec" value="${test.junit.jvm}/bin/java"/>

<property name="wildfly.modules.dir" location="${wildfly.home}/modules/system/layers/base"/>

<target name="-backup-init">
<condition property="do.backup">
<not>
<available file="${wildfly.modules.dir}/org/eclipse/persistence/main/module.xml.bak"/>
</not>
</condition>
</target>

<target name="-do-backup" description="Backup org.eclipse.persistence module definition." depends="-backup-init" if="do.backup">
<move file="${wildfly.modules.dir}/org/eclipse/persistence/main/module.xml" tofile="${wildfly.modules.dir}/org/eclipse/persistence/main/module.xml.bak"/>
<copy file="${wildfly.modules.dir}/javax/persistence/api/main/module.xml" tofile="${wildfly.modules.dir}/javax/persistence/api/main/module.xml.bak"/>
</target>

<target name="-wildfly-cli-init" description="Initialize 'cli' macro for jboss-cli.">
<condition property="is.windows" value="true">
<os family="windows"/>
</condition>
<condition property="is.unix" value="true">
<os family="unix"/>
</condition>
<condition property="suffix" value="bat">
<isset property="is.windows"/>
</condition>
<condition property="suffix" value="sh">
<isset property="is.unix"/>
</condition>

<macrodef name="cli" description="Run ${wildfly.home}/bin/jboss-cli.${suffix}">
<attribute name="command"/>
<sequential>
<echo>Executing command: @{command}</echo>
<exec executable="${wildfly.home}/bin/jboss-cli.${suffix}" dir="${basedir}" resultproperty="cli.result">
<env key="JAVA_HOME" value="${test.junit.jvm}"/>
<env key="JBOSS_HOME" value="${wildfly.home}"/>
<arg value="--connect"/>
<arg value="command=@{command}"/>
</exec>
<echo> ==> Execution result: ${cli.result}</echo>
</sequential>
</macrodef>
</target>

<target name="wildfly-install" description="Install binaries on the server." depends="-do-backup,-wildfly-cli-init">
<pathconvert property="eclipselink.jars" refid="eclipselink.lib" pathsep=":">
<flattenmapper/>
</pathconvert>
<pathconvert property="junit.jars" pathsep=":">
<path path="${junit.lib}"/>
<flattenmapper/>
</pathconvert>
<xslt style="resource/wildfly/eclipselink-module-template.xsl" in="${wildfly.modules.dir}/org/eclipse/persistence/main/module.xml.bak" out="${wildfly.modules.dir}/org/eclipse/persistence/main/module.xml" force="true">
<param name="resources" expression="${eclipselink.jars}"/>
<param name="dependencies" expression="com.${db.name}:junit.junit:javax.json.api"/>
</xslt>
<copy todir="${wildfly.modules.dir}/org/eclipse/persistence/main" flatten="true">
<path refid="eclipselink.lib"/>
</copy>
<replaceregexp file="${wildfly.modules.dir}/javax/persistence/api/main/module.xml" match="hibernate-.*jar" replace="${w.jpa.api.jar}" byline="true"/>
<copy todir="${wildfly.modules.dir}/javax/persistence/api/main" file="${jpatest.2.jpa.plugins.dir}/${w.jpa.api.jar}" verbose="true"/>

<antcall target="wildfly-start"/>
<!-- JDBC Driver -->
<cli command="module add --name=com.${db.name} --resources=${jdbc.driver.lib} --dependencies=javax.api,javax.transaction.api --module-root-dir=${wildfly.modules.dir}"/>
<!-- JUnit -->
<cli command="module add --name=junit.junit --resources=${junit.lib} --module-root-dir=${wildfly.modules.dir}"/>

<cli command=":reload"/>
</target>

<target name="wildfly-setup" description="Create datasources and JDBC driver definition on the Wildfly server." depends="-wildfly-cli-init">
<cli command="/subsystem=datasources/jdbc-driver=${db.name}Driver:add(driver-name=${db.name}Driver,driver-module-name=com.${db.name},driver-class-name=${db.driver})"/>
<cli command=":reload"/>

<property name="w.ds.name" value="${wildfly.jtaDs.name}${db.name}Pool"/>
<echo>Setting up ${w.ds.name}</echo>
<cli command="data-source add --jndi-name=${wildfly.jtaDs.jndi} --name=${w.ds.name} --connection-url=${db.url} --driver-name=${db.name}Driver --user-name=${db.user} —-password=${db.pwd} --jta=true --enabled=true"/>
<cli command="/subsystem=datasources/data-source=${w.ds.name}:write-attribute(name=password,value=${db.pwd})"/>

<property name="w.nonjtads.name" value="${wildfly.nonJtaDs.name}${db.name}Pool"/>
<echo>Setting up ${w.nonjtads.name}</echo>
<cli command="data-source add --jndi-name=${wildfly.nonJtaDs.jndi} --name=${w.nonjtads.name} --connection-url=${db.url} --driver-name=${db.name}Driver --user-name=${db.user} —-password=${db.pwd} --jta=true --enabled=true"/>
<cli command="/subsystem=datasources/data-source=${w.nonjtads.name}:write-attribute(name=password,value=${db.pwd})"/>
<cli command=":reload"/>

<cli command="/system-property=eclipselink.archive.factory:add(value=org.jipijapa.eclipselink.JBossArchiveFactoryImpl)"/>
<cli command=":reload"/>
</target>

<target name="wildfly-reset" description="Revert all modifications on the server done by install/setup." depends="-wildfly-cli-init,wildfly-start">
<!-- DataSources -->
<cli command="data-source remove --name=${wildfly.jtaDs.name}${db.name}Pool"/>
<cli command="data-source remove --name=${wildfly.nonJtaDs.name}${db.name}Pool"/>
<cli command=":reload"/>

<cli command="/subsystem=datasources/jdbc-driver=${db.name}Driver:remove"/>
<cli command="/system-property=eclipselink.archive.factory:remove"/>
<cli command=":reload"/>

<!-- JDBC Driver -->
<cli command="module remove --name=com.${db.name} --module-root-dir=${wildfly.modules.dir}"/>
<!-- JUnit -->
<cli command="module remove --name=junit.junit --module-root-dir=${wildfly.modules.dir}"/>

<move file="${wildfly.modules.dir}/javax/persistence/api/main/module.xml.bak" tofile="${wildfly.modules.dir}/javax/persistence/api/main/module.xml" failonerror="false" verbose="true" overwrite="true"/>
<delete file="${wildfly.modules.dir}/javax/persistence/api/main/${w.jpa.api.jar}" failonerror="false"/>

<move file="${wildfly.modules.dir}/org/eclipse/persistence/main/module.xml.bak" tofile="${wildfly.modules.dir}/org/eclipse/persistence/main/module.xml" failonerror="false" verbose="true" overwrite="true"/>
<pathconvert property="delete.eclipselink.jars" refid="eclipselink.lib" pathsep=",">
<flattenmapper/>
</pathconvert>
<delete failonerror="false">
<fileset dir="${wildfly.modules.dir}/org/eclipse/persistence/main" includes="${delete.eclipselink.jars}"/>
</delete>
<cli command=":reload"/>
</target>

<target name="wildfly-start" description="Start the server." depends="-wildfly-cli-init">
<property name="additional.server.args" value=""/>
<property name="additional.server.jvmOpts" value="-Xms64m -Xmx1g -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=2g -Djava.net.preferIPv4Stack=true"/>
<property name="w.jvmOpts" value="-Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"/>
<exec executable="${wildfly.home}/bin/standalone.${suffix}" spawn="true">
<env key="JAVA_HOME" value="${test.junit.jvm}"/>
<env key="JBOSS_HOME" value="${wildfly.home}"/>
<env key="JBOSS_MODULES_SYSTEM_PKGS" value="org.jboss.byteman"/>
<env key="JAVA_OPTS" value="${additional.server.jvmOpts} ${w.jvmOpts}"/>
<arg value="--server-config=${wildfly.config}"/>
<arg value="-Ddb.user=${db.user}"/>
<arg value="-Ddb.pwd=${db.pwd}"/>
<arg line="${additional.server.args}"/>
</exec>
<waitfor maxwait="3" maxwaitunit="minute" checkevery="500" timeoutproperty="wildfly.not.running">
<http url="http://localhost:8080/index.html"/>
</waitfor>
<fail if="wildfly.not.running" message="Wildfly did not start within given time"/>
<echo>Wildfly is runnig at http://localhost:8080/index.html</echo>
</target>

<target name="wildfly-stop" description="Stop the server." depends="-wildfly-cli-init">
<cli command=":shutdown"/>
</target>

<target name="wildfly-deploy" description="Deploy the application ear to the server." depends="-wildfly-cli-init">
<cli command="deploy ${ear.name} --force"/>
</target>

<target name="wildfly-undeploy" description="Undeploy the application ear frpm the server." depends="-wildfly-cli-init">
<cli command="undeploy ${application.name}.ear"/>
</target>

</project>

0 comments on commit 9a8ec38

Please sign in to comment.