stratos-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pubudu Gunatilaka <>
Subject Re: Python Cartridge Agent Test Failure
Date Mon, 22 Jun 2015 05:01:18 GMT
Hi Imesh,

I found the root cause for this issue.

ExecutorService executorService =
StratosThreadPool.getExecutorService("TEST_THREAD_POOL", 5);

We are using StratosThreadPool utility class to create or get already exist
executor service. "TEST_THREAD_POOL" is the identifier or the key we used
in the implementation. In StratosThreadPool class, it has a static
concurrent hash map to hold the executor. Although we terminate event
receivers in tear down, it won't stop all the running threads. Due to that,
in the last test run it won't be able to receive the instance activated
event as there aren't any available threads in the thread pool.

public static ExecutorService getExecutorService(String identifier,
int threadPoolSize) {
    ExecutorService executorService = executorServiceMap.get(identifier);
    if (executorService == null) {
        synchronized (executorServiceMapLock) {
            if (executorService == null) {
                executorService = Executors.newFixedThreadPool(threadPoolSize);
                executorServiceMap.put(identifier, executorService);
      "Thread pool created: [type]
Executor Service [id] %s [size] %d", identifier, threadPoolSize));
    return executorService;

For this issue we can create a new thread pool as below. It will not affect
any tests we run.

ExecutorService executorService = Executors.newFixedThreadPool(5);

IMO this is okay as we try to run tests. Otherwise we will have to increase
the number of threads we use. But if we add more artifacts, threads number
will have to increase.


On Mon, Jun 22, 2015 at 7:56 AM, Imesh Gunaratne <> wrote:

> Yes I'm also seeing the same, we need to investigate this.
> Thanks
> On Sunday, June 21, 2015, Pubudu Gunatilaka <> wrote:
>> Hi Devs,
>> I ran the live test in python cartridge agent(PCA) and it was failed.
>> There are 3 tests in the PCA and they run on based on the artifacts which
>> is taken from a public repo and a private repo. Each test uses defined
>> artifacts as parameters. When I ran all the 3 tests, which is the default
>> run it was failed. Then I tried running a single test which uses a public
>> repo and it was successful. Even running 2 tests was successful. But could
>> not run 3 tests successfully.
>> After looking at logs, what I could understand is that in the last test,
>> it waits for the instance activated event. But cartridge agent has already
>> sent the instance activated event. So after the timeout, build get failed.
>> ExecutorService executorService = StratosThreadPool.getExecutorService("TEST_THREAD_POOL",
>> Thread pool size we used in the PCA test is 5. I increased that number
>> more than 5 and ran all 3 tests. It was successful. In each and every test
>> case, a new Executor Service is getting created and have the same number of
>> thread pool size. But every time last test fails regardless of the test
>> order. Other thing is that when we are adding more artifact events as
>> parameters which is also increasing the number of tests, we have to
>> increase the thread pool size to run tests successfully.
>> What could be the reason for this behavior?
>> Thank you!
>> --
>> *Pubudu Gunatilaka*
>> Software Engineer
>> WSO2, Inc.:
>> lean.enterprise.middleware
>> mobile:  +94 77 4078049
> --
> Imesh Gunaratne
> Senior Technical Lead, WSO2
> Committer & PMC Member, Apache Stratos


*Pubudu Gunatilaka*
Software Engineer
WSO2, Inc.:
mobile:  +94 77 4078049

View raw message