Last updated at: Oct 26, 2010
By: Ming.Zhang@sun.com
I. Running QuickLook tests:
The QuickLook (QL) implements three profiles (web profile,
dev_debug profile and glassfish profile) to run QL in 3 different
scenarios: testing v3 web distribution, testing v3 web distribution
in debug mode, testing v3 glassfish distribution.
First,
install/unzip the glassfish bundle to a directory. Let's call the
full path to glassfish directory as {V3 Installation Dir}.
Please do not install glassfish under v3/tests/quicklook since the
"clean" target of QL will clean up all war files under
quicklook directory. Change directory to v3/tests/quicklook.
All italic text below indicate a command.
QL will work with
the default admin password "NULL" (empty). Please clean up
the previous ~/.asadminpass if it contains other password.
1.
To Run QL in Glassfish Profile:
The v3 glassfish
distribution includes extra modules such as EJB, jts and corba other
than the modules in web distribution. The glassfish profile is the
default profile of QL.
New: Added cluster testing
support for QL glassfish.
For glassfish bundle of V3, {V3 Installation Dir} is equivalent to /test/glassfish in the example above.
mvn -Dglassfish.home={V3 Installation Dir} test | tee run.log
For glassfish-ips.zip bundle of V3, the same command can be used but {V3 Installation Dir} is equivelent to in /test/glassfish3/glassfish:
To run cluster tests only, you can go to v3/tests/quicklook and do: ant -Dglassfish.home={V3 Installation Dir} all_cluster
The test results will be in test-output directory.
2.
To Run QL in Web Profile:
The web profile (-P test_wd) should
be used for testing the v3 web distribution.
mvn -Dglassfish.home={V3 Installation Dir} -P test_wd test | tee run.log
3. To Run QL in Embedded
Profile:
The web profile (-P test_em) should be used for
testing the v3 embedded mode.
mvn -Dglassfish.home={V3 Installation Dir} -P test_em test | tee run.log
4. To Run QL in Glassfish
Profile with Security Manager Turned On:
The web
profile (-P test_wd_security) should be used for testing the v3 web
distribution.
mvn -Dglassfish.home={V3 Installation Dir} -P test_gd_security test | tee run.log
5. To Run QL in Web Profile with Security Manager Turned
On:
The web profile (-P test_wd_security) should be used
for testing the v3 web distribution.
mvn -Dglassfish.home={V3 Installation Dir} -P test_wd_security test | tee run.log
6. To Run QL in V3 Debug Profile:
Usually, user
wants to run QL against a running v3 instance started in debug mode.
The dev_debug profile can be used (-P dev_debug) in this scenario.
Start v3 in debug mode. For example: java -jar modules/glassfish.jar
mvn -Dglassfish.home={V3 Installation Dir} -Pdev_debug test | tee run.log
Note: The tests require restart domain (admincli) will be skipped
in this scenario.
7. To Run Individual Test Suite from
Directory Level:
After the first run with maven from top
level, the dependency jars will be downloaded to local maven
repository. Now it's possible to run individual test suite from
directory level. Change directory to the test directory. For example,
to run quicklook/ejb/slsbnicmt test suite against glassfish
bundle:
{V3 Installation Dir}/bin/asadmin start-domain
{V3 Installation Dir}/bin/asadmin start-database
cd ejb/slsbnicmt
ant -Dglassfish.home={V3 Installation Dir} all
8. Using Local Maven Repository in Non-Default
Directory:
Section 1 and 2 assume the use of default local
maven repository directory, ${user.home}/.m2/repository. If you local
maven repository is in another directory, say directory
{Local_Maven}, you can use one of the following ways to point to your
specific maven repository:
Add option on command line: -Dmaven.repo.local={Local_Maven}
Set MVN_OPTS environment varialable: MVN_OPTS="-D-Xmx512M -Dmaven.repo.local={Local_Maven}"
Make a symbolic link from ${user.home}/.m2/repository to the actuall maven repository (will not work on windows platform).
II. Adding Tests to QuickLook
1. Requirements for the Adding Tests to QL:
The QL has a wide user community which includes developer, RE and SQE teams. So the candidate tests need conform to the following criteria:
The tests need to be robust. For example, the failure of the test in any process (compile, build, deploy, run ...) should not stop the process of generating the finial QL report.
Not depend on internet access. The tests should be off-line and self-sufficient.
Performance. The QL tests should be testing the basic features of the module and fast. Ideally, tests for one module should be less than 1 minute.
To make sure the tests don't break the RE and SQE processes, please send the tests to Ming.Zhang@sun.com for reviewing.
2. Steps of Adding Tests to QL
The test framework of QuickLook is TestNG. TestNG allows us to add/remove tests from harness easily and simplifies the client side programming. Below is an example of how to add a test suite to QL:
An easy way to do is to copy an
existing test suite, such as quicklook/web/helloworld, to your test
directory. Then add your java or xml files (or your test logics to
the existing files) to the test directory. The build.xml and
properties files are inherited.
For examples on the client
side java testing code, please look at the following files for
reference:
Using HttpURLConnection to access URL and read the content: quicklook/web/helloworld/src/test/HelloJSPTestNG.java
Using httpclient as a testing tool: quicklook/adminconsole/src/test/admin/BaseAdminConsoleTest.java
Here is an example of adding a test
suite hellouniverse. All italic text indicate a command. Unix OS is
used for the commands
% cp -r helloworld hellouniverse
%
cd hellouniverse
Please make the following changes to
build.properties
war.file=hellouniverse
testsuite.name=basicweb
testng.test.name=web_jsp_hello_universe
contextroot=hellouniverse
deploy.platform=v3
Please
make following changes to build.xml. Change Project
name
<project name="hello-universe" default="default"
basedir=".">
Under runtest target
<param
name="contextroot" value="hellouniverse"/>
%
cd metadata
Edit web.xml to reflect the new application as
universe .
Edit src/java/SimpleServlet.java, change the name
of servlet to SimpleServlet1, change the package directory from myapp
to hellouniverse and rename to src/java/SimpleServlet1.java
Edit
src/test/HelloJSPTestNG.java, change the classname, testurl and
rename to src/test/HelloUniverseTestNG.java
Now all editing is
complete, lets try to build/deploy/run from leaf level (hellouniverse
level)
Assume we are using web.zip for glassfish. Make sure
javadb and server are started (please use ant 1.6.5)
% cd
v3/test/quicklook
% ant -Dglassfish.home={V3 Installation
Dir} startDerby
% ant -Dglassfish.home={V3 Installation
Dir} start-server
Once the server and derby are started,
go to
% cd web/hellouniverse
% ant
-Dglassfish.home={V3 Installation Dir} build
Make sure no
errorss on consol
% ant -Dglassfish.home={V3 Installation
Dir} deploy
make sure no errors in server.log (while
loading application)
% ant -Dglassfish.home={V3
Installation Dir} runtest
Now you should see 4 tests run and
passed
Please add "all" target to include "build
deploy runtest"
Since QL runs in multiple profiles, the test cases need to be defined in the 3 test lists (under quicklook/testng dir) for the profiles: testng_wd.xml for the Web profile, testng_gd.xml for Glassfish profile, testng_debug.xml for the debug profile. The module level testng.xml is optional but it provides the conveniences of running the module test locally. User can also choose to define the class name in the local build.xml. In this case, there is no need to defined the test cases in local testng.xml .
To integrate your tests into quicklook, please contact Ming Zhang .
III. Reference: