You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stanbol.apache.org by Shay Thompson <st...@adobe.com> on 2011/02/10 20:28:27 UTC

RE: Integration testing - start/stop crx?

Being a noob with Maven I'll admit I'm pretty lost here.  I synced to the stanbol trunk and ran 'mvn install' from the trunk directory and it seems to have built successfully but I have no idea what all it did.  The only other instructions I found were in the enhancer\integration-tests directory but those fail for me saying I'm missing org.apache.maven.shared:file-management:jar:1.2

Could you help me out with a few steps to get me going?  Keep in mind I'm very very new to Maven.  If I have the correct steps to get things built and run the workflow I hopefully can deduce how it's happening and what parts to look at.

Thanks,
Shay

-----Original Message-----
From: Bertrand Delacretaz 
Sent: Thursday, February 10, 2011 8:33 AM
To: Tyson Norris
Cc: DL-tech
Subject: Re: Integration testing - start/stop crx?

Hi,

Le 9 févr. 2011 à 18:26, Tyson Norris a écrit :

> I followed some of the recent thread on integration testing, but the details of starting/stopping crx wasn't mentioned.
> 
> Does anyone have some maven script already in use that runs a workflow for integration testing like:
> 	. start crx
> 	. wait for startup to complete
> 	. execute integration tests that use http to access crx
> 	. stop crx
> 	. wait for crx to stop
> 	. continue with other build/test steps

That's what we do in our CRX and CQ builds, but I think the test utilities have too much Day/CQ dependencies to be useful outside of our own build at this time.

I'm currently working on streamlining this and making it more reusable, if you're adventurous you can try building the following modules and using them as an example:

  http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons
  The jarexec module starts a runnable jar
  StanbolTestBase contains a waitForServerReady method that is similar to what you'd use for CRX

  https://svn.apache.org/repos/asf/incubator/stanbol/trunk/enhancer/integration-tests
  Maven setup to use the above and run a similar scenario to yours

That code is from the Stanbol project (in which we participate via IKS) but the stuff under commons/testing should be reusable, the rest can serve as an example.

My plan is to write a simple sample combining this with the SLING-1963 stuff, that will run your above scenario on a plain Sling launchpad instance. 

You should then be able to base your builds on that example, which will be under http://svn.apache.org/repos/asf/sling/trunk/testing (folder does not exist yet).

ETA for this is next week but that depends on interruptions related to our CQ 5.4 release which has priority.

I'll let you know on this list when the sample is ready.

-Bertrand


Re: Integration testing - start/stop crx?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Fri, Feb 11, 2011 at 3:59 PM, Shay Thompson <st...@adobe.com> wrote:
>
> Ok, I didn't realize it had started an http service.  I assume it's starting a copy
> of sling that was downloaded by mvn?....

Yes, but it's not a vanilla sling jar. The enhancer/integration-tests
module runs the org.apache.stanbol.enhancer.launchers.full jar, which
is built by the enhancer/launchers/full module. It's based on Sling
but as far as those tests are concerned that doesn't really matter, as
long as it's a runnable jar that provides an http interface and takes
a -p parameter to define the server port number.

Here's how this works, pom.xml contains

<dependency>
  <groupId>org.apache.stanbol</groupId>
  <artifactId>org.apache.stanbol.enhancer.launchers.full</artifactId>
  <version>0.9-SNAPSHOT</version>
  <scope>provided</scope>
</dependency>

to define which jar it will run, and that jar is copied under
target/dependency by the maven-dependency-plugin (see the pom for
details).

