Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to do integration test in a multi-project setup #102

Closed
fowlie opened this issue Oct 21, 2014 · 22 comments
Closed

How to do integration test in a multi-project setup #102

fowlie opened this issue Oct 21, 2014 · 22 comments

Comments

@fowlie
Copy link

fowlie commented Oct 21, 2014

Hi,

We have a multi-project gradle build with 20 submodules. Each submodule has its own farm, and each farm shares a lot of common modules. So the _farmIntegrationTest_ task seems very inefficient, as it would start and stop the common modules many times.

Is it possible to call _farmStartWar, run all integration tests and then finally call _farmStopWar?

Thanks!

@akhikhl
Copy link
Owner

akhikhl commented Oct 21, 2014

Hi Mats,
Do I get it right, that every farm contains exactly one web-app? If so, then configuration is not optimal.
If you have something like this:

project(':ProjectA') {
  farm {
    project(':ProjectA')
  }
}
project(':ProjectB') {
  farm {
    project(':ProjectB')
  }
}

you should change it into this:

farm {
  project(':ProjectA')
  project(':ProjectB')
}

When you invoke "farmIntegrationTest" on the first variant, web-server will be started/stopped before/after each web-app, which is slow.
When you invoke "farmIntegrationTest" on the second variant, web-server will be started/stopped only once for the whole sequence, which should be significantly faster.

@akhikhl
Copy link
Owner

akhikhl commented Oct 21, 2014

Do your projects contain farm definitions at all?

@fowlie
Copy link
Author

fowlie commented Oct 21, 2014

A typical submodule would have a farm like this:

farm {
    webapp project
    webapp ':webshop-car'
    webapp ':webshop-customerservice'
    webapp ':webshop-mock'
}

While another submodule could have it like this:

farm {
    webapp ':webshop-customerservice'
    webapp ':webshop-mock'
    webapp ':webshop-policyservice'
    webapp ':webshop-archiveservice'
    webapp ':webshop-communicationservice'
    webapp ':webshop-uwservice'
    webapp ':webshop-animal'
}

And the customer module have a farm like this:

farm {
    webapp ':webshop-mock'
    webapp ':webshop-communicationservice'
    webapp ':webshop-customerservice'
    webapp ':webshop-uwservice'
}

Is it possible to run all integration tests from all submodules with setting up and tearing down jetty only once?

@akhikhl
Copy link
Owner

akhikhl commented Oct 21, 2014

Ah, now it becomes clearer 😄
So you indeed have normal farms and you use them properly. The problem, as I understand it, is how to run tests on multiple farms, so that web-server is started/stopped once for all.
I will think on the solution.

@akhikhl akhikhl self-assigned this Oct 21, 2014
@fowlie fowlie changed the title How to do integration test in a molti-project setup How to do integration test in a multi-project setup Oct 21, 2014
@akhikhl
Copy link
Owner

akhikhl commented Oct 21, 2014

I have a solution for you. The solution is available in Gretty 1.1.5-SNAPSHOT (already at jfrog snapshot repository).
Please create a new subproject (in the same project tree) and supply it with "build.gradle":

apply plugin: 'org.akhikhl.gretty'
farm {
  include ':ProjectA'
  include ':ProjectB'
}

now you have so-called "composite farm". ProjectA and ProjectB are supposed to contain their own farms. The composite farm includes webapps referenced by those farms.
All normal tasks apply to composite farm, including farmRun, farmIntegrationTest, buildProduct, etc.etc.
There is working example of composite farms in https://github.com/akhikhl/gretty/tree/master/examples/multifarm .
Please report back your experiences, I am ready to improve the thing until it is usable.

@fowlie
Copy link
Author

fowlie commented Oct 23, 2014

I can't find that version anywhere.. http://repo.jfrog.org/artifactory/webapp/search/artifact/?3&q=gretty

@saladinkzn
Copy link
Contributor

It's in oss.jfrog.org: https://oss.jfrog.org/webapp/search/artifact/?1&q=gretty-1.1.5 :)

@fowlie
Copy link
Author

fowlie commented Oct 23, 2014

Ah 😄

