[maven-surefire-plugin] Stop a thread on a parallel run

147 views
Skip to first unread message

Asaf Bitton

unread,
Jun 11, 2019, 2:55:56 AM6/11/19
to testng-users
Hi all,

I am executing my tests in parallel using the parallel parameter of maven-surefire-plugin.

I want to be able to stop an execution of a single thread on a test failure, while keeping the other threads running (the rest of the tests).

Can it be done?

Already tried the JAVA way of using 
interrupt() without any success.

Thanks.

⇜Krishnan Mahadevan⇝

unread,
Jun 11, 2019, 4:51:20 AM6/11/19
to testng...@googlegroups.com
>>>>> I want to be able to stop an execution of a single thread on a test failure, while keeping the other threads running (the rest of the tests).

I didn't quite understand what do you mean by this? Are you saying that, TestNG should refrain from reusing a thread, on which there was a test failure already?

If yes, what exactly are you trying to achieve? Please elaborate your use case, and the problem statement that you are trying to solve.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/55c4f1b8-bb99-45af-a4aa-758307ca07fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Asaf Bitton

unread,
Jun 11, 2019, 5:44:31 AM6/11/19
to testng-users
I have an API Testing infrastructure which gets a list of machines to test against (list contains machines ip addresses that are running my app - same app on each machine).
Let's assume I have 10 machines.
The infrastructure then starts with threadCount=10.
On each test start It is being assigned with an IP (in order to be used in that test)...each IP is being reused by the same thread or by multiple threads (# test > 10)
I want to be able to stop the execution of a thread that had a test failure in its run (while removing the failed machine from the machines_list) so there will be only 9 (or lower) threads running (against 9 machines...or lower in case of multi threads failures).

There may be another solution that I am missing so let me know if you think of one...

 
On Tuesday, June 11, 2019 at 11:51:20 AM UTC+3, Krishnan Mahadevan wrote:
>>>>> I want to be able to stop an execution of a single thread on a test failure, while keeping the other threads running (the rest of the tests).

I didn't quite understand what do you mean by this? Are you saying that, TestNG should refrain from reusing a thread, on which there was a test failure already?

If yes, what exactly are you trying to achieve? Please elaborate your use case, and the problem statement that you are trying to solve.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/


On Tue, Jun 11, 2019 at 12:25 PM Asaf Bitton <asaf....@ridewithvia.com> wrote:
Hi all,

I am executing my tests in parallel using the parallel parameter of maven-surefire-plugin.

I want to be able to stop an execution of a single thread on a test failure, while keeping the other threads running (the rest of the tests).

Can it be done?

Already tried the JAVA way of using 
interrupt() without any success.

Thanks.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng...@googlegroups.com.

Krishnan Mahadevan

unread,
Jun 12, 2019, 12:14:37 AM6/12/19
to testng...@googlegroups.com

Asaf,

 

Interesting problem statement Thanks for adding more context.

 

What if we abstracted out the machine IP information from the tests and did something like this:

 

  1. You build a IInvokedMethodListener which would be used to query the App Info (IP address of the machine where the app is running).
  2. The listener’s beforeInvocation() from (1) would query query a singleton like structure to retrieve the App info and then pack that information inside the ITestResult object as an attribute.
  3. The @Test method queries its own ITestResult object (via Reporter.getCurrentTestResult()), retrieves the App Info from the attribute and runs the test.
  4. The listener’s afterInvocation() from (1) would check if the current test method failed and if it failed, it would update the singleton like structure to remove the App Info for which the current test ran.

 

Would this work ?

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.com/

To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.


To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.

Asaf Bitton

unread,
Jun 13, 2019, 3:55:46 AM6/13/19
to testng-users
Sounds like it should to the trick.
I'll try to implement it, or at least use the logic, and let you know how it went.
Reply all
Reply to author
Forward
0 new messages