-
Notifications
You must be signed in to change notification settings - Fork 41
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
Refactor NDT server #110
Refactor NDT server #110
Conversation
Pull Request Test Coverage Report for Build 633
💛 - Coveralls |
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.
Reviewable status: 0 of 1 approvals obtained (waiting on @stephen-soltesz)
legacy/handler/tcphandler.go, line 37 at r2 (raw file):
// this code. In the future, if you are thinking of adding protocol sniffing to // your system, don't. func (rh *rawHandler) sniffThenHandle(conn net.Conn) {
FYI: Sorry to jump into a review, but I had hoped (and assumed) that we were going to move the support for the binary clients to a different port (or vice versa), instead of carrying this hack forward. Has that been abandoned? This makes me sad. 8-(
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.
Reviewable status: 0 of 1 approvals obtained (waiting on @stephen-soltesz)
legacy/handler/tcphandler.go, line 37 at r2 (raw file):
Previously, gfr10598 (Gregory Russell) wrote…
FYI: Sorry to jump into a review, but I had hoped (and assumed) that we were going to move the support for the binary clients to a different port (or vice versa), instead of carrying this hack forward. Has that been abandoned? This makes me sad. 8-(
They can't be moved. See the comment. What we can do (and this does do) is to have one port that only does ws, one that only does wss, and one that does raw ndt + protocol detection. Then, when the protocol detection is triggered, the connection is forwarded to the ws-only port. So the only jank is in the first few lines of sniffThenHandle
.
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.
Reviewable status: 0 of 1 approvals obtained (waiting on @stephen-soltesz)
legacy/handler/tcphandler.go, line 37 at r2 (raw file):
Previously, pboothe (Peter Boothe) wrote…
They can't be moved. See the comment. What we can do (and this does do) is to have one port that only does ws, one that only does wss, and one that does raw ndt + protocol detection. Then, when the protocol detection is triggered, the connection is forwarded to the ws-only port. So the only jank is in the first few lines of
sniffThenHandle
.
See the comment right at the beginning of the protocol-sniffing, I mean.
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.
Reviewed 1 of 10 files at r1, 7 of 13 files at r2.
Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @pboothe and @stephen-soltesz)
ndt-server_test.go, line 162 at r2 (raw file):
// Test legacy raw JSON clients // { // name: "Connect with web100clt (with JSON)",
What is the plan for this test?
ndt-server_test.go, line 258 at r2 (raw file):
wg := sync.WaitGroup{} // Run every test in parallel (the server must handle parallel tests just fine) for _, tc := range tests {
nit: maybe name the outer variable tt
or similar to avoid any confusion from the masked parameter tc
below?
legacy/README.md, line 12 at r2 (raw file):
functionality. If you are reading this and trying to decide how to implement a speed test, use ndt7 and not the legacy protocol. The legacy protocol is deprecated. It will be supported in perpetuity (or at least until usage drops
nit: I suggest saying only that it will be supported until usage drops to very low levels. And, "supported" does not distinguish between in code and in production. I would like to look forward to a day when we could put this behind a flag and leave it disabled in production.
legacy/c2s/c2s.go, line 53 at r2 (raw file):
return 0, err } byteCount, err := testConn.DrainUntil(endTime)
In the ndt.c server and in the previous ndt-server version there were two phases of 'drain' from the client. iirc, failing to deploy that fix was the cause of the "march-2016" loss of upload tests.
Why won't this sequence cause those clients to error again?
legacy/handler/tcphandler.go, line 146 at r2 (raw file):
// connection requests that look like HTTP to a different address (assumed to be // on the same host). func NewTCP(forwardingaddr string) RawHandler {
Tell me if I'm making too much of this.
I'm concerned about names. The RawHandler acts like a conditional proxy. My thinking is that "TCP" is too vague. "RawHandler" is a misnomer here, and 'fowardingAddr' is the reverse proxy target.
I'm not saying I advocate these specific examples; a first pass might look like: "NewRawMuxHandler", "RawMuxHandler" , "wsAddr".
Can these be improved on?
legacy/handler/tcphandler_test.go, line 14 at r2 (raw file):
) func Count200(w http.ResponseWriter, r *http.Request) {
This appears to be unused.
legacy/handler/tcphandler_test.go, line 26 at r2 (raw file):
success++ }) forwardSrv := &http.Server{
I found this naming confusing. I expected this server to be the one that was forwarding requests. Maybe 'target' or 'backend'?
legacy/handler/tcphandler_test.go, line 31 at r2 (raw file):
} rtx.Must(httpx.ListenAndServeAsync(forwardSrv), "Could not start server") _, err := http.Get("http://" + forwardSrv.Addr + "/test_url")
This is just a sanity check?
legacy/handler/tcphandler_test.go, line 43 at r2 (raw file):
rtx.Must(tcpH.ListenAndServe(ctx, ":0"), "Could not start tcp server") rh := tcpH.(*rawHandler)
I have mixed feelings about this.
legacy/s2c/s2c.go, line 80 at r2 (raw file):
// Send additional download results to the client. resultMsg := &Result{ // TODO: clean up this logic to use socket stats rather than application-level counters.
Did the original NDT report socket stats rather than application-level counters?
legacy/singleserving/server.go, line 43 at r2 (raw file):
func (s *wsServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { upgrader := websocket.Upgrader{
Can this use ws.Upgrader
?
legacy/singleserving/server.go, line 57 at r2 (raw file):
return } s.newConn = protocol.AdaptWsConn(wsc)
Please add a short note about what's happening with the ws hijacking followed by the server close. This looks funny if you don't know that WS takes over the connection.
legacy/singleserving/server.go, line 98 at r2 (raw file):
// StartWS starts a single-serving unencrypted websocket server. When this // method returns without error, it is safe for a client to connect to the // server, as the server socket will be in "listening" mode. Then returned
s/Then/The/
legacy/singleserving/server.go, line 126 at r2 (raw file):
// just a wsServer with a different ServeOnce method. type wssServer struct { ws *wsServer
Can we use "type embedding" here so that Port
and Close
are just inherited from wsServer?
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.
PTAL
Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @stephen-soltesz)
ndt-server_test.go, line 162 at r2 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
What is the plan for this test?
Added todo.
legacy/c2s/c2s.go, line 53 at r2 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
In the ndt.c server and in the previous ndt-server version there were two phases of 'drain' from the client. iirc, failing to deploy that fix was the cause of the "march-2016" loss of upload tests.
Why won't this sequence cause those clients to error again?
Good catch. Made it too simple.
legacy/handler/tcphandler.go, line 146 at r2 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
Tell me if I'm making too much of this.
I'm concerned about names. The RawHandler acts like a conditional proxy. My thinking is that "TCP" is too vague. "RawHandler" is a misnomer here, and 'fowardingAddr' is the reverse proxy target.
I'm not saying I advocate these specific examples; a first pass might look like: "NewRawMuxHandler", "RawMuxHandler" , "wsAddr".
Can these be improved on?
There is also a semantic gap. The thing returned by NewTCP
is a server unto itself. The thing returned by NewWS
and NewWSS
is an http.Handler
.
wsAddr
is a good name. How about RawServer
? or RawForwardingServer
?
I am changing it to RawForwardingServer
for now.
legacy/handler/tcphandler_test.go, line 14 at r2 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
This appears to be unused.
Yup. Deleted.
legacy/handler/tcphandler_test.go, line 26 at r2 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
I found this naming confusing. I expected this server to be the one that was forwarding requests. Maybe 'target' or 'backend'?
wsSrv
now
legacy/handler/tcphandler_test.go, line 31 at r2 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
This is just a sanity check?
Yup. Added comment.
legacy/s2c/s2c.go, line 80 at r2 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
Did the original NDT report socket stats rather than application-level counters?
Sometimes one, sometimes the other. It is vague because there was almost no difference between those two before I came along.
legacy/singleserving/server.go, line 43 at r2 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
Can this use
ws.Upgrader
?
Forgot to migrate this code after creating that method. Thanks!
legacy/singleserving/server.go, line 57 at r2 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
Please add a short note about what's happening with the ws hijacking followed by the server close. This looks funny if you don't know that WS takes over the connection.
Done.
legacy/singleserving/server.go, line 98 at r2 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
s/Then/The/
Done.
legacy/singleserving/server.go, line 126 at r2 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
Can we use "type embedding" here so that
Port
andClose
are just inherited from wsServer?
But I want wssServer
to have its own ServeOnce
and for it to use the ServeOnce
of the embedded type. I am sure that is possible, but I couldn't figure out a way to do it without making everything look real confusing.
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.
Reviewed 1 of 13 files at r2, 7 of 7 files at r3.
Reviewable status: complete! 1 of 1 approvals obtained (waiting on @pboothe)
legacy/c2s/c2s.go, line 53 at r2 (raw file):
Previously, pboothe (Peter Boothe) wrote…
Good catch. Made it too simple.
Just as an aside: do our tests include this client behavior? could they easily?
legacy/singleserving/server.go, line 126 at r2 (raw file):
Previously, pboothe (Peter Boothe) wrote…
But I want
wssServer
to have its ownServeOnce
and for it to use theServeOnce
of the embedded type. I am sure that is possible, but I couldn't figure out a way to do it without making everything look real confusing.
Discussed in person and resolved.
legacy/handler/tcphandler_test.go, line 31 at r2 (raw file):
Previously, pboothe (Peter Boothe) wrote…
Yup. Added comment.
Nit: please refer to the backend server (or fake ws server) consistently throughout comments and log/error messages. i.e. "backend" vs "forwarding".
This change is