Skip to content
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

Running tests multithreaded using cucumber scenario paralleliszation is broken #2546

Closed
GianniGiglio opened this issue Sep 6, 2021 · 2 comments

Comments

@GianniGiglio
Copy link
Contributor

GianniGiglio commented Sep 6, 2021

Hi,

Background:
I know this isn't an officially supported way of running serenity with cucumber tests but for our project (fully containerized tests) we use a custom implementation where we run the test directly using a main method (no junit). Doing so we use the cucumber jvm feature to run multithreaded on scenario level instead of feature file. Up until version 2.4.4 everything works fine.

Using a higher version of the serenity gives the following error:

java.util.EmptyStackException
at java.util.Stack.peek(Stack.java:102)
at net.thucydides.core.steps.BaseStepListener.getCurrentStep(BaseStepListener.java:753)
at net.thucydides.core.steps.BaseStepListener.currentStepHasMoreThanOneScreenshot(BaseStepListener.java:991)
at net.thucydides.core.steps.BaseStepListener.removeDuplicatedInitalScreenshotsIfPresent(BaseStepListener.java:977)
at net.thucydides.core.steps.BaseStepListener.take(BaseStepListener.java:954)
at net.thucydides.core.steps.BaseStepListener.takeEndOfStepScreenshotFor(BaseStepListener.java:932)
at net.thucydides.core.steps.BaseStepListener.stepFinished(BaseStepListener.java:781)
at net.thucydides.core.steps.StepEventBus.stepFinished(StepEventBus.java:446)
at net.thucydides.core.steps.StepInterceptor.notifyStepFinishedFor(StepInterceptor.java:515)
at net.thucydides.core.steps.StepInterceptor.executeTestStepMethod(StepInterceptor.java:485)
at net.thucydides.core.steps.StepInterceptor.runTestStep(StepInterceptor.java:458)
at net.thucydides.core.steps.StepInterceptor.runOrSkipMethod(StepInterceptor.java:210)
at net.thucydides.core.steps.StepInterceptor.testStepResult(StepInterceptor.java:197)
at net.thucydides.core.steps.StepInterceptor.intercept(StepInterceptor.java:85)
at net.thucydides.core.steps.ProxyConfiguration$InterceptorDispatcher.intercept(ProxyConfiguration.java:51)

The exception is throw when the screenshot is taken however even when disabling the screenshots the reports are generated completely wrong and steps are mixed in the reports.

I was able to track the change causing the issue 0690c0f

More precisly 0690c0f#diff-2b4bcdac67f1a12b80c7bc0cf08736cdef4e53fdfe8f03447fcab71742d2435fR73

private final ThreadLocal<Stack> currentStepStack;
private final Stack currentStepStack = new Stack<>();

It's likely caused because baseSteplListner is not thread-safe anymore since ThreadLocal is not used anymore for the stack.

@GianniGiglio GianniGiglio changed the title Running tests multithreaded using cucumber scenario paralleliszation is broke Running tests multithreaded using cucumber scenario paralleliszation is broken Sep 6, 2021
@wakaleo
Copy link
Member

wakaleo commented Sep 6, 2021

Running scenarios in parallel is not supported and will not work.

@GianniGiglio
Copy link
Contributor Author

@wakaleo I know it's not supported but seeing you left the ThreadLocal currentStepStack commented out, it felt like the implementation was still unsure.

Pitty since it worked using thread-local but I understand.
It would be great if in the future you decide to support this, it would definitely improve the test execution time and memory consumption since no forks are used and you get a better distribution of the scenario's accross all threads.

I'll close the ticked. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants