The parallel execution of API test within the suite take much more time than when they are ran sequentially

Katalon Studio : 11.5.0

I have a small API Test Suite with only 4 test cases in it.

Now when run these test cases sequentially they take only 5.2 seconds to execute.

But when i run them in parallel within the suite, they take around 29 seconds to execute.

I believe the whole purpose of parallel execution within suite is to reduce the overall time, but here it is just the opposite.

Not sure if anyone else has faced this issue.

I believe the team should look into fixing this issue.

Note: This is for parallel execution of test cases within the suite with the new feature.

Have a look at my previous post:

and this:

and more;

I think you shouldn’t expect any “speed up” by the parallel mode of Test Suites Collection execution of Katalon Studio. It just mess you up.

Parallel execution is a headache and not fruitful for sure.

We tried every possible approach to make parallel execution work smoothly, but we kept encountering random and flaky issues. As a result, we eventually stopped using parallel execution altogether.

@kazurayam
I read your post, and those are mostly around the Test Suite collection.

In this post, I’m highlighting the parallel execution of test cases within a specific test suite, the latest feature that Katalon has shipped.

I’m assuming that the same (logic/explanation) would be applicable for the parallel execution within the test suite.

However, In my case,

The parallel execution of the Test Suite Collection has been helpful at least in the run that I’m executing.

It looks like Katalon has improved since you post.

For sequential execution of test suite collection - 2 mins
For parallel execution of test suite collection - 25 seconds

OK. I did not recognize your point correctly.

This looks odd.

The log viewer tells us — the Test Suite Collection “TSC_metraAssist_API” finished in 25 seconds; and the Test Suite “TS_Digital_Auth”, which is a component of the TSC, finished in 31 seconds.

How come a Test suite collection can finish faster than its component!?

It’s ridiculous. There must be something cheating us. Possibly the log view lied; it took longer than 60, but pretended to be faster and reported 25seconds.

I don’t trust this log view. Though I know that writing a program that accurately measures and reports elapsed time is never easy.

I would never use the parallel mode of TSC as it just annoys me.


I just guess …

As my previos post revealed, a Test Suite Collection forks multiple OS-subprocesses in which each Test Suites run. I suppose, the Test Suite Collection “TSC_metraAssist_API” took forked 5 processes. As soon as it successfully forked the subordinate processes, it finished. Forking 5 processes took 25 seconds. This is likely. Not too fast, not too slow.

And the Test Suite Collection does NOT continue monitoring how the subordinate processes run. A subordinate process took 25 secs; another took 52 seconds. The elapsed time of each Test Suite — TSC does not know. Nobody can accurately report the entire elapsed time from the start of a TSC execution untill all the subordinate procesess to finish.

If we demand TSC to be a strict controller, then Katalon have to change the Test Suites’ architecture from the ground up — inter-processe communication via TCP messages will be required. I think, Katlaon would not like to do. I think, it is not worth doing either.

Hmmm… i did not look closely into the timings…

This does seems misleading now… as the longest suite took 52 seconds to run and total time shows 25 seconds.

Seems like katalon is just showing the average.

@nghi.phan this could easily break the trust if shown to some new users, maybe katalon should fix.

I agree with you.

I don’t know how the recent versions of Katalon Studio implement the parallel execution of tests within a suite. I don’t know it at all.

Previously in 2021, I tried to implement “concurrent execution of test cases” for my own. See my previous post:

While doing it, I found that concurrency does not promise a reduction of the overall time.

I found, that all test cases that use WebDriver are very resource-hungry in terms of network, external browser processes, cpu, memory. Within a single PC, each of them demands instantly the full resources of my PC, consequently the resource contentions force the test cases to run effectively sequentially or even slower.

If I want to achieve an effective parallelism of tests execution, I would look for “distributed tests execution over multiple boxes in a cloud environment”. This would cost much. You need to purchase sufficient number of KRE licenses. I can not afford of it.

Dear Akshay,

A ticket has been created, I will share updates to you when we have any information.

Thanks for the update @nghi.phan

This makes sense to me, thanks for the explanation.

I reproduced this on Katalon Studio 11.6.0 and measured where the time goes.

Setup: one test suite with 4 short API test cases (one POST and a status check each). I ran it three times back to back, changing only the suite’s Execution Information. The public Petstore server returned HTTP 500, so the tests failed, but each test still made its one request, so the timing is valid.

Setting Real time (run start to last process exit) Duration in Katalon’s JUnit_Report.xml
Parallel off 28.0 s 9.5 s
Parallel on, Max Concurrent Instances 1 61.4 s 48.8 s
Parallel on, Max Concurrent Instances 4 67.0 s 39.8 s

