Skip to content

Testable net load... - #7139

Merged
bors-servo merged 43 commits into
servo:masterfrom
samfoo:testable-net-load
Aug 31, 2015
Merged

bors-servo merged 43 commits into
servo:masterfrom
samfoo:testable-net-load

Conversation

@samfoo

@samfoo samfoo commented Aug 10, 2015

Copy link
Copy Markdown
Contributor

The goal of this PR is to get early feedback on this before I go too far down the rabbit hole. This new code path is working, and there's several tests I've written as a proof of concept. There are still some regressions that I'll be fixing in the coming days.

I've abstracted out the request/response cycle so that it's no longer dependent on the Hyper request/response structs. Since request/response @ hyper are structs, not traits, it made mocking them for tests impossible.

Current issues/concerns:

  • This relies on boxing the HttpResponse that gets returned from the HttpRequester because HttpResponse is unsized. I don't know if there's a more idiomatic rust-y way of doing this?
  • This relies on boxing the Read that is now returned from load for the same reason.
  • The devtools and resource manager channels are still passed into load. It might be easier to inject these as trait dependencies instead of chans as well?
  • Needs more tests.

🎩
#6727

Review on Reviewable

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Aug 10, 2015
@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@jdm

jdm commented Aug 10, 2015

Copy link
Copy Markdown
Member

Woohoo!

@jdm jdm self-assigned this Aug 10, 2015
@jdm

jdm commented Aug 11, 2015

Copy link
Copy Markdown
Member

Ok, I've read through all of these changes. First off, the load_consumer/load split is great, and I really like the enum for all of the possible errors now. Great work there! Also, If the nossl stuff is causing you pain, go ahead and get rid of it. I don't believe anybody is using it.

With regards to the question about boxing, what about something like this:

trait HttpRequestor {
    type Response: HttpResponse;
    fn send(...) -> Result<Self::Response, LoadError>;
}

I'm not super keen on the implementation of NetworkHttpRequester::Send. It feels to me like we could get away with a series of traits with associated types that return Result<Self::Output, LoadError>, and in the unit test case those could all be the self value (if send took self by value, that is). That would allow us to move that code back where it came from and avoid the problems like the TODO it currently contains. We could then write a common implementation for all unit tests that stuffs the relevant request data in fields in a MockRequest<R: MockResponse> struct, and the implementation of send could do something like:

fn send(&self) -> Result<R, LoadError> {
    R::create(&self.headers, &self.body, &self.method)
}

where MockResponse is defined like:

trait MockResponse {
    fn create(&Headers, &Option<Vec<u8>>, &Method) -> Result<Self, LoadError>;
}

I think that would allow the unit tests to stay slim like they currently are. Does that make sense?

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Aug 11, 2015
@samfoo

samfoo commented Aug 11, 2015

Copy link
Copy Markdown
Contributor Author

I agree that the HttpRequester pattern is a bit awkward. I thought it didn't make as much sense to wrap the hyper Request object at first, but you're right that doing that pushes the request building logic (which is what we care about in this method anyway) back to the method. The main thing I was trying to abstract was all of the Request<Fresh> vs. Request<Streaming> in hyper, since ultimately servo is less concerned about that and just wants to make a request more or less atomically after it's built.

I'll have a go at rejiggering it a bit.

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Aug 15, 2015
@bors-servo

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #7225) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added S-needs-rebase There are merge conflict errors. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Aug 15, 2015
@samfoo
samfoo force-pushed the testable-net-load branch from f463071 to d79b453 Compare August 15, 2015 12:00
@jdm jdm removed the S-needs-rebase There are merge conflict errors. label Aug 15, 2015
@jdm

jdm commented Aug 15, 2015

Copy link
Copy Markdown
Member

@samfoo Looking really good! Is this ready for review at this point, or are you intending to make more changes?

@samfoo

samfoo commented Aug 15, 2015

Copy link
Copy Markdown
Contributor Author

Not quite ready yet, @jdm. Going to spend some time today finishing off adding the tests I want and any additional refactorings.

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Aug 16, 2015
@samfoo
samfoo force-pushed the testable-net-load branch from 98e07ca to f7a55ac Compare August 16, 2015 09:32
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Aug 16, 2015
@samfoo

samfoo commented Aug 16, 2015

Copy link
Copy Markdown
Contributor Author

@jdm, this should be ready to review now.

@jdm

jdm commented Aug 16, 2015

Copy link
Copy Markdown
Member

Great! Unfortunately I'll be on vacation this week, and I can't promise that anybody else will be able to look at the changes before I get back. Apologies for the delay!

@samfoo
samfoo force-pushed the testable-net-load branch from f7a55ac to 87e5ef1 Compare August 17, 2015 22:52
@bors-servo

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #7265) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added S-needs-rebase There are merge conflict errors. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Aug 20, 2015
@samfoo
samfoo force-pushed the testable-net-load branch from 87e5ef1 to 545683d Compare August 22, 2015 22:57
@jdm jdm removed the S-needs-rebase There are merge conflict errors. label Aug 23, 2015
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 9d0f418 with merge 3619171...

@highfive highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Aug 30, 2015
bors-servo pushed a commit that referenced this pull request Aug 30, 2015
Testable net load...

*The goal of this PR is to get early feedback on this before I go too far down the rabbit hole. This new code path is working, and there's several tests I've written as a proof of concept. There are still some regressions that I'll be fixing in the coming days.*

I've abstracted out the request/response cycle so that it's no longer dependent on the Hyper request/response structs. Since request/response @ hyper are structs, not traits, it made mocking them for tests impossible.

Current issues/concerns:

* This relies on boxing the `HttpResponse` that gets returned from the `HttpRequester` because `HttpResponse` is unsized. I don't know if there's a more idiomatic rust-y way of doing this?
* This relies on boxing the `Read` that is now returned from `load` for the same reason.
* The devtools and resource manager channels are still passed into `load`. It might be easier to inject these as trait dependencies instead of chans as well?
* Needs more tests.

:tophat: 

#6727

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7139)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - mac-rel-wpt

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Aug 30, 2015
@jdm

jdm commented Aug 30, 2015

Copy link
Copy Markdown
Member


/XMLHttpRequest/send-redirect-bogus-sync.htm
--------------------------------------------
TIMEOUT [Parent]
/XMLHttpRequest/send-redirect-bogus.htm
---------------------------------------
TIMEOUT XMLHttpRequest: send() - Redirects (bogus Location header) (302: mailto:[email protected])
TIMEOUT XMLHttpRequest: send() - Redirects (bogus Location header) (303: foobar:[email protected])

@jdm

jdm commented Aug 30, 2015

Copy link
Copy Markdown
Member

Specifically:

(pid:56002) "thread 'http_loader for http://localhost:8000/XMLHttpRequest/resources/redirect.py?location=foobar://abcd&code=301' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:363"
 1:36.08 PROCESS_OUTPUT: Thread-TestrunnerManager-3 (pid:56002) "stack backtrace:"
 1:36.08 PROCESS_OUTPUT: Thread-TestrunnerManager-3 (pid:56002) "   1:        0x105ae3ab0 - sys::backtrace::write::h095d0f07f92e7e3eYts"
 1:36.08 PROCESS_OUTPUT: Thread-TestrunnerManager-3 (pid:56002) "   2:        0x105ae6e83 - panicking::on_panic::h5f4115f30a6b4860Z7w"
 1:36.08 PROCESS_OUTPUT: Thread-TestrunnerManager-3 (pid:56002) "   3:        0x105ad5e12 - rt::unwind::begin_unwind_inner::h7c54671eea5e313e0Cw"
 1:36.08 PROCESS_OUTPUT: Thread-TestrunnerManager-3 (pid:56002) "   4:        0x105ad6327 - rt::unwind::begin_unwind_fmt::h1bf10e625ad90c4f6Bw"
 1:36.08 PROCESS_OUTPUT: Thread-TestrunnerManager-3 (pid:56002) "   5:        0x105ae68a7 - rust_begin_unwind"
 1:36.08 PROCESS_OUTPUT: Thread-TestrunnerManager-3 (pid:56002) "   6:        0x105b0b7c0 - panicking::panic_fmt::ha8483564b9ba8c9c47D"
 1:36.08 PROCESS_OUTPUT: Thread-TestrunnerManager-3 (pid:56002) "   7:        0x105b07d5c - panicking::panic::h0037039f4901293aB6D"
 1:36.08 PROCESS_OUTPUT: Thread-TestrunnerManager-3 (pid:56002) "   8:        0x104fe3851 - http_loader::request_must_be_secured::h1f74dcdf13d2cd60vGa"
 1:36.08 PROCESS_OUTPUT: Thread-TestrunnerManager-3 (pid:56002) "   9:        0x104fda3c4 - http_loader::load::h4784776128278545592"
 1:36.08 PROCESS_OUTPUT: Thread-TestrunnerManager-3 (pid:56002) "  10:        0x104fd41f1 - boxed::F.FnBox<A>::call_box::h15827463960754583520"
 1:36.08 PROCESS_OUTPUT: Thread-TestrunnerManager-3 (pid:56002) "  11:        0x104fcf222 - rt::unwind::try::try_fn::h17794595131187671366"
 1:36.08 PROCESS_OUTPUT: Thread-TestrunnerManager-3 (pid:56002) "  12:        0x105ae6858 - __rust_try"
 1:36.08 PROCESS_OUTPUT: Thread-TestrunnerManager-3 (pid:56002) "  13:        0x105ae24b0 - rt::unwind::try::inner_try::h39d984f71e9cc780Tyw"
 1:36.08 PROCESS_OUTPUT: Thread-TestrunnerManager-3 (pid:56002) "  14:        0x104fcf3d7 - boxed::F.FnBox<A>::call_box::h22052022223099250"
 1:36.08 PROCESS_OUTPUT: Thread-TestrunnerManager-3 (pid:56002) "  15:        0x105ae5b4d - sys::thread::Thread::new::thread_start::h999b3790b6d4b23deXv"
 1:36.08 PROCESS_OUTPUT: Thread-TestrunnerManager-3 (pid:56002) "  16:     0x7fff8d3b9267 - _pthread_body"
 1:36.08 PROCESS_OUTPUT: Thread-TestrunnerManager-3 (pid:56002) "  17:     0x7fff8d3b91e4 - _pthread_start"