Then, the StanbolTestBase class (from the commons/testing/stanbol
module), from which the tests in this module inherit, starts the jar
using a @BeforeClass method (that's a JUnit 4 annotation) that uses
the JarExecutor from the commons/testing/jarexec module.

The JarExecutor looks for a jar with a name that matches the
org.apache.stanbol.*full.*jar$ regepx in that folder (hmm...those
values are hardcoded, good that I looked ;-) and executes it in a
separate process.

All that's left for the tests is to wait for the http interface of the
running jar to be ready, that's done in the StanbolTestBase class.

This would work for any runnable jar that provides an http interface,
so any Sling runnable jar in particular.

If you want to set this up for your own server jar, I'd start with the
a copy of the integration-testing module and go from there. JIRA is
down here right now but I'll create an issue for the hardcoded values
problem, should be fixed soon.

-Bertrand

RE: Integration testing - start/stop crx?

Posted by Shay Thompson <st...@adobe.com>.
Ok, I didn't realize it had started an http service.  I assume it's starting a copy of sling that was downloaded by mvn?

-----Original Message-----
From: Bertrand Delacretaz [mailto:bdelacretaz@apache.org] 
Sent: Friday, February 11, 2011 4:42 AM
To: stanbol-dev@incubator.apache.org
Subject: Re: Integration testing - start/stop crx?

Hi Shay,

For those who missed the beginning: Shay's a colleague at Adobe, we're
collaborating on creating/documenting tools to test Sling-based
applications. Basically, how to run integration tests against a
runnable jar, so that's fairly similar to what I did in STANBOL-19 and
SLING-1963.

On Thu, Feb 10, 2011 at 8:28 PM, Shay Thompson <st...@adobe.com> wrote:
> Being a noob with Maven I'll admit I'm pretty lost here.  I synced to the stanbol trunk
> and ran 'mvn install' from the trunk directory and it seems to have built successfully but
> I have no idea what all it did.  The only other instructions I found were in the
> enhancer\integration-tests directory but those fail for me saying
> I'm missing org.apache.maven.shared:file-management:jar:1.2...

If you successfully ran mvn install from the top of the stanbol source
tree, the enhancer/integration-tests indeed ran, so you should be
fine.

To run them again, use "mvn clean install" in the
enhancer/integration-tests folder.

My goal in pointing you here was to give an example of integration
tests that start a runnable jar, wait for its http services to be
ready, and run tests against it.

That's what the enhancer/integration-tests module does, with the help
of the utilities found under commons/testing, so you could use this as
an example to test your Sling-based apps.

My plan for the next few days is to combine those with what I did in
SLING-1963, to create a complete sample that demonstrates the various
tools available to run integration tests against applications built as
OSGi-based runnable jars with an http API. That sample will be in
Sling under http://svn.apache.org/repos/asf/sling/trunk/testing/ once
I get to it, and it will very probably use the stanbol commons/testing
stuff.

-Bertrand

Re: Integration testing - start/stop crx?

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Shay,

For those who missed the beginning: Shay's a colleague at Adobe, we're
collaborating on creating/documenting tools to test Sling-based
applications. Basically, how to run integration tests against a
runnable jar, so that's fairly similar to what I did in STANBOL-19 and
SLING-1963.

On Thu, Feb 10, 2011 at 8:28 PM, Shay Thompson <st...@adobe.com> wrote:
> Being a noob with Maven I'll admit I'm pretty lost here.  I synced to the stanbol trunk
> and ran 'mvn install' from the trunk directory and it seems to have built successfully but
> I have no idea what all it did.  The only other instructions I found were in the
> enhancer\integration-tests directory but those fail for me saying
> I'm missing org.apache.maven.shared:file-management:jar:1.2...

If you successfully ran mvn install from the top of the stanbol source
tree, the enhancer/integration-tests indeed ran, so you should be
fine.

To run them again, use "mvn clean install" in the
enhancer/integration-tests folder.

My goal in pointing you here was to give an example of integration
tests that start a runnable jar, wait for its http services to be
ready, and run tests against it.

That's what the enhancer/integration-tests module does, with the help
of the utilities found under commons/testing, so you could use this as
an example to test your Sling-based apps.

My plan for the next few days is to combine those with what I did in
SLING-1963, to create a complete sample that demonstrates the various
tools available to run integration tests against applications built as
OSGi-based runnable jars with an http API. That sample will be in
Sling under http://svn.apache.org/repos/asf/sling/trunk/testing/ once
I get to it, and it will very probably use the stanbol commons/testing
stuff.

-Bertrand