-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Isolate tests and run concurrently #1159
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
Isolate tests and run concurrently #1159
Conversation
Awesome job |
* Uses the same generation method as the built in tmpdir, simply returns a different object type.
* We've selected a concurrency number of 16 because that's how many CPUs the multiprocessing library tells us a Travis box has.
This is needed because the various activities that exericsing the tests do will cause files to change inside this data directory. If we do not make it test specific then we run into concurrency issues.
Previously pip was always installed directly from the source tree however this causes concurrency issues so it is now copied into the temporary directory and installed from there.
There seems to be some issues with parallel tests and Python 3.2 in pytest or pytest-xdist, so we run the tests normally for now on 3.2.
Isolate tests and run concurrently
@@ -20,4 +24,4 @@ branches: | |||
- 1.3.X | |||
- 1.4.X | |||
env: | |||
- PIP_USE_MIRRORS=true | |||
- PYTHONHASHSEED=0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where does this apply? 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Python 3.3+ hash randomization is on by default, this confuses pytest-xdist. Setting the hash seed to zero effectively disables hash randomization.
See https://bitbucket.org/hpk42/pytest/issue/346/pytest-xdist-and-python-33-is-sort-of
merge 👍 ex post facto |
tmpdir
fixture with our own that returns atests.lib.path.Path
object.virtualenv
fixture which creates a virtual environment in the per test temporary directory.script
fixture which creates an instance ofPipTestEnvironment
using the per test virtual environment.data
fixture which copies all of the test data into the per test temporary directory so tests can interact with it.tests_cache
directory the helperslocal_repo
andlocal_checkout
now cache to a per test specific temporary directory.The bulk of the work of this PR is in isolating the tests from each other. To do that it uses the py.test
tmpdir
to give each test a unique temporary directory and then moves all of the operations that modify the filesystem in any way to take place inside of that temporary directory. It adds some other fixtures and modifies some helpers along the way to make doing that a bit nicer.The easiest part of the PR was enabling the actual concurrent builds. We use 8 concurrent builds because that seems to give us the most bang for the buck without making PyPy dreadfully slow (I'm unsure of why but using 16 processes made PyPy take twice as long as 8 processes). However I was unable to use concurrent builds on Python 3.2 because of an apparent bug in py.test or pytest-xdist. I will follow up with upstream to attempt to sort out why 3.2 was erroring out and then submit another PR to enable concurrent builds for it. This means PRs still take awhile to pass but at least there is some quick feedback.