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

Notification

Icon
Error

Ensure test resource is initialized with parallel testing?
GreenMoose
#1 Posted : Tuesday, June 26, 2018 12:14:18 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 507

Thanks: 145 times
Was thanked: 66 time(s) in 64 post(s)
[v3.17.0.2]

I have a test project where a static initialization requires a startup-initialization of a resource which then tests are using.

Is there a way to tell NCrunch to run this initialization "isolated" in the context of current test node ("local" or grid nodes)?

E.g. I have test1+2 requiring a test db to be set up, but these tests are allowed to be run in parallel and the test db is setup as part of a static construction, but this causes issues when both tests are starting simultaneously since they both run the initialization routine on (local).

Thanks.
Remco
#2 Posted : Tuesday, June 26, 2018 12:49:02 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
ExclusivelyUsesAttribute can be used for this. Its scope is the machine (not the whole grid), so using this attribute would solve your problem. Though of course this would then prevent the tests from being run in parallel at all.

I would actually solve this in your test code by using a system-wide Mutex for the initialization code. Here's an example of how to do this.
1 user thanked Remco for this useful post.
GreenMoose on 6/26/2018(UTC)
GreenMoose
#3 Posted : Tuesday, December 4, 2018 5:26:02 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 507

Thanks: 145 times
Was thanked: 66 time(s) in 64 post(s)
Remco;12409 wrote:
ExclusivelyUsesAttribute can be used for this. Its scope is the machine (not the whole grid), so using this attribute would solve your problem.

Suppose I have gridnode1, which is used by runner console1 and console2 that may run simultaneously. Will ExclusivelyUsesAttribute ensure that console2 waits for console1 to stop using the resource, if they are both using gridnode1?
Remco
#4 Posted : Tuesday, December 4, 2018 10:45:37 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
GreenMoose;12882 wrote:

Suppose I have gridnode1, which is used by runner console1 and console2 that may run simultaneously. Will ExclusivelyUsesAttribute ensure that console2 waits for console1 to stop using the resource, if they are both using gridnode1?


Yes :)

The list of used resources is included in the data packet sent by the grid node to the client when it requests additional work, and it is an important consideration for the client when selecting a task to assign to the node.
1 user thanked Remco for this useful post.
GreenMoose on 12/5/2018(UTC)
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.029 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download