-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Parallel execution: *same_thread* cucumber option does not ensure that a feature file is solely ran by a single thread #2900
Comments
Very interesting. Unfortunately, I'm just as puzzled as you are. And the backlog of things to do for Cucumber well exceeds the time I can reasonably spend on it. So your active participation will be required for a resolution.
Your theory seems consistent with observations. But a few points of note:
So a good first step would be to create a minimal reproducer based on the You may also want to check your code for other interactions with
Let me get you up to speed on the architecture. The Cucumber JUnit Platform Engine uses the JUnit Platform. The JUnit Platform provides an API for describing and executing tests. Tests are represented by a tree of Lines 35 to 41 in 8769e8d
When executing the Lines 64 to 72 in e9f99b1
So any debugging efforts you'll probably want to focus on |
Comes to mind, you mentioned you were using |
Sorry for the late response. Thank you for the explanation, it makes sense how the executor works! And yes, during a rebase of the branch, we downgraded back to the version 7.3 (it was supposed to be 7.17 for this branch) and therefore, the same_thread option was not implemented and not working. Changing cucumber version back to a version after 7.7 made the tests run as intended. It is easy to overlook something like this when you had previously set it and it got changed on a branch update. |
👓 What did you see?
Result
Small test suite
Output is: [Feature file name] || Scenario name => Thread Id
This is company code, and I am not exactly sure what I can share about it, so I took the liberty to alter the names of the results. However, this is what I see when I run a small test suite in parallel, with a fixed strategy, with 4 threads and the execution mode as same_thread. I tracked the results by creating a concurrent Queue, where I store the feature file, scenario name and thread id in the @ Before Hook. I highlighted and organized the results to be easier to read:
So, in this test suite, most feature files are only ran by the parent thread (as expected ✅). However, the last feature file is ran by more than one thread (not as expected ❌).
Large test suite
This behavior also appear in a larger test suite, namely, when testing 335 scenarios over 50 feature files. Again, the test has the exact same cucumber options has the small test suite, and for simplicity sake I am going to give a summary of the results:
✅ What did you expect to see?
I expect to see ALL feature files being ran by the parent thread when utilizing the cucumber.execution.execution-mode.feature=same_thread option.
📦 Which tool/library version are you using?
Language
Java 17
Compiler
Maven
Docker image
maven:3.8.5-openjdk-17-slim
Junit Version
5.9.2
Cucumber Version
7.3.0
🔬 How could we reproduce it?
Mock
📚 Any additional context?
Pre discussion
Theory
According to the results I obtained, I would like to describe a scenario to explain what I believe might be happening:
Structure
Execution
In broader terms, it is generally great to have a pool of resources that we can assign work to as soon as a resource frees up, ensuring we maximize their usage and they spend the least amount of time idling, so we can finish our workload faster.
However, looking at the task we have at hand, we really don't want at any point in time for two (or more) threads to utilize the same data within a feature file. If the data is not properly taken care before being used in a scenario, our tests will fail with erroneous results.
Possible Action
Is it possible to ensure that when there are no more feature files to be ran, the scenarios that are still waiting to be executed from other feature files will not grab a thread from the resources pool, and just wait for the parent thread of that feature file to execute them?
The text was updated successfully, but these errors were encountered: