Skip to content

Make freeze functional tests depend on less external services #2509

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

Closed
wants to merge 10 commits into from

Conversation

msabramo
Copy link
Contributor

@msabramo msabramo commented Mar 9, 2015

This change:

  1. prevents a failure if we can't reach:
    • bazaar.launchpad.net
    • bitbucket.org
    • github.com
    • pypi.python.org
    • svn.colorstudy.com
  2. for me this reduced the time to run:
.tox/py27/bin/py.test tests/functional/test_freeze.py --tb=short

from 90 seconds to 76 seconds. I think that a lot of the remaining time is spent on creating virtualenvs rather than downloading things.

os.path.dirname(__file__),
'..', 'data', 'repos', 'bzr', 'django-wikiapp', 'release-0.1'
)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not looked at this in context, but should this not use the test data directory fixture data?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh probably. I'm having trouble grokking how the tests fit together.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, updated.

@msabramo
Copy link
Contributor Author

msabramo commented Mar 9, 2015

By the way, I notice that even without hitting the network, these tests are pretty slow and it seems like a good chunk of time is spent on creating the virtualenvs -- any ideas for how to speed that up?

@msabramo msabramo force-pushed the faster_tests branch 2 times, most recently from c9e0f73 to 7754f36 Compare March 9, 2015 17:10
@msabramo msabramo changed the title Make test_freeze_bazaar_clone not depend on bazaar.launchpad.net Make freeze functional tests depend on less external services Mar 9, 2015
@pfmoore
Copy link
Member

pfmoore commented Mar 9, 2015

Nope, on Windows creating virtualenvs seems to fail with no explanation (at least sometimes, it hit me earlier today). Someone with way more time than I have needs to get the tests working on Windows (or lots of people need to fix them one little bit at a time, as per your posting on distutils-sig - do you have access to an army of open-source enthusiasts who are Windows experts? ;-))

@msabramo msabramo force-pushed the faster_tests branch 2 times, most recently from 141cdab to cef7910 Compare March 9, 2015 23:49
@msabramo
Copy link
Contributor Author

test_install could use the same treatment.

But tests are passing so this could be merged as-is. Either way.

@msabramo msabramo force-pushed the faster_tests branch 2 times, most recently from 2c99b6f to 0a3be72 Compare March 10, 2015 07:14
@xavfernandez
Copy link
Member

Do we really need to include the whole django-wikiapp ? We could certainly make a simplebzr module and put it in a bzr repo. Maybe even via a fixture ?

Edit: something similar to https://github.com/pypa/pip/blob/develop/tests/lib/__init__.py#L461-L485 maybe ?

@dstufft
Copy link
Member

dstufft commented Mar 10, 2015

We don't need too. The pip tests have a bad habit of using whatever package the person writing the test happened to be using at the time. We should absolutely try to get rid of these things and use dummy packages. Ideally local test fixtures where possible.

On Mar 10, 2015, at 8:00 AM, Xavier Fernandez [email protected] wrote:

Do we really need to include the whole django-wikiapp ? We could certainly make a simplebzr module and put it in a bzr repo. Maybe even via a fixture ?


Reply to this email directly or view it on GitHub.

@msabramo
Copy link
Contributor Author

Yeah, I just pulled that in because that's what it had, but I could certainly change it to use something a little smaller.

The fixtures -- hmmm -- I guess I could see using fixtures for dynamically creating git repos (since you had to have git to clone the pip tree) and maybe mercurial because most folks probably have that, but I don't know if I would use that for bzr and then force people to have bzr on their system. I feel like for bzr I would rather commit a small package -- you guys okay with that?

@pfmoore
Copy link
Member

pfmoore commented Mar 10, 2015

Surely if you don't have bzr the bzr tests won't work anyway, so needing bzr as a prerequisite to setting up a bzr test isn't any extra issue? Just don't try to create the bzr repo at the start of the test run and fail everything if you can't ;-)

@msabramo
Copy link
Contributor Author

@pfmoore: Good point. I hadn't had my coffee yet. I could probably just skip the test if bzr is not available.

Crap - now I need to look up how to use bzr again :)

@msabramo
Copy link
Contributor Author

@dstufft, @pfmoore : You okay with the overall idea of this though?

@pfmoore
Copy link
Member

pfmoore commented Mar 10, 2015

Sure. Anything to make the tests less fragile :-)

@msabramo
Copy link
Contributor Author

Cool, I'm on it

@msabramo
Copy link
Contributor Author

I just made a bunch of changes to test_freeze_git_clone to make it use a dynamically created git repo (created with tests.lib._create_test_package) instead of cloning from GitHub. This seems like it will be more robust and it doesn't require network access.

I still need to do something similar for the bzr test.

@msabramo
Copy link
Contributor Author

BTW, I wouldn't tackle it here, but has there ever been discussion of moving all the VCS code out into some kind of plugins? That seems like it would remove a good bit of code from pip, though of course we'd have to come up with an API.

@msabramo msabramo force-pushed the faster_tests branch 3 times, most recently from d210efc to 5cc6fa8 Compare March 10, 2015 17:29
@msabramo
Copy link
Contributor Author

I changed test_freeze_bazaar_clone in 86fcd3c so that it dynamically creates a small toy bzr repo for testing purposes and I removed the copy of django-wikiapp.

None of the tests in test_freeze.py depend on having network access now and to reflect that, I removed the @pytest.mark.network decorator from all the functions that used it.

Travis CI tests are passing. I hope that this can be reviewed and merged soon so that the tests are less fragile.

"""Test freezing a svn checkout"""

checkout_path = local_checkout(
'svn+http://svn.colorstudy.com/INITools/trunk',
tmpdir.join("cache"),
tmpdir.join("cache")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spurious "tidy up" change, presumably?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Fixed.

@pfmoore
Copy link
Member

pfmoore commented Mar 10, 2015

(Rats, got distracted by adding line comments and lost my larger comment-in-progress :-()

Wow, that's a big change! A lot of it looks like a more or less opaque change to tests/data/repos/hg/pip-test-package, but it'll take me some time to work out what's going on here.

Any chance you could summarise what the various bits of the PR are about? You've got 8 separate commits here. Maybe you could summarise what each one does? (Maybe it would have been easier to review if the PR was split into separate PRs for each commit). I'll try to get a chance to review properly, but it could be some time before I'm able to.

@msabramo
Copy link
Contributor Author

I could split it into separate PRs, if that makes it easier to review. Little atomic chunks should be easier to understand and review quickly I think.

@pfmoore
Copy link
Member

pfmoore commented Mar 11, 2015

Thanks, @msabramo - I'll go through the individual PRs.

@msabramo
Copy link
Contributor Author

This can be closed as it was replaced by multiple small PRs:

@msabramo msabramo closed this Mar 12, 2015
@msabramo msabramo deleted the faster_tests branch March 13, 2015 15:07
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants