Skip to content

Add TestApp::init() for tests that don't need HTTP recording #1519

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

Merged

Conversation

jtgeibel
Copy link
Member

@jtgeibel jtgeibel commented Oct 13, 2018

The unused Uploader::NoOp option is now Uploader::Panic which
panics on any usage. The panic message directs users to initialize the
app with TestApp::with_proxy().

While this adds more panics to the main lib, the application
configuration isn't dynamic and it should be obvious that
Uploader::Panic is not to be used to configure a production
application.

@jtgeibel
Copy link
Member Author

The test suite currently has 33 (of 166 total) tests that need a thread running an HTTP recording proxy. This PR avoids that overhead for 30 of the unnecessary cases. On my machine (with an average of 3 runs each), this reduces my user time from 26.60 to 26.11 seconds. An additional second or two can probably be saved once all test are converted.

@jtgeibel jtgeibel force-pushed the tests/simple-tests-avoid-http-thread branch from 2b3db7c to 6144edf Compare October 13, 2018 03:24
@carols10cents
Copy link
Member

Nice! I'm into it! The only slight reservation I have is about the names. I'm trying to think of this from the point of view of a new contributor writing some new tests. They have the empty/with_user/with_token axis to choose from, which is mostly pretty clear I think, and this adds the simple/full axis that I'm not sure is as clear.

The proxy change also affects tests that talk to github as well as those that talk to S3, right? The current doc comments on simple only talks about uploading; full talks about generic outgoing HTTP requests though, so that's good.

Some ideas for names, none of which I really like yet but maybe it'll help us get to something good:

  • proxy/no_proxy
  • record_http/no_record_http
  • makes_external_http_requests/no_external_http_requests

Or could we make simple be the default and only require calling a method when the test makes http requests? That would avoid the no_* names above....

@jtgeibel jtgeibel force-pushed the tests/simple-tests-avoid-http-thread branch from 6144edf to daba1e6 Compare October 25, 2018 01:03
The unused `Uploader::NoOp` option is now `Uploader::Panic` which
panics on any usage.  The panic message directs users to initialize the
app with `TestApp::with_proxy()`.

While this adds more panics to the main lib, the application
configuration isn't dynamic and it should be obvious that
`Uploader::Panic` is not to be used to configure a production
application.
@jtgeibel jtgeibel force-pushed the tests/simple-tests-avoid-http-thread branch from daba1e6 to 15a4109 Compare October 25, 2018 01:10
@jtgeibel
Copy link
Member Author

I renamed simple to init and full to with_proxy. I rebased to fix merge conflicts and updated the tests converted in the other PR. There are now 50 tests using init and 3 using with_proxy.

bors: r+

bors-voyager bot added a commit that referenced this pull request Oct 25, 2018
1519: Add `TestApp::simple()` for tests that don't need HTTP recording r=jtgeibel a=jtgeibel

The unused `Uploader::NoOp` option is now `Uploader::Panic` which
panics on any usage.  The panic message directs users to initialize the
app with `TestApp::with_proxy()`.

While this adds more panics to the main lib, the application
configuration isn't dynamic and it should be obvious that
`Uploader::Panic` is not to be used to configure a production
application.

Co-authored-by: Justin Geibel <[email protected]>
@jtgeibel jtgeibel changed the title Add TestApp::simple() for tests that don't need HTTP recording Add TestApp::init() for tests that don't need HTTP recording Oct 25, 2018
@bors-voyager
Copy link
Contributor

bors-voyager bot commented Oct 25, 2018

Build succeeded

@bors-voyager bors-voyager bot merged commit 15a4109 into rust-lang:master Oct 25, 2018
@jtgeibel jtgeibel deleted the tests/simple-tests-avoid-http-thread branch February 7, 2019 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants