This message was deleted.
# community-support
s
This message was deleted.
j
I think it is not a good idea sharing data between tests, they should be independent, even in a single module build.
e
They dont share data.. but message broker :)
j
What you mean with resources? The build is overloaded due multiple tests running in parallel?
e
Module
A
produces events on a broker. My integration tests in module
A
inspect the broker and assert that the correct things are published. module
B
consumes these events. My integration tests in
B
publishes faked events on the broker and assert that the correct side-effects occur, given the event. If
A
and
B
run in parallel, the events from tests in
A
would cause unexpected side-effects to happen when(if)
B
is running at the same time
j
I am not sure, can’t you avoid that by doing everything in the same test in a module C which depends on A and B? The other option would be using fakes, which has no sense in integration tests. Tests can run in parallel even in the same module, so the same test should produce and consume.
c
You need to use a shared Build Service (representing the resource, even if it's absolutely empty), and limit its concurrency
You cannot enforce order, but you will enforce that they don't run in parallel
πŸ‘ 1
e
Thanks. I stumbled upon a ticket mentioning build services πŸ™‚ I'll dig deeper in that direction
j
But what would happens if B runs before A?
e
Wouldn't matter. B:s tests send the events which we want to consume
πŸ‘ 1
v
Then a shared build service with concurrency 1 would indeed be the way to make the tasks mutally exclusive
πŸ‘ 1
e
The docs for using build services never seem to mention them from a regular build script (
build.gradle.kts
). Can it be done?
v
yes
But as you want the same build service in two different projects, you probably should put it into
buildSrc
or an included build anyway, unless you do highly discouraged bad-practice cross-project configuration. πŸ™‚
But within one project, you can simply do it like
Copy code
interface Foo : BuildService<BuildServiceParameters.None>
val foo = gradle.sharedServices.registerIfAbsent("foo", Foo::class) {
    maxParallelUsages.set(1)
}
tasks.test {
    usesService(foo)
}
e
Aha, thanks πŸ™‚
I am using an included build. I'll try putting something like that there. TYVM!
πŸ‘Œ 1