Skip to content
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

Merged
merged 4 commits into from
Feb 26, 2019

Conversation

connorjclark
Copy link
Collaborator

@connorjclark connorjclark commented Feb 21, 2019

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

Copy link
Collaborator

@patrickhulce patrickhulce left a 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,
Copy link
Collaborator

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

Copy link
Collaborator Author

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any findings from the 🐰 🕳 ?

Copy link
Collaborator Author

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',
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

@patrickhulce patrickhulce left a 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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any findings from the 🐰 🕳 ?

Copy link
Member

@paulirish paulirish left a 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;
Copy link
Member

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);
Copy link
Member

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);

// ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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.

4 participants