Why parallel is slower

  • With Enable Parallel Execution ticked, the suite runs with "orchestration":"ISOLATED_PROCESS" (as seen in plan.jsonl in my report folder). Katalon starts a new Java process for the before-suite listeners, one for each test case, and one for the after-suite listeners. That is 6 processes for 4 tests, each with its own folder and console0.log in the report, all started by katalon.exe. The docs say the same: “Katalon Studio runs each test case in its own process” (Run test cases in parallel in a test suite).
  • Here a test-case process needed about 6 s before its test started (the first one in a run about 15 s). The tests themselves took under 5 s each (up to 8 s when 4 ran at once). With parallel off, that start-up is paid once for the whole suite. In parallel mode, every test case pays it.
  • Max Concurrent Instances defaults to 1. Then every test case still gets its own process, but they run one after another, so you only get the extra start-ups: 28 s became 61 s. That is probably what happened in the first post (5.2 s to 29 s).
  • With 4 at once, the processes slowed each other down while starting: start-up went from about 6 s to 28-30 s each.

Run 3 (Max Concurrent Instances 4), per process. “START” is the time in each process’s own console0.log; start-up is from JVM start to the first listener call.

process                  JVM started   "START" logged   exited       start-up
before-suite listeners   16:09:06.9    16:09:18.9       16:09:19.8   12.9 s
Test 1                   16:09:21.0    16:09:47.4       16:09:57.6   28.1 s
Test 2                   16:09:22.4    16:09:49.0       16:09:58.0   28.5 s
Test 3                   16:09:22.6    16:09:49.7       16:09:58.7   29.1 s
Test 4                   16:09:22.6    16:09:50.6       16:09:58.9   29.9 s
after-suite listeners    16:09:59.7    16:10:12.0       16:10:13.0   13.1 s

Why Katalon’s total is lower than the real time

In run 3, the duration in JUnit_Report.xml starts at 16:09:19.1, after the first process had already booted and logged START, and ends at 16:09:58.9, when the last test case finished. It leaves out the 13 s boot of the first process and the whole after-suite listener process. The run actually went from 16:09:06 to 16:10:13. I did not test collections, but the 25 s vs 52 s difference discussed above looks like the same kind of gap.

What to do

  • For short tests such as API calls, keep Enable Parallel Execution off.
  • Parallel only pays off when each test runs much longer than a process takes to start (about 6 s alone on this machine, about 30 s with 4 starting together).
  • Parallel with Max Concurrent Instances 1 only adds start-up time.

Suggestions for the ticket for @nghi.phan

  1. Reuse a pool of worker processes for the test cases instead of starting a new JVM for each one.
  2. Include process start-up and the listener processes in the reported duration, or show the real elapsed time next to it.
  3. Warn when parallel is on and Max Concurrent Instances is 1.

How I measured: a test listener that writes, in every process, the JVM start time (ManagementFactory.getRuntimeMXBean().getStartTime()), a timestamp at each Before/After hook, and the exit time from a shutdown hook. The times line up with each process’s own console0.log. The screenshots below are from that listener , one per run.

Short version :Katalon’s timer leaves out much of the time spent starting a new Java process for each test, so a parallel run that really took 67 s was reported as 39.8 s.

Tests used

I created a small utility for this tha would give recommendation and all details. Let me know if you need it and i will open source it

Happy Dhanteras and Diwali to everyone :slight_smile:


No guessing now , you have the report now , plug and play tool for this

Ticked “Enable Parallel Execution” in Katalon Studio and assumed your suite got faster? Mine got 4× slower.

Four short API tests:
• Parallel, max 4: 27.2 s
• Parallel off: 6.6 s

84% of the process time went to starting Java processes, not to running tests. In a parallel suite Katalon starts one Java process per test case, and for short tests that start-up costs more than parallel saves. I couldn’t see this clearly anywhere, so I built a free tool that shows it: Run Clock.

It’s a drop-in Test Listener: no plugin, no changes to your test cases or suites. After every run it shows:
• the real time, from Katalon preparing the run to the last Java process exiting
• where the time went: start-up, running tests and shutdown, for every process
• every parallel setting you’ve run for that suite, raced on one clock, and which one is fastest
• for Test Suite Collections, each suite on the collection’s own clock, and Sequential against Parallel
• a warning when a run is slower than usual
• an All runs page to compare any two runs

It also works with Katalon Runtime Engine in CI on Windows, Linux and macOS, with a ready-to-use Azure Pipelines example and a GitHub Action on the Marketplace. Tested on Katalon Studio 11.6 across 43 real runs.

Install:
npx katalon-run-clock install “C:\path\to\your\katalon-project”
Then refresh the project

GitHub Repo : GitHub - montbaga/katalon-run-clock · GitHub
npm: https://www.npmjs.com/package/katalon-run-clock
GitHub Action: Katalon Run Clock · Actions · GitHub Marketplace · GitHub

Free and open source (Apache 2.0). If you try it on a bigger suite, I’d like to hear what your numbers look like.

Great..
I liked the video

The report will also be the same showing your executions overtime and what execution and concurrency helped the tests execute faster or slower

Check the sample report for my own katalon runs in the README of the repo and you wil get an idea how the report would look like

great video

try the utility once and let me know