CCM NG: Build helper script: Application server to use is now deduced from the profile name for test subcommands.

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4610 8810af33-2d31-482b-a856-94f89814c4df
jensp 2017-03-01 13:59:50 +00:00
parent 53d60320b6
commit f82f771eb2
2 changed files with 282 additions and 186 deletions

View File

@ -3,20 +3,17 @@ environment. It provides shortcuts for several Maven goals. The available
subcommands are: subcommands are:
build-site [PROFILE] : Builds the Maven project site. build-site [PROFILE] : Builds the Maven project site.
build [PROFILE] : Builds LibreCCM using the build [PROFILE] : Builds LibreCCM using the provided
provided profile profile
build-module MODULE [PROFILE] : Build a specific LibreCCM build-module MODULE [PROFILE] : Build a specific LibreCCM module.
test-all [[PROFILE] [start]] : Run tests for all modules.
test-module MODULE [[PROFILE] [start]]: Run tests for a specific LibreCCM
module. module.
test-all [-s [-r RUNTIME]] [PROFILE] : Run tests for all modules. test MODULE TEST [[PROFILE] [start]] : Run a specific testsuite or a single
test-module [-s [-r RUNTIME]] MODULE [PROFILE] : Run tests for a specific test method.
LibreCCM module. install-runtime [RUNTIME] : Download and install a runtime
run-test [-s [-r RUNTIME]] MODULE TEST [PROFILE]: Run a specific testsuite or (application server) into ./runtime.
a single test. run [-r RUNTIME] [BUNDLE] : Run a runtime (application server)
install-runtime [RUNTIME] : Download and install a
runtime (application server)
into ./runtime.
run [-r RUNTIME] [BUNDLE] : Run a runtime
(application server)
help : Show this help message. help : Show this help message.
build-site [PROFILE] build-site [PROFILE]
@ -49,81 +46,121 @@ build-module MODULE [PROFILE]
Build a specific LibreCCM module. Equivalent to Build a specific LibreCCM module. Equivalent to
mvn clean package -pl $MODULE -am mvn clean package -pl MODULE -am
without a profile and to without a profile and to
mvn clean package -P$PROFILE -pl $MODULE -am mvn clean package -PPROFILE -pl MODULE -am
with a profile. with a profile.
test-all [-s [-r RUNTIME]] [PROFILE] test-all [[PROFILE] [start]]
============================
Run all tests for all modules. The name of the (optional) profile is used to
determine if a runtime (application server) is started and which application
server is started. Some profiles use Arquillian container adapters which don't
require a running application server. Others requires a running a application
server. For those profiles the application server deduced from the profile
name is started if the last parameter is "start". Otherwise the application
server must be started manully before running the tests. Please note that the
use of the "start" parameter is not recommanded because is may causes
problems. It is recommanded to either start the application server manually or
to use a profile which uses an Arquillian container adapter which starts the
application server itself.
This subcommand is equivalent to the Maven command
mvn clean test -PPROFILE
with a profile and to
mvn clean test
without a profile.
test-module MODULE [[PROFILE] [start]]
======================================
Runs the tests for a specific module. The name of the module is a mandatory
parameter.
The name of the (optional) profile is
used to to determine if a runtime (application server) is started and
application server is started. Some profiles use Arquillian container adapters
which dont't require a running application server. Others require a running
application server. For those profiles the application is deduced from the
profile is started if the the last parameter is "start". Otherwise the
application server must be started manually before running the tests. Please
note that the use of the "start" parameter is not recommanded. It is
recommanded to either start the application server manually or to use a
profile which uses a container adapter which starts the application server
itself.
This subcommand is equivalent to the Maven command
mvn clean test -pl MODULE -am -PPROFILE
with a profile and to
mvn clean test -pl MODULE -am
without a profile.
test MODULE TEST [[PROFILE] [start]]
==================================== ====================================
Run all tests for all modules. If the -s flag is set a application server is Runs the a specific testsuite or a single test. Module and test are mandatory
started in the background before the tests are run and stopped afterwards. parameters. The testsuite or test to run is set using the following syntax:
If no runtime is provided using -r RUNTIME Wildfly is used as runtime. See
the section "run" for Wildfly specific details.
If a profile is provided the profile is used to run the tests.
test-module [-s [-r RUNTIME]] MODULE [PROFILE]
==============================================
Runs the tests for a specific module. If the -s flag is set a application
server is started in the background before the tests are run and stopped
afterwards. If no runtime is provided using -r RUNTIME Wildfly is used as
runtime. See the section "run" for Wildfly specific details.
This subcommand has one mandatory parameter: The module which tests are run.
Optionally a profile can be provided.
run-test [-s [-r RUNTIME]] MODULE TEST [PROFILE]
================================================
Runs the a specific testsuite or a single test.
If the -s flag is set a application
server is started in the background before the tests are run and stopped
afterwards. If no runtime is provided using -r RUNTIME Wildfly is used as
runtime. See the section "run" for Wildfly specific details.
This subcommand has two mandatory parameter:
The module which contains the test(suite) to run and the test to run. The test
to run must be provided in the following syntax:
fully.qualified.classname.of.testclass[#test-method] fully.qualified.classname.of.testclass[#test-method]
Optionally are profile can be provided. The name of the (optional) profile is
used to to determine if a runtime (application server) is started and
application server is started. Some profiles use Arquillian container adapters
which dont't require a running application server. Others require a running
application server. For those profiles the application is deduced from the
profile is started if the the last parameter is "start". Otherwise the
application server must be started manually before running the tests. Please
note that the use of the "start" parameter is not recommanded. It is
recommanded to either start the application server manually or to use a
profile which uses a container adapter which starts the application server
itself.
This subcommand is equivalent to the Maven command
mvn clean test -Dtest=TEST -DfailIfNoTests=false -pl MODULE -am -PPROFILE
with a profile and to
mvn clean test -Dtest=TEST -DfailIfNoTests=false -pl MODULE -am
without a profile.
Some examples: Some examples:
Run all tests in the class org.libreccm.configuration.EqualsAndHashCodeTest in Run all tests in the class org.libreccm.configuration.EqualsAndHashCodeTest in
the ccm-core module: the ccm-core module:
ccm.sh runtest ccm-core org.libreccm.configuration.EqualsAndHashCodeTest ccm.sh test ccm-core org.libreccm.configuration.EqualsAndHashCodeTest
Run all tests in the class org.libreccm.core.CcmObjectRepositoryTest in the Run all tests in the class org.libreccm.core.CcmObjectRepositoryTest in the
ccm-core module. This tests is run using Arquillian and requires a runtime and ccm-core module. These tests is run using Arquillian and require a runtime and
is only run when an integration test profile is used: is only run when an integration test profile is used. The application server
must be started before the test are invoked.
ccm.sh runtest -s ccm-core org.libreccm.core.CcmObjectRepositoryTest ccm.sh test ccm-core org.libreccm.core.CcmObjectRepositoryTest wildfly-remote-h2-mem
wildfly-remote-h2-mem
This example runs the same tests as the previous example but uses a managed
profile. The application server will started by Arquillian automatically:
ccm.sh test ccm-core org.libreccm.core.CcmObjectRepositoryTest
wildfly-managed-h2-mem
Or if you only want to run the saveChangedCcmObject test: Or if you only want to run the saveChangedCcmObject test:
ccm.sh runtest -s ccm-core ccm.sh test ccm-core
org.libreccm.core.CcmObjectRepositoryTest#saveChangedCcmObject wildfly-remote-h2-mem org.libreccm.core.CcmObjectRepositoryTest#saveChangedCcmObject wildfly-managed-h2-mem
The last two examples used the default runtime (Wildfly). Invoking without a
specific runtime is equivalent to
ccm.sh runtest -s -r wildfly ccm-core org.libreccm.core.CcmObjectRepositoryTest wildfly-remote-h2-mem
ccm.sh runtest -s -r wildfly ccm-core org.libreccm.core.CcmObjectRepositoryTest#saveChangedCcmObject wildfly-remote-h2-mem
install-runtime [RUNTIME] install-runtime [RUNTIME]
@ -169,18 +206,28 @@ using Wildfly's administration UI available at
http://localhost:9990 http://localhost:9990
Wildfly specific details Supported iApplication server
------------------------ =============================
Wildfly
-------
If the JBOSS_HOME environment variable is set the script will use the server If the JBOSS_HOME environment variable is set the script will use the server
in the directory provided by JBOSS_HOME. You may provide a value for this in the directory provided by JBOSS_HOME for starting Wildfly.
variable when calling the script: You may provide a value for this variable when calling the script:
JBOSS_HOME=/path/to/wildfly ./ccm.sh run [wildfly] JBOSS_HOME=/path/to/wildfly ./ccm.sh run [wildfly]
For profiles using the wildfly-arquillian-container-remote adapter Wildfly
must be started manually. The subcommands for running test have an optional
parameter for starting Wildfly automatically if a remote profile is used, but
this is not recommanded. If a profile is used which uses
wildfly-arquillian-container-managed Arquillian starts the container
automatically.
If JBOSS_HOME is not set the script will look for a Wildfly installation in If JBOSS_HOME is not set the script will look for a Wildfly installation in
./runtime. The install-runtime subcommand can be used to install Wildfly ./runtime. The install-runtime subcommand can be used to install Wildfly
there. there. The script passes this parameter to Maven in the required form.
The datasource configuration is done using Wildfly's administration UI. To The datasource configuration is done using Wildfly's administration UI. To
create a datasource open a browser and go to create a datasource open a browser and go to

263
ccm.sh
View File

@ -67,7 +67,7 @@ starttestruntime() {
fi fi
pushd $wildflyhome pushd $wildflyhome
sh "LAUNCH_JBOSS_IN_BACKGROUND=1 JBOSS_PID_FILE=$wildflypidfile ./bin/standalone.sh" LAUNCH_JBOSS_IN_BACKGROUND=1 JBOSS_PIDFILE=$wildflypidfile ./bin/standalone.sh &
popd popd
echo "Waiting 120s for Wildfly to start up..." echo "Waiting 120s for Wildfly to start up..."
sleep 120 sleep 120
@ -109,7 +109,7 @@ stoptestruntime() {
echo "Setting wildflyhome..." echo "Setting wildflyhome..."
wildflyhome="./runtime/wildfly-$wildflyversion" wildflyhome="./runtime/wildfly-$wildflyversion"
else else
echo "There is not Wildfly in ./runtime/ and JBOSS_HOME is not set." echo "There is no Wildfly in ./runtime/ and JBOSS_HOME is not set."
echo "Please call install-runtime or set JBOSS_HOME" echo "Please call install-runtime or set JBOSS_HOME"
exit 1 exit 1
fi fi
@ -129,126 +129,180 @@ stoptestruntime() {
# Run all tests # Run all tests
testall() { testall() {
echo "Running all tests for all modules..."
startruntime=false if [[ $1 =~ ^wildfly-managed.* ]]; then
runtime="wildfly" echo "...using a managed Wildfly container"
profile="" wildflyhome=""
if [ -n "$JBOSS_HOME" ]; then
if [ "$1" = "-s" ]; then echo "...JBOSS_HOME environment variable is set. Using Wildfly installation at $JBOSS_HOME."
startruntime=true wildflyhome=$JBOSS_HOME
if [ "$2" = "-r" ]; then elif [ -d "./runtime/wildfly-$wildflyversion" ]; then
runtime=$3 echo "...using Wildfly installation in runtime directory"
profile=$4 pushd $wildflyhome
wildflyhome=`pwd`
popd
else else
profile=$2 echo -e "\e[41mThere is no Wildfly-$wildflyversion in ./runtime nore is JBOSS_HOME set. Please install Wildfly-$wildflyversion into runtime by calling install-runtime or set the JBOSS_HOME environment variable to a valid location.\e[0m"
fi exit 1
fi fi
if [ $startruntime ]; then echo "...using profile $1"
starttestruntime $runtime echo ""
fi if [ -n $STARTUP_TIMEOUT ]; then
mvn clean test -Djboss.home=$wildflyhome -DstartuptimeoutInSeconds=$STARTUP_TIMEOUT -P$1
if [ -n "$profile" ]; then
echo "Running tests for all modules with profile $profile..."
mvn clean test -P$profile
else else
echo "Running tests for all modules..." mvn clean test -Djboss.home=$wildflyhome -P$1
fi
elif [[ $1 =~ ^wildfly-remote.* ]]; then
echo "...using a remote Wildfly container"
if [[ $2 == "start" ]]; then
echo "...starting runtime"
starttestruntime wildfly
else
echo "...runtime is started manually"
fi
echo "...using profile $1"
mvn clean test -P$1
if [[ $2 == "start" ]]; then
echo "...stopping runtime"
fi
else
if [[ -n $1 ]]; then
echo -n -e "\e[43m"
echo "Warning: "
echo "The provided profile starts with an unknown prefix. Tests"
echo "which require a running application server may fail. "
echo -n -e "\e[0m"
fi
mvn clean test mvn clean test
fi fi
if [ $startruntime ]; then
stoptestruntime $runtime
fi
} }
# Run tests for a module # Run tests for a module
testmodule() { testmodule() {
startruntime=false if [[ -z $1 ]]; then
runtime="wildfly" echo -e "\e[41mUsage: ccm.sh test-module MODULE [PROFILE] [start]\e[0m"
module=""
profile=""
if [ "$1" = "-r" ]; then
startruntime=true
if [ "$2" = "-r" ]; then
runtime=$3
module=$4
profile=$5
else
module=$2
profile=$3
fi
fi
if [ -z "$module" ]; then
echo "Error: No module to test. Exiting."
exit 1 exit 1
fi fi
if [ $startruntime ]; then echo "Running tests for module $1..."
starttestruntime $runtime if [[ $2 =~ ^wildfly-managed.* ]]; then
fi echo "...using a managed Wildfly container."
wildflyhome=""
if [ -n "$profile" ]; then if [ -n "$JBOSS_HOME" ]; then
echo "Running tests for module $module with profile $profile..." echo "...JBOSS_HOME enviromentment variable is set Using Wildfly installation at $JBOSS_HOME."
mvn clean test -P$profile -pl $module -am wildflyhome=$JBOSS_HOME
elif [ -d "./runtime/wildfly-$wildflyversion" ]; then
echo "...using Wildfly installation in runtime-directory"
pushd $wildflyhome
wildflyhome=`pwd`
popd
else else
echo "Running tests for module $module..." echo -e "\e[41mThere is no Wildfly-$wildfly-version in ./runtime nore is JBOSS_HOME set. Please install Wildfly-$wildfly-version into ./runtime by calling install-runtime or set the JBOSS_HOME environment variable to valid location.\e[0m"
mvn clean test -pl $module $am exit 1
fi fi
if [ $startruntime ]; then echo "...using profile $2"
stoptestruntime $runtime echo ""
if [ -n $STARTUP_TIMEOUT ]; then
mvn clean test -Djboss.home=$wildflyhome -DstartupTimeoutInSeconds=$STARTUP_TIMEOUT -pl $1 -am -P$1
else
mvn clean test -Djboss.home=$wildflyhome -pl $1 -am -P$2
fi
elif [[ $2 =~ ^wildfly-remote.* ]]; then
echo "Using a remote Wildfly container..."
if [[ $3 == "start" ]]; then
echo "...starting runtime"
starttestruntime wildfly
else
echo "...runtime is started manually"
fi
echo "...using profile $2"
mvn clean test -pl $1 -am -P$2
if [[ $3 == "start" ]]; then
echo "...stopping runtime"
fi
else
if [[ -n $2 ]]; then
echo -n -e "\e[43m"
echo "Warning: "
echo "The provided profile starts with an unknown prefix. Tests"
echo "which require a running application server may fail. "
echo -n -e "\e[0m"
fi
mvn clean test -pl $1 -am
fi fi
} }
# Run a single testsuite or test # Run a single testsuite or test
runtest() { runtest() {
startruntime=false if [ -z "$1" -o -z "$2" ]; then
runtime="wildfly" echo -e "\e[41mUsage: ccm.sh test-module MODULE TEST [PROFILE] [start]\e[0m"
module=""
testtorun=""
profile=""
if [ "$1" = "-r" ]; then
startruntime=true
if [ "$2" = "-r" ]; then
runtime=$3
module=$4
profile=$5
else
module=$2
profile=$3
fi
fi
if [ -z module ]; then
echo "No module provided. Please provide the module which contains the test to run. Exiting."
exit 1 exit 1
fi fi
if [ -z testtorun ]; then echo "Running test $2 from module $1..."
echo "No test to run provided. Exiting." if [[ $3 =~ ^wildfly-managed.* ]]; then
echo "...using a managed Wildfly container."
wildflyhome=""
if [ -n "$JBOSS_HOME" ]; then
echo "...JBOSS_HOME environment variable is set. Using Wildfly installation at $JBOSS_HOME."
wildflyhome=$JBOSS_HOME
elif [ -d "./runtime/wildfly-$wildflyversion" ]; then
echo "...using Wildfly installation in runtime directory"
pushd ./runtime/wildfly-$wildflyversion
wildflyhome=`pwd`
popd
else
echo -e "\e[41mThere is no Wildfly-$wildfly-version in ./runtime nore is JBOSS_HOME set. Please install Wildfly-$wildfly-version into ./runtime by calling install-runtime or set the JBOSS_HOME environment variable to valid location.\e[0m"
exit 1 exit 1
fi fi
if [ $startruntime ]; then echo "...using Wildfly in $wildflyhome"
starttestruntime $runtime echo "...using profile $3"
fi echo ""
if [ -n $STARTUP_TIMEOUT ]; then
if [ -n "$profile" ]; then mvn clean test -Djboss.home=$wildflyhome -DstartupTimeoutInSeconds=$STARTUP_TIMEOUT -Dtest=$2 -DfailIfNoTests=false -pl $1 -am -P$3
echo "Running tests for module $module with profile $profile..."
mvn clean test -Dtest=$testtorun -DfailIfNoTests=false -P$profile -pl $module -am
else else
echo "Runnign tests for module $module..." mvn clean test -Djboss.home=$wildflyhome -Dtest=$2 -DfailIfNoTests=false -pl $1 -am -P$3
mvn clean test -D$testtorun -pl $module $am fi
elif [[ $3 =~ ^wildfly-remote.* ]]; then
echo "Using a remote Wildfly container..."
if [[ $4 == "start" ]]; then
echo "...starting runtime"
starttestruntime wildfly
else
echo "...runtime is started manually"
fi fi
if [ $startruntime ]; then mvn clean test -Dtest=$2 -DfailIfNoTests=false -pl $1 -am -P$3
stoptestruntime $runtime
if [[ $4 == "start" ]]; then
echo "...stopping runtime"
stoptestruntime wildfly
fi fi
else
if [[ -n $3 ]]; then
echo -n -e "\e[43m"
echo "Warning: "
echo "The provided profile starts with an unknown prefix. Tests"
echo "which require a running application server may fail. "
echo -n -e "\e[0m"
fi
mvn clean test -Dtest=$2 -DfailIfNoTests=false -pl $1 -am
fi
} }
@ -430,25 +484,20 @@ stopruntime() {
showhelp() { showhelp() {
echo "ccm.sh is a helper script for building and running LibreCCM in a echo "ccm.sh is a helper script for building and running LibreCCM in a
development environment. It provides shortcuts for several Maven goals. The development environment. It provides shortcuts for several Maven goals. The available subcommands are:
available subcommands are:
build-site [PROFILE] : Builds the Maven project build-site [PROFILE] : Builds the Maven project site.
site. build [PROFILE] : Build all LibreCCM modules.
build [PROFILE] : Build all LibreCCM build-module MODULE [PROFILE] : Build a specific LibreCCM module.
modules. test-all [[PROFILE] [start]] : Run all tests for all modules.
build-module MODULE [PROFILE] : Build a specific LibreCCM test-module MODULE [[PROFILE] [start]] : Run all tests for a specific
module.
test-all [-s [-r RUNTIME]] [PROFILE] : Run tests for all modules.
test-module [-s [-r RUNTIME]] MODULE [PROFILE] : Run tests for a specific
LibreCCM module. LibreCCM module.
run-test [-s [-r RUNTIME]] MODULE TEST [PROFILE]: Run a specific testsuite run-test MODULE TEST [[PROFILE] [start]]: Run a specific testsuite or a
or a single test. single test method.
install-runtime [RUNTIME] : Download and install a install-runtime [RUNTIME] : Download and install a runtime
runtime (application (application server) into
server) into ./runtime ./runtime
run [-r RUNTIME] [BUNDLE] : Run a runtime run [-r RUNTIME] [BUNDLE] : Run a runtime (application server)
(application server)
help : Show this help message. help : Show this help message.
A detailed description of the subcommands is provided in ccm-readme.txt" A detailed description of the subcommands is provided in ccm-readme.txt"
@ -464,7 +513,7 @@ case $1 in
build-module) buildmodule $2 ;; build-module) buildmodule $2 ;;
test-all) testall $2 $3 $4 ;; test-all) testall $2 $3 $4 ;;
test-module) testmodule $2 $3 $4 $5 ;; test-module) testmodule $2 $3 $4 $5 ;;
run-test) runtest $2 $3 $4 $5 $6 ;; test) runtest $2 $3 $4 $5 ;;
install-runtime) installruntime $2 ;; install-runtime) installruntime $2 ;;
run) run $2 $3 $4 ;; run) run $2 $3 $4 ;;
stop-runtime) stopruntime $2 ;; stop-runtime) stopruntime $2 ;;