Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stack test should not run concurrently by default #482

Closed
pseudonom opened this issue Jul 2, 2015 · 11 comments
Closed

stack test should not run concurrently by default #482

pseudonom opened this issue Jul 2, 2015 · 11 comments

Comments

@pseudonom
Copy link

As far I understand things, in a multi-project stack directory, tests are run concurrently (using getNumCapabilities). This has the potential to cause spurious errors for test suites which are not concurrency safe (and has for a stack directory I'm working with). That is,stack test fails where stack test foo && stack test bar succeeds.

Setting jobs: 1 in stack.yaml resolves the problem, but I didn't find this in the documentation.

@mboes
Copy link
Contributor

mboes commented Jul 2, 2015

I consider this a doc problem, rather than a defaults problem: if test suites claim exclusive access to system resources, then arguably this is a bug in the test suites, or if test suites really must claim exclusive access to system resources, then they should learn to block rather than fail waiting for the resource to become available.

I think it's important to make the common case predictable and efficient. The common case is that test suites don't claim global resources, hence making things single-threaded by default would be an unnecessary pessimization for the common case. Running test suites concurrently is also consistent with stack build behaviour.

@pseudonom
Copy link
Author

I agree that better documentation would go a long way.

Our use case doesn't seem so exotic. We're doing integration tests with a database. At the end of each test suite, the suite cleans up after itself by truncating the tables it touched. When run concurrently, this clean-up is likely to break any other executing suites touching those tables.

I think it's important to make the common case predictable

I think the current behavior is rather unexpected. It took me quite a while to figure out why cd foo; stack test and stack test foo worked where stack test did not.

Running test suites concurrently is also consistent with stack build behaviour.

From the outside, it's not apparent to me why stack build and stack test should be consistent with each other. They seem like very different operations.

@snoyberg snoyberg added this to the 0.2.0.0 milestone Jul 2, 2015
@snoyberg snoyberg modified the milestones: 0.2.0.0, 0.3.0.0 Jul 2, 2015
@snoyberg
Copy link
Contributor

snoyberg commented Jul 2, 2015

For the record, we've had users request specifically to have their tests run in parallel, so it's impossible to have a default that satisfies everyone's expected default behavior. The current behavior though does provide consistency with both cabal and the rest of the build experience (which is in parallel), and for most use cases will work and be faster.

In other words: I agree with @mboes here about keeping the default as-is.

@gregwebs
Copy link
Contributor

gregwebs commented Jul 2, 2015

Regardless of the default, is there a way to configure the number of jobs differently for building and testing (or otherwise indicate to only run tests in serial) ?

@snoyberg
Copy link
Contributor

snoyberg commented Jul 2, 2015

No, not currently. Added a lock such that only one test job can run at a time is straightforward though.

@gregwebs
Copy link
Contributor

gregwebs commented Jul 2, 2015

since it seems unlikely that the default will be changed, I opened #492. We can close this issue after updating the docs

@gregwebs
Copy link
Contributor

gregwebs commented Jul 2, 2015

I put a blurb about project testing at the bottom of the Architecture page. Feel free to edit/move it

@mboes
Copy link
Contributor

mboes commented Jul 3, 2015

I don't think caveats about project testing and further info about usage have their place in the Architecture doc, which documents the design. Moving to the FAQ.

@mboes
Copy link
Contributor

mboes commented Jul 3, 2015

@mboes mboes assigned mboes and unassigned mboes Jul 3, 2015
@gregwebs
Copy link
Contributor

gregwebs commented Jul 3, 2015

great! I removed a few superfluous sentences from the entry.

@pseudonom
Copy link
Author

Thanks, looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants