parallel="methods" + dependsOnMethods()

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

parallel="methods" + dependsOnMethods()

tarun3kumar

Hi,

Some pseudocode:
 parallel="methods" thread-count="10"
 void testA()
 void testB() dependsOnMethods( "testA")
 void testC() dependsOnMethods( "testA")
 void testD() dependsOnMethods( "testC")

Leads to:
 [TestRunner] WILL BE RUN SEQUENTIALLY:
 testA
 testB
 testC
 testD
 ...
 [pool-1-thread-1] testA
 [pool-1-thread-1] testB
 [pool-1-thread-1] testC
 [pool-1-thread-1] testD

So only one thread is used like:
testA -> testB -> testC -> testD

Expected behavior: TestNG would branch into 2 threads: (some kind of RFE?)
testA
 |-> testB
 |-> testC -> testD

So first A runs in one Thread. Afterwards B and C run in seperated Threads.  After C got finished, D runs in the same Thread as C.

I hoped, that testNG will use as many Threads as possible, honoring the dependencies as some kind of hint. Possible, that im just using something in the wrong manner. It seems like TestNG runs all depending Methods in the same Thread as sequence.

I think it would be a nice feature, when TestNG would split the test into different Threads, when 2 or more Methods got the same dependsOnMethod (the dependency run at last). Im not sure if it could lead to side effects. Maybe this would be hard to implement and as such error prone.

Regards,
Neuhauser Bernhard
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=61241&messageID=119046#119046


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: parallel="methods" + dependsOnMethods()

Cédric Beust ♔
Hi Bernhard,

I'm not sure TestNG is wrong in this particular case.

The methods that depend on TestA need to be run in the same thread as TestA, otherwise, the dependencies might not be honored.  Once TestA is run in a particular thread, all the methods that depend on it (directly or indirectly) are pinned to that thread as well.

But I see what you are saying, and you are actually asking for a different implementation than what TestNG is doing.

There are two ways to guarantee that a method B is run after a method A:
  1. Run them in the same thread, sequentially.
  2. Run them in different threads and make B wait for ("join") A to finish before starting.
Your approach could only be implemented with method 2), which comes with a lot of complexity in itself.

Also, I'm not convinced that method 2) would necessarily result in a faster execution, since a lot of threads will be allocated (the pool will probably be always completely allocated), therefore requiring a lot of context switching, and there will also a lot of synchronization going on, which will result in a lot of potential for deadlocks and harder to debug test lock ups.

Just a few thoughts, I could be wrong, I haven't really thought about this much...

Let me know what you think.

--
Cedric


1/29/07, Cybernd <[hidden email]> wrote:

Hi,

Some pseudocode:
parallel="methods" thread-count="10"
void testA()
void testB() dependsOnMethods( "testA")
void testC() dependsOnMethods( "testA")
void testD() dependsOnMethods( "testC")

Leads to:
[TestRunner] WILL BE RUN SEQUENTIALLY:
testA
testB
testC
testD
...
[pool-1-thread-1] testA
[pool-1-thread-1] testB
[pool-1-thread-1] testC
[pool-1-thread-1] testD

So only one thread is used like:
testA -> testB -> testC -> testD

Expected behavior: TestNG would branch into 2 threads: (some kind of RFE?)
testA
|-> testB
|-> testC -> testD

So first A runs in one Thread. Afterwards B and C run in seperated Threads.  After C got finished, D runs in the same Thread as C.

I hoped, that testNG will use as many Threads as possible, honoring the dependencies as some kind of hint. Possible, that im just using something in the wrong manner. It seems like TestNG runs all depending Methods in the same Thread as sequence.

I think it would be a nice feature, when TestNG would split the test into different Threads, when 2 or more Methods got the same dependsOnMethod (the dependency run at last). Im not sure if it could lead to side effects. Maybe this would be hard to implement and as such error prone.

Regards,
Neuhauser Bernhard
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=61241&messageID=119046#119046







--
Cédric
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: parallel="methods" + dependsOnMethods()

tarun3kumar

Hi Cedric,

> But I see what you are saying, and you are actually asking for a different
> implementation than what TestNG is doing.

Yes.
(Not exactly, because its not badly needed.)

Just wanted to tell you, that a more flexible thread-dependency featureset might be useful for some scenarios.

Personally i compensated the lack of such a feature by removing all dependencies and adding manual sync.

> Also, I'm not convinced that method 2) would necessarily result in a faster
> execution, since a lot of threads will be allocated (the pool will probably

Its not a question of execution speed. I just want to be as close as possible to the true environment. The Appserver will also execute requests multithreaded.

Bernhard
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=61241&messageID=119317#119317


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---