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

Notification

Icon
Error

Exclusively uses attribute seems to not be working
CourtJesterBob
#1 Posted : Wednesday, June 4, 2014 4:38:53 PM(UTC)
Rank: Member

Groups: Registered
Joined: 7/2/2012(UTC)
Posts: 13
Location: Beachwood, OH

I just recently upgraded to Visual Studio 2013 and the version of NCrunch for 2013.

I have a solution with several projects of "integration" tests that use a database. I had previously added an assembly attribute to each of these project to set the ExclusivelyUses property to that all IntegrationTests share the same ExclusivelyUses value. Now, when I have NCrunch re-build and re-run all tests, I get some subset of them failing. If I run them all one at a time, they all pass. Or, if I run all the tests in a single solution with the "Run selected test(s) in new process" button, they all pass. It feels like the exclusively uses attribute does not work across projects in the solution.

Bob
Remco
#2 Posted : Wednesday, June 4, 2014 10:51:12 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 932 times
Was thanked: 1259 time(s) in 1172 post(s)
Hi Bob,

When upgrading to VS2013, did you also upgrade to a new version of NCrunch? (i.e. from 1.48 to 2.7?) Or was it just to a different build of NCrunch under the same version (i.e. v2.7 VS2012 to v2.7 VS2013)?

A useful thing I think we should check is whether or not the engine is actually detecting the ExclusivelyUses attribute. In the Tests Window, right click the columns and choose to show the 'Exclusively used resources' column. When all your tests are showing in the window, does this column show their usage of the resource?

Also, are you using distributed processing?
CourtJesterBob
#3 Posted : Friday, June 6, 2014 3:13:23 PM(UTC)
Rank: Member

Groups: Registered
Joined: 7/2/2012(UTC)
Posts: 13
Location: Beachwood, OH

Yes, when I installed VS2013 I installed 2.7.0.5 of NCrunch because I had only installed the 2012 version.

The tests windows does indeed show the correct value on all of the tests.

I am not using distributed processing, that I know of.
Remco
#4 Posted : Saturday, June 7, 2014 12:49:13 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 932 times
Was thanked: 1259 time(s) in 1172 post(s)
Ok - that narrows things down a bit. The next thing we should check is the behaviour of the tests in the processing queue. If you set the filters on the queue to show only executing tests, and turn on the 'Exclusively Used Resources' column, do you see any evidence of the engine running tests concurrently that make use of the same resource?

The area of the engine that handles resource locking is very mature and hasn't seen any work for a long time, so I think there may be more going on here. Something that hits my mind is the nature of database connectivity. If you have a test that holds an open database connection (perhaps including locks on database tables or resources) after its execution has completed, this can create a concurrency problem for NCrunch ... as NCrunch will not be aware of the locked resource and will simply execute the next test, possibly inside a different test process.

ADO.NET often tends to pool database connections, which means that it could still be possible that the test process is holding open connections to the database after its tests have finished executing. Off the top of my head I'm not aware of any situations where a SQL server database would retain locks using a connection stored in the pool, but there's quite a bit that can go on here and I'm not sure what kind of database you're working with.

Something that may help with such an issue is to try setting the Test process memory limit to '1'. This will cause NCrunch to terminate each test process after it's finished an execution run, which may help break up resource locking. Because this will stop NCrunch from re-using test runner processes, it will also reduce the engine to a crawl - so it's probably only useful in helping to further narrow down the problem.
CourtJesterBob
#5 Posted : Tuesday, June 10, 2014 12:51:46 PM(UTC)
Rank: Member

Groups: Registered
Joined: 7/2/2012(UTC)
Posts: 13
Location: Beachwood, OH

I tried re-running all of my tests as you suggested. I couldn't figure out how to show only the executing tests. I also don't know how to recognize which test is running. I see multiple tests with the stopwatch icon and their status says "Running (Failed last run), Prioritised". I have a screenshot, but I don't see any way to attach it.

I am reluctant to set the process memory limit as I have thousands of tests and I don't want them all to crawl.
Remco
#6 Posted : Tuesday, June 10, 2014 10:47:29 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 932 times
Was thanked: 1259 time(s) in 1172 post(s)
The processing queue window has a number of filters on the toolbar to control which tasks are shown in the view. I recommend turning on the 'Stopwatch' option and leaving the rest turned off, as this will make it possible to see which tasks are running at any one time. If you have the 'Exclusively Used Resources' column showing in the window, you won't need to see the test names inside each task in order to know that they're using the same resource (as it'll be shown next to the task). If you don't see the toolbar options for filtering on this window, try updating to a later version of NCrunch. The filters were introduced in V2 and won't be available under V1.

I definitely don't recommend actively working with the test process memory limit set to 1, but I do suggest trying this for a few engine cycles as it will help us to further narrow down the problem.
CourtJesterBob
#7 Posted : Friday, June 13, 2014 1:04:30 PM(UTC)
Rank: Member

Groups: Registered
Joined: 7/2/2012(UTC)
Posts: 13
Location: Beachwood, OH

So, I monitored the Processing Queue window like you suggested. I chose to , Resynchronise, rebuild, and rerun all tests. I have the project marked with the exclusively uses attribute at the assembly level.

During processing I can see one main row, with a stopwatch icon that says processing and it has the correct name of the project under test as the target. The exclusively uses column is set correctly. When I expand that row, I can see multiple tests under that main row. They do not have their exclusively uses column set at all and they both have green stopwatches on them.
Remco
#8 Posted : Friday, June 13, 2014 10:17:31 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 932 times
Was thanked: 1259 time(s) in 1172 post(s)
Ok - this suggests the engine is behaving correctly by not running tests concurrently when they use the same resource.

The test tasks themselves are batches, so all tests within each batch are run synchronously within the same process.

How did you get on with the test process memory limit? Did this make any difference? I strongly suspect that the resource problem you're experiencing is due to resource cleanup after tests complete their execution.
1 user thanked Remco for this useful post.
morten05 on 4/13/2015(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.052 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download