@jdm

jdm commented Aug 30, 2015

Copy link
Copy Markdown
Member

We should specifically check for the "http" scheme at https://github.com/servo/servo/pull/7139/files#diff-aa469beb5619907dbccd88364264b9b8R463, not anything that isn't "https".

@samfoo

samfoo commented Aug 30, 2015

Copy link
Copy Markdown
Contributor Author

Urg. Yep. I saw that outcome when I ran locally and didn't realise it was a failure 😧 Will have to fix later today when I have time.

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Aug 31, 2015
@samfoo

samfoo commented Aug 31, 2015

Copy link
Copy Markdown
Contributor Author

Fingers cross the build is going now. I think I better understand the test-wpt output now. I'll make sure the ping pong nonsense doesn't happen next time 😄

Build Success

@jdm

jdm commented Aug 31, 2015

Copy link
Copy Markdown
Member

@bors-servo: r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 43e0c4a has been approved by jdm

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 43e0c4a with merge 7dda183...

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Aug 31, 2015
bors-servo pushed a commit that referenced this pull request Aug 31, 2015
Testable net load...

*The goal of this PR is to get early feedback on this before I go too far down the rabbit hole. This new code path is working, and there's several tests I've written as a proof of concept. There are still some regressions that I'll be fixing in the coming days.*

I've abstracted out the request/response cycle so that it's no longer dependent on the Hyper request/response structs. Since request/response @ hyper are structs, not traits, it made mocking them for tests impossible.

Current issues/concerns:

* This relies on boxing the `HttpResponse` that gets returned from the `HttpRequester` because `HttpResponse` is unsized. I don't know if there's a more idiomatic rust-y way of doing this?
* This relies on boxing the `Read` that is now returned from `load` for the same reason.
* The devtools and resource manager channels are still passed into `load`. It might be easier to inject these as trait dependencies instead of chans as well?
* Needs more tests.

:tophat: 

#6727

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7139)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - mac-rel-css

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Aug 31, 2015
@jdm

jdm commented Aug 31, 2015

Copy link
Copy Markdown
Member

@bors-servo

Copy link
Copy Markdown
Contributor

⚡ Previous build results for android, gonk, linux-dev, linux-rel, mac-dev-ref-unit, mac-rel-wpt are reusable. Rebuilding only mac-rel-css...

@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, gonk, linux-dev, linux-rel, mac-dev-ref-unit, mac-rel-css, mac-rel-wpt

@bors-servo
bors-servo merged commit 43e0c4a into servo:master Aug 31, 2015
@SimonSapin SimonSapin removed the S-tests-failed The changes caused existing tests to fail. label Jan 27, 2016
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.

5 participants