How to make Arquillian eventing thread safe?

discussion
core

#1

As probably some of you know, mainly Aslak and Alex, I was extracting that Arquillian Cube runtime into Arquillian-less solution so I can manage lifecycle of containers manually by firing respective management events.

The thing is that, when you look at it realistically, you can start containers which do not depend on any other container in parallel. Right now I am doing it sequentially hence I could potentially save some startup time.

So the first naive approach was to do it like this:

listOfContainers.parallelStream().forEach(container -> manager.start(container.getName()))

manager is just a wrapper which internally fires CreateContainer and StartContainer events.

The result of this was that it got it kind of mangled and underlying Core manager ended up with some weird exceptions. I do not have a log at hand right now but I could make some reproducer on demand.

How to make this thread safe? Is core manager thread safe? I guess it is not because it observes events as they are fired and there is not any notion of “threadness” in it so only events logically coupled in one thread would be executed in some kind of isolated state from all other ones.

Is it a bad idea to put Arquillian core manager to some thread pool so I would have multiple of them and I would then submit a task to Executor service which would fire events so eventually every core manager would execute in a separate thread hence it would not clash?


Arquillian 1.2 and Java version
#2

If you could provide a “reproducer” it would help us working on that. It’s definitely a big topic not only for cube, but also for any other Arquillian power tests - such as Drone.


#3

In case of Arquillian Cube, Docker containers are started in parallel if they can using a Future.