Now I get this:
$ gradle farmIntegrationTest --stacktrace

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ':webshop-animal'.

    Failed to notify project evaluation listener.
    java.lang.StackOverflowError (no error message)

  • Try:
    Run with --info or --debug option to get more log output.

  • Exception is:

    org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':webshop-animal'.
    at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:79)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:74)
    ...

BUILD FAILED

Total time: 27.247 secs

@akhikhl
Copy link
Owner

akhikhl commented Oct 23, 2014

I'll have a look.

@akhikhl
Copy link
Owner

akhikhl commented Oct 23, 2014

Looks like infinite recursion in farm includes. Could you, please, show the structure of your composite farm? Does it include itself?

@akhikhl
Copy link
Owner

akhikhl commented Oct 23, 2014

I introduced automatic detection of cyclic farm includes in Gretty 1.1.5-SNAPSHOT.
When there are include cycles, Gretty will throw an exception with detailed information on the cycle.
Could you, please, compile your project again and see the output?

@fowlie
Copy link
Author

fowlie commented Oct 23, 2014

Okey, now the root build file looks like this:

farm {
    include ':webshop-volvia-bsal'
}

...and the webshop-volvia-bsal submodule has a farm like this:

farm {
    webapp project
    webapp ':webshop-car'
    webapp ':webshop-customerservice'
    webapp ':webshop-mock'
}

And then the output was this:
A problem occurred configuring project ':webshop-animal'. Cyclic farm inclusion: [:webshop-animal/, :webshop-volvia-bsal/, :webshop-volvia-bsal/]

@fowlie
Copy link
Author

fowlie commented Oct 23, 2014

I should probably also add the farm from the webshop-animal module:

farm {
    webapp ':webshop-customerservice'
    webapp ':webshop-mock'
    webapp ':webshop-policyservice'
    webapp ':webshop-archiveservice'
    webapp ':webshop-communicationservice'
    webapp ':webshop-uwservice'
    webapp ':webshop-animal'
}

@akhikhl
Copy link
Owner

akhikhl commented Oct 23, 2014

I'll have a look.

@akhikhl
Copy link
Owner

akhikhl commented Oct 23, 2014

Are you sure you have it like this:

farm {
  webapp project
  // ...
}

and not like this?

farm {
  include project
  // ...
}

the second variant would produce exactly the error message you mentioned.

@fowlie
Copy link
Author

fowlie commented Oct 24, 2014

I did a search for "include" on *.gradle files in the IDE, and it found two matches:

  • Once in the top level build.gradle
  • In the top level settings.gradle we include all submodules

And no matches in submodule build.gradle files

@akhikhl
Copy link
Owner

akhikhl commented Oct 24, 2014

Understood. So there's no obvious error in configuration.
Could you, please, create a little sample project setup here, on github, allowing to reproduce the problem? Not necessary to bring all code, just minimalistic gradle scripts with same topology.

@fowlie
Copy link
Author

fowlie commented Oct 31, 2014

Sorry for the late response here, I've been really busy with non-work stuff... So here is a minimalistic multiproject gradle project that gets the same error: https://github.com/fowlie/gretty-sample

@akhikhl
Copy link
Owner

akhikhl commented Nov 1, 2014

Yesss, with this project it is reproducible 😄 Thanks a lot.
Now comes an easy part - to fix it.
Please expect new release with a fix at Monday.

@akhikhl
Copy link
Owner

akhikhl commented Nov 2, 2014

I solved the problem in Gretty 1.1.7-SNAPSHOT.
Please have a look at my PR for gretty-sample: https://github.com/fowlie/gretty-sample/pull/1
https://github.com/fowlie/gretty-sample/pull/1/files?diff=unified
With this PR things should work.

@akhikhl
Copy link
Owner

akhikhl commented Jan 25, 2015

Hi Mats,
Does Gretty 1.1.8 solve the issue for you?
Can we close this issue?

@fowlie
Copy link
Author

fowlie commented Jan 26, 2015

Hi! I guess we can close this now. Although we decided to do things slightly different and did not need this feature any more. That being said, I was voting for this feature though 😃

@fowlie fowlie closed this as completed Jan 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants