Daily Usage Issues

Ncrunch 5 Task Capacity Defect

Started by fidel on 2,435 views

Ncrunch 5.6

I use integration tests within Ncrunch grid server.
With Xunit.

I need to run tests exactly one by one. ( on each node)

So on develop machine i disable paralell execution set Paralell Execution enabled = false set up maximum worker = 1

On remote machine which has Task Capacity = 16 it still run tests in parallel.

In my tests i write Start/Finish to text file and i see that it executes all tests in parallel.
Only one thing where i was able to do it one by one is to set on Grid Server on remote Task Capacity = 1.

This works weird, i thought if i use xunit collection attribute then it guarantees that only one execution in the same moment.
Same for ncrunch if i set Paralell Execution enabled = false i expect that even on remote servers it will run tests one by one.

Now I am confused, is that only one way in V5 to execute them one by one?

I found that my tests works when they distributed to 1 remote ncrunch test runner process (in Processing Queue window)
otherwise when they get to 2 processes (despite on option Max Threads = 1 and Allow paralell = False), they are executed simultaneously and fails.
How to avoid that without reducing grid Task Capacity on each grid node?

Edited

Hi, thanks for posting.

Disabling parallel execution should prevent tests being run at the same time by NCrunch on a single system. This means you can still end up with parallel execution if you're using a grid (for example, you might have one test running on your local machine, while another test runs on the remote grid node).

NCrunch doesn't integrate with Xunit's collection attributes. If you have xunit features set up to run tests in parallel, this does have the potential to undercut NCrunch's own parallelisation controls and can result in instability, including tests being run on background threads inside the test process.

It is not required to set your max processing threads to 1 to suppress parallel execution. Disabling parallel execution via setting should do the trick.

Something to be aware of is that it's still possible to have multiple processes running at one time, though when this happens NCrunch will only call them one at a time to execute tests. This is because NCrunch pools test processes for optimisation purposes.

If you have multithreaded behaviour in your tests (or xunit is somehow forcing its own parallelisation), this could cause parallel execution across these processes. For example, if you have a test that kicks off a background thread that continues runs after test execution is complete, this can then overlap execution of the next test. NCrunch cannot prevent such behaviour and it should be avoided in your code.

To introduce finer control of parallelisation, I recommend looking into ExcusivelyUsesAttribute.

Edit: I strongly suspect your parallel behaviour is being caused by xunit. I recommend removing/disabling your xunit collection attributes to see if this rectifies the behaviour.

Edited

Thanks for comprehensive answer.

Looks like it was my bad.
So I disabled in Global settings Paralell Execution, but in Shared settings it was enabled.
When i disabled it, All tests now works super well as designed.



I overlooked that
Sorry.
Have a nice day!
This post has been deleted.

Post a reply

Log in to reply.