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

Notification

Icon
Error

Possible to retry failed tests if particular regex(es) match output?
Peter Mounce
#1 Posted : Monday, September 16, 2013 8:12:20 AM(UTC)
Rank: Member

Groups: Registered
Joined: 1/18/2012(UTC)
Posts: 15
Location: London, UK

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
We use NCrunch a lot, and really like it. However, we also test ServiceStack-based sites with it, in-process. ServiceStack 3.9.x has a static that gets in the way when running lots of end-to-end tests in parallel - the exception is

Code:
System.IO.InvalidDataException: System.IO.InvalidDataException : HttpListenerBase.Instance has already been set
at ServiceStack.WebHost.Endpoints.Support.HttpListenerBase.Init()


We've done one thing to randomise the port on which the ServiceStack AppHost listens, when the test spins up the listener, so we don't get port conflicts. Our tests are xunit 1.9.x based.

We want to keep NCrunch cranked up to 11, running all our tests in parallel - but we'd also like it to be intelligent enough to be told that if it sees that stacktrace (well, a regex would be ample), it should retry that test before marking it as failed.

We'd like the retries to be configurable, and have some input into the scheduler - in our case, we'd want to wiggle around the tests so that the ones that fail for this reason are scheduled to not necessarily run concurrently, since the chances of passing are then higher.

Or, perhaps there's something odd going on in that one test is starting before a previous test is all the way torn down...?
Remco
#2 Posted : Monday, September 16, 2013 9:46:26 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)
Hi Peter -

From what you've described, the setup you're using should allow NCrunch to run these tests in parallel. Because the tests are always in separate processes and you're testing in-process, there shouldn't be any interference around the parallelisation of the tests. The randomisation of port numbers is extremely unlikely to give you trouble - if it does, you can try seeding the random values using the test runner's process ID, as this will always be unique between parallel threads.

I think that this problem is being caused somehow by the tests themselves being sequence dependent. Where the sequence dependency exists is an interesting question and it may take some diving into SS.NET to figure out. If there is something in your test code that makes a call to HttpListenerBase.Init (directly or indirectly), you may wish to try controlling access by checking against another static member beforehand, i.e. only call this method if it hasn't been called before in the current application domain/process.

I'm wondering if it may be possible to easily reproduce this problem by running the same test twice. If you have a test throw this out at you, try right clicking on the test in NCrunch, going to Advanced, then choosing to run it using an existing task runner process. Try this a few times to make sure you do actually get the same task runner twice. If its a simple static reinitialise call, then this should surface the problem and make it easier to isolate/fix.

The regex idea on retrying for particular stack traces is a really good one. I'd been looking to retry options for flakey tests and the regex concept will definitely help with this - I'll note it down :)

Cheers,

Remco
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.050 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download