Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upThe networking code is hard to test #6727
Closed
Labels
Comments
|
Yep, it's a great start. |
|
Hey guys, I'll pick this up over the weekend. |
|
Fantastic! |
samfoo
added a commit
to samfoo/servo
that referenced
this issue
Aug 2, 2015
This simplifies the arguments that are passed in and should make testing errors/responses easier once they're mocked servo#6727
samfoo
added a commit
to samfoo/servo
that referenced
this issue
Aug 2, 2015
… think are working?) servo#6727
|
I've done some proof-of-concept work on this over the past couple of days. I'm still debating whether the approach makes sense. The current approach:
I've also made some simplifying assumptions for the moment, that may need to change before finishing (e.g. is |
|
Exciting! I am having trouble imagining how the split into two functions was managed, but perhaps I'm over-complicating matters in my head. |
samfoo
added a commit
to samfoo/servo
that referenced
this issue
Aug 9, 2015
Because we're using unsized types not for requesting, there's not a satisfactory way of doing this without boxing the request... Once unsized stuff lands in rust 1.2/1.3(???) then this should be implemented with Rc's instead of Box's. For the time being I'm not sure what else to do. servo#6727
samfoo
added a commit
to samfoo/servo
that referenced
this issue
Aug 9, 2015
This simplifies the arguments that are passed in and should make testing errors/responses easier once they're mocked servo#6727
samfoo
added a commit
to samfoo/servo
that referenced
this issue
Aug 9, 2015
… think are working?) servo#6727
samfoo
added a commit
to samfoo/servo
that referenced
this issue
Aug 9, 2015
Because we're using unsized types not for requesting, there's not a satisfactory way of doing this without boxing the request... Once unsized stuff lands in rust 1.2/1.3(???) then this should be implemented with Rc's instead of Box's. For the time being I'm not sure what else to do. servo#6727
samfoo
added a commit
to samfoo/servo
that referenced
this issue
Aug 9, 2015
The HttpRequest trait doesn't make sense, on further reflection. Rather, just modify the method signature on the requester. The hyper request was only being used to mutate it's headers anyway. servo#6727
Merged
samfoo
added a commit
to samfoo/servo
that referenced
this issue
Aug 15, 2015
This simplifies the arguments that are passed in and should make testing errors/responses easier once they're mocked servo#6727
samfoo
added a commit
to samfoo/servo
that referenced
this issue
Aug 15, 2015
… think are working?) servo#6727
samfoo
added a commit
to samfoo/servo
that referenced
this issue
Aug 15, 2015
Because we're using unsized types not for requesting, there's not a satisfactory way of doing this without boxing the request... Once unsized stuff lands in rust 1.2/1.3(???) then this should be implemented with Rc's instead of Box's. For the time being I'm not sure what else to do. servo#6727
samfoo
added a commit
to samfoo/servo
that referenced
this issue
Aug 27, 2015
This simplifies the arguments that are passed in and should make testing errors/responses easier once they're mocked servo#6727
samfoo
added a commit
to samfoo/servo
that referenced
this issue
Aug 27, 2015
… think are working?) servo#6727
samfoo
added a commit
to samfoo/servo
that referenced
this issue
Aug 27, 2015
Because we're using unsized types not for requesting, there's not a satisfactory way of doing this without boxing the request... Once unsized stuff lands in rust 1.2/1.3(???) then this should be implemented with Rc's instead of Box's. For the time being I'm not sure what else to do. servo#6727
samfoo
added a commit
to samfoo/servo
that referenced
this issue
Aug 27, 2015
The HttpRequest trait doesn't make sense, on further reflection. Rather, just modify the method signature on the requester. The hyper request was only being used to mutate it's headers anyway. servo#6727
bors-servo
pushed a commit
that referenced
this issue
Aug 28, 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.🎩 #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 -->
samfoo
added a commit
to samfoo/servo
that referenced
this issue
Aug 30, 2015
This simplifies the arguments that are passed in and should make testing errors/responses easier once they're mocked servo#6727
samfoo
added a commit
to samfoo/servo
that referenced
this issue
Aug 30, 2015
… think are working?) servo#6727
samfoo
added a commit
to samfoo/servo
that referenced
this issue
Aug 30, 2015
Because we're using unsized types not for requesting, there's not a satisfactory way of doing this without boxing the request... Once unsized stuff lands in rust 1.2/1.3(???) then this should be implemented with Rc's instead of Box's. For the time being I'm not sure what else to do. servo#6727
samfoo
added a commit
to samfoo/servo
that referenced
this issue
Aug 30, 2015
The HttpRequest trait doesn't make sense, on further reflection. Rather, just modify the method signature on the requester. The hyper request was only being used to mutate it's headers anyway. servo#6727
bors-servo
pushed a commit
that referenced
this issue
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.🎩 #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
pushed a commit
that referenced
this issue
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.🎩 #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 -->
josiahdaniels
added a commit
to josiahdaniels/servo
that referenced
this issue
Sep 28, 2015
This simplifies the arguments that are passed in and should make testing errors/responses easier once they're mocked servo#6727
josiahdaniels
added a commit
to josiahdaniels/servo
that referenced
this issue
Sep 28, 2015
josiahdaniels
added a commit
to josiahdaniels/servo
that referenced
this issue
Sep 28, 2015
… think are working?) servo#6727
josiahdaniels
added a commit
to josiahdaniels/servo
that referenced
this issue
Sep 28, 2015
josiahdaniels
added a commit
to josiahdaniels/servo
that referenced
this issue
Sep 28, 2015
josiahdaniels
added a commit
to josiahdaniels/servo
that referenced
this issue
Sep 28, 2015
Because we're using unsized types not for requesting, there's not a satisfactory way of doing this without boxing the request... Once unsized stuff lands in rust 1.2/1.3(???) then this should be implemented with Rc's instead of Box's. For the time being I'm not sure what else to do. servo#6727
josiahdaniels
added a commit
to josiahdaniels/servo
that referenced
this issue
Sep 28, 2015
The HttpRequest trait doesn't make sense, on further reflection. Rather, just modify the method signature on the requester. The hyper request was only being used to mutate it's headers anyway. servo#6727
josiahdaniels
added a commit
to josiahdaniels/servo
that referenced
this issue
Sep 28, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We can write full integration tests in the form of pages that run in the WPT harness and Python scripts that control the server responses, but it's not particularly efficient. At some point we're going to implement an HTTP cache, and being able to test precisely how the networking stack treats a series of HTTP requests/responses will be important. Furthermore, the improvements for testing can lay the groundwork for an implementation of request interception for a future ServiceWorker implementation!
I propose the following:
Responsestruct that contains all of the data used by Servo's networking stack from hyper's ResponseHTTPResponseProviderwith a method that takes in all the data associated with an HTTP request and returns the new Response typeRemoteHTTPResponsethat extracts all of the code fromhttp_loader::loadthat initiates a network connection and waits for a responsehttp_loader::loaddifficult to test