Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Why are tests with the [Serial] attribute distributed to several nodes?
royboy23
#1 Posted : Friday, January 15, 2016 12:23:36 PM(UTC)
Rank: Member

Groups: Registered
Joined: 3/3/2014(UTC)
Posts: 21
Location: Germany

Thanks: 3 times
Hi,

I just noticed that while tests marked with the [Serial] attribute are not parallelized on a single node, they are still distributed to several different nodes. This makes me wonder if the tests are actually run one after another.

So, my question is: Are tests marked with the [Serial] attributed implicitly parallelized when using multiple processing nodes? If not, why do you distribute them at all? After all it seems that it would be simpler and faster to just run them all on a single node.

Thanks in advance for your help.
Remco
#2 Posted : Friday, January 15, 2016 9:26:13 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi,

Thanks for posting.

The SerialAttribute works internally through a combination of ExclusivelyUsesAttribute and InclusivelyUsesAttribute.

When this attribute exists, NCrunch internally does the following:
1. All tests within the project become implicitly marked with InclusivelyUses("Test Runner")
2. All tests within the project using the SerialAttribute become implicitly marked with ExclusivelyUses("Test Runner")

The end result is that on one machine, no test is allowed to run concurrently with another test that declares SerialAttribute.

These concurrency constraints are always at machine level. This makes them advantageous in a situation where the constraint is local - for example, you may have a local file or database server running on your development machine that also exists on every grid node. In such a situation, distributed processing is extremely helpful as it gives you much more capacity even when constraints exist.

The downside is that this doesn't work well for distributed environments that are centrally constrained. For example, you may have a database server that is shared by all nodes on the network. At present, there is no way to add a concurrency constraint that would apply to all these nodes allowing only one to use the database at any one time. The reason this feature doesn't yet exist is because to do it effectively in a team-based environment would require a distributed mutex in which the grid nodes would coordinate with each other to handle the concurrency constraints. At present the distributed processing doesn't have the concept of a controller node to coordinate such a mutex.

I think this is the question you're asking ... Or are you asking in terms of the meaning of the SerialAttribute itself? At the moment, this attribute has no impact on the sequencing or batching of test execution.
1 user thanked Remco for this useful post.
royboy23 on 1/16/2016(UTC)
royboy23
#3 Posted : Saturday, January 16, 2016 2:28:26 PM(UTC)
Rank: Member

Groups: Registered
Joined: 3/3/2014(UTC)
Posts: 21
Location: Germany

Thanks: 3 times
Hi Remco,

Thanks for your quick reply. You are correct, I was looking for a way to make some tests run one after another globally, not just per ncrunch node. The reason is that these tests are using a database mutex and all nodes are using the same database.

I guess the only way to achieve this is by using the serial attribute and also adding a capability to only one of the nodes that that the test is supposed to be using. Or is there any simpler workaround?

Remco
#4 Posted : Sunday, January 17, 2016 12:09:45 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
royboy23;8243 wrote:

I guess the only way to achieve this is by using the serial attribute and also adding a capability to only one of the nodes that that the test is supposed to be using. Or is there any simpler workaround?


Using SerialAttribute with RequiresCapabilityAttribute is the quickest and simplest way to implement this. Unfortunately, it would mean targeting the tests to a specific node, but you likely would receive little benefit from the parallelisation or distributed processing if these tests have a central dependency anyway.

It may be worth using ExclusivelyUsesAttribute instead of SerialAttribute if you have other tests that are able to run concurrently with these database tests. It would be painful to wait for your database tests to finish before any unrelated and unrestricted unit tests could be run.

I recommend examining ways to tweak your test code to remove the concurrency constraint. One possible option could be to have a separate database or schema per grid node, so that the nodes wouldn't be restricted by access to only one database. You could derive the connection string using some parameter on the grid node, like System.Environment.MachineName for example. This would give you significantly higher throughput and better response times from the engine - assuming the database server can keep up with the demand.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.035 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download