-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
tests(smokehouse): gzip test to assert transfer and resource sizes #7286
Conversation
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.
nice this is great!!
}, | ||
{ | ||
url: 'http://localhost:10200/byte-efficiency/script.js?gzip=1', | ||
transferSize: 1136, |
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.
are these stable across platforms, like the native zlib mac/linux is the same byte-for-byte as js and transfer size is always the same and all that?
seems like we could loosen the assertion a bit
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.
Good question, no idea. For the purposes of the regression a ballpark is good enough (less than 1500 i guess).
Looks like travis / appveyor got the same thing I did.
This SO answer perhaps suggests that we can rely on zlib being the same? Interestingly there's a byte that represents the OS used, but that wouldn't change the length. You've got me curious now so I'm gonna dig in way deeper than necessary :P
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.
Any findings from the 🐰 🕳 ?
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.
Just that it may change when Node upgrades zlib, but they haven't update it in years. Seems fine to punt.
resourceSize: 52997, | ||
}, | ||
{ | ||
url: 'http://localhost:10200/byte-efficiency/script.js', |
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.
is this is just for exact comparison with the gzip?
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.
Just the ?gzip=1 one is important for the regression test. This is just for comparing. And maybe it'd catch some other future issue? I'm open to removing.
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.
LGTM we can always loosen if we later find a platform that is off by epsilon
}, | ||
{ | ||
url: 'http://localhost:10200/byte-efficiency/script.js?gzip=1', | ||
transferSize: 1136, |
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.
Any findings from the 🐰 🕳 ?
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.
lg aside from this naming nit
@@ -71,6 +72,7 @@ function requestHandler(request, response) { | |||
} | |||
|
|||
let delay = 0; | |||
let gzip = false; |
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.
useGzip
response.writeHead(statusCode, headers); | ||
|
||
// Delay the response | ||
if (delay > 0) { | ||
return setTimeout(finishResponse, delay, data); | ||
} | ||
|
||
finishResponse(data); | ||
finishResponse(data, gzip); |
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.
if passing it this way, would need to pass into the delay
path above as well (to getdelay
and gzip
to work together).
Could also doing the gzip encoding when doing the header? e.g.
if (gzip) {
headers['Content-Encoding'] = 'gzip';
data = zlib.gzipSync(data);
}
response.writeHead(statusCode, headers);
// ...
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.
Done
Assert that gzip savings are correctly being provided by the browser for LH to use.
Regression test for when a version of headless Chrome was giving weird
dataReceivedEvent
values in the face of gzipped resources (see this doc (private to Googlers) for more).Related: #7284