Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Separating Clover deployment and test execution

Mark N July 3, 2015

Greetings,

I'm using Jenkins and maven to build a Clover-instrumented war file that is deployed on one machine - this is all done in one Jenkins job using maven.

Once the war is deployed and the application is started,  I use another Jenkins job to run our regression tests. The Jenkins test job runs on a different machine and when it execute  the clover2:aggregate clover2:clover  steps in maven, there's no clover db found locally

I'm relatively new to Clover, is there a way to use or specify remote Clover dbs?

Thanks,

Mark

 

 

 

5 answers

0 votes
Grzegorz Lewandowski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 10, 2015

Hi, 

  1. The clover.initstring will be resolved at runtime so modifying catalina.sh should be enough. There's probably more options to configure this system property, e.g. with setting JAVA_OPTS or CATALINA_OPTS environment variables. Please refer to Tomcat documentation for more information about this. 
  2. Clover 3.0.5 supports initstring property. 

 

Best regards,

Grzegorz Lewandowski 

 

0 votes
Mark N July 7, 2015

Hello again, 

Thanks again for your time and the great detailed answer.   The environment that I have to deal with is pretty much as you described, the only small difference is that machine A and machine B are one of the same.  

The job that builds and deploys the application occurs on the same machine (machine A = machine B).   

 

So two more questions...

  1. Does this mean that the -Dclover.initstring=/path/to/clover.db parameter is part of the application server's startup command line arguments?  I'm using a pretty basic Tomcat configuration so to me that means that I would have to modify my catalina.sh properties - which is not really a big problem.
  2. With respect to the clover plugin version, I would love to upgrade but I'm not permitted due to license issues.  Is the clover.initstring paramter only available in Clover 4.x and newer?

 

Thanks again!

 

Regards,

Mark

 

 

0 votes
Grzegorz Lewandowski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 6, 2015

Hey,

Sorry, I miss-understood a little bit the whole configuration. So I assume the testing env you're having is similar to this:

  • machine A which instruments source code, builds instrumented application WAR (along with clover.db) and deploys it machine B
  • machine B with an application server
  • machine C which runs tests against application deployed to machine B

Please correct me if I'm wrong.

 

I would like to prepare your environment configuration with Clover in several steps:

Step #1 - recording code coverage for application code only

  1. On machine A run maven command with clover2:setup (e.g. "mvn clean clover2:setup package")
    1. copy the clover.db to the machine B (if you're having multi-module project you have to copy all generated clover databases or you use the singleCloverDatabase option) 
    2. deploy an instrumented WAR to the machine B
    3. start the application server - use the -Dclover.initstring pointing to the clover.db location (or use -Dclover.initstring.basedir in case you have multiple databases)
  2. Run tests on machine C
    1. just run "mvn clean test" as you did before
    2. as soon as your tests are finished you should see coverage recordings in directory with clover.db on the machine B
  3. Generate reports on machine C:
    1. copy the clover databases and all coverage recording files from machine B to the machine C
    2. the machine C must have access to application sources (otherwise you will not see sources in an HTML report)
    3. optional: in case you have many databases run clover2:merge to merge them
    4. generate your reports using clover2:clover (point to either the single clover.db or the cloverMerge.db if you had many databases)

 

Assuming that your tests are written in Java or Groovy (JUnit, TestNG, Spock), you can configure even more:

Step #2 - recording code coverage for application code as well as coverage and test results for your test classes

Step #3 - tracking per-test code coverage of your application

I'll guide you further as soon as Step #1 is achieved.

 

Note: Clover 3.0.5 is quite old and not supported anymore, I strongly recommend to upgrade to the newest version. Especially Clover 4.0+ have completely redesigned HTML report.

 

Cheers,

Grzegorz Lewandowski 

0 votes
Mark N July 6, 2015

Hello Grzegorz,

Thank you very much for the info!  Here's where I am with clover on the test machine...  

  1. I've managed to instrument the war and have copied the clover.db to the test machine.  Using the (clover2:setup goal)
  2. On the test machine, I've removed any references to the license location inside the pom.xml and used -Dmaven.clover.licenseLocation=/path/to/clover.license in the maven command line.
  3. Per your instructions, I'm specified the location of the db file on the maven command line as follows, -Dclover.initstring=/path/to/clover.db 
  4. Inside the pom.xml I have not specified any clover goals
  5. On my maven command line i'm going to use clover2:aggregate clover2:clover
  6. When I execute the mvn command line and see the following message... 

    [WARNING] No Clover database found, skipping report generation

    [INFO] No report being generated for this module.



    Here's the maven command line I'm using:

    mvn -U clean test -Dmaven.clover.licenseLocation=/path/to/clover.license -Dclover.initstring=/path/to/clover.db -Dtype=NAV -Denv=LOCAL -Dlocalurl=http://mytest.site.org -Dmaven.test.failure.ignore=true clover2:aggregate clover2:clover

 

I don't believe I should be getting this message.  I'm specifying an absolute path to the clover.db file.  

What am I doing wrong?

To verify that clover is configured correctly, where should I look for the generated files?

I should add that I'm 'forced' to use version 3.0.5 of the plugin.

 

 

Thanks in advance.

 

 

 

0 votes
Grzegorz Lewandowski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 6, 2015

Hey Mark, 

Clover DB is created during instrumentation, so you have to ensure manually existence of Clover db generated during clover2:setup on the second machine, you can just copy it or share via some network drive.

On the second machine for you should specify the location of the Clover DB  initstring property for the regression test and Clover goals.  

If the test coverage files won't appear in the same (initstring)  location please refer to Clover flush policy.

For reference:

https://confluence.atlassian.com/display/CLOVER/Working+with+Distributed+Applications#WorkingwithDistributedApplications-Step1:UnderstandingtheClover'initstring'

https://confluence.atlassian.com/display/CLOVER/Using+Clover+for+web+applications#UsingCloverforwebapplications-Flushingcoveragedatainapplicationcontainer

https://confluence.atlassian.com/display/CLOVER/Using+Clover+in+various+environment+configurations

 

If you'll be facing any problems with Clover configuration, please feel free to ask. 

 

Cheers,

Grzegorz Lewandowski

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events