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): refactor to enable Smokerider #7284

Merged
merged 10 commits into from Mar 6, 2019
Merged

Conversation

connorjclark
Copy link
Collaborator

A few refactors to enable running smoke tests against Lightrider. Namely:

  1. Move all test definitions to their own module, with a way to uncompact the references to other modules (the expectations / config).
  2. Move all the LHR comparison / reporting code to a module.
  3. LR entry option keepRawValues, since many smoke tests assert on that.

See internal bug b/124882661.

@brendankenny
Copy link
Member

is it possible to make the brainstorming doc public? It would be nice to see the motivations/constraints before settling on a new design

@@ -0,0 +1,224 @@
/* eslint-disable no-console */
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Only changes here are 1) module exports at the bottom and 2) using Smokehouse. type definitions.

@connorjclark
Copy link
Collaborator Author

It's easier to share it individually. I sent @patrickhulce a link. I can do the same for anyone else who requests it.

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.

I'm probably missing the bigger picture here how this helps. Doc you shared helped a lot :)

@@ -106,7 +35,7 @@ function displaySmokehouseOutput(result) {
/**
* Run smokehouse in child processes for selected smoketests
* Display output from each as soon as they finish, but resolve function when ALL are complete
* @param {Array<SmoketestDfn>} smokes
* @param {Array<typeof SMOKETESTS[0]>} smokes
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we not use SmoketestDfn directly somehow?

import('./smoke-test-dfn').SmoketestDefn or better yet a new Smokehouse namespace?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved to the new .d.ts.

const path = require('path');

/**
* @typedef {object} SmoketestDfn
Copy link
Collaborator

Choose a reason for hiding this comment

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

☠️ 1️⃣ ✉️ 🕐

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

xD

return require(expectationsPath);
}

module.exports.getCompactSmokeTests = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

we don't typically do piecemeal exports as we go, and I must admit the explicit collection of what's exported at the bottom has somewhat grown on me.

anything in particular that prompted this style or just more used to it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

also this function feels a little more like getUncompactedSmokeTests, no?

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 point, changed to module.exports = {...}.

Doh, that is a better name. Although I do not like the word 'compact' for this. Got any better ideas?

Copy link
Collaborator

Choose a reason for hiding this comment

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

resolved, expanded, loaded... like any of those? I think that's all I got :)

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 % last typedef

@@ -53,8 +56,8 @@ function processForProto(result) {
audit.scoreDisplayMode = 'notApplicable';
}
}
// Drop raw values. #6199
if ('rawValue' in audit) {
// Drop raw values. https://github.com/GoogleChrome/lighthouse/issues/6199
Copy link
Collaborator

Choose a reason for hiding this comment

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

🎉

@@ -139,7 +68,7 @@ async function runSmokehouse(smokes) {
/**
* Determine batches of smoketests to run, based on argv
* @param {string[]} argv
* @return {Map<string|undefined, Array<SmoketestDfn>>}
* @return {Map<string|undefined, Array<typeof SMOKETESTS[0]>>}
Copy link
Collaborator

Choose a reason for hiding this comment

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

upate this one?

@connorjclark
Copy link
Collaborator Author

@brendankenny any questions or concerns about these changes after reviewing how it's utilized in cl/234828413?

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.

works for me. only small nits

const smokehouseDir = 'lighthouse-cli/test/smokehouse/';

/** @type {Array<Smokehouse.TestDfn>} */
const SMOKE_TESTS = [{
Copy link
Member

Choose a reason for hiding this comment

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

rename to SMOME_TEST_DFNS ?

return require(expectationsPath);
}

function getUncompactedSmokeTests() {
Copy link
Member

Choose a reason for hiding this comment

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

This name is funny to me. It means the config/expectations are not filenames but the files are read as modules?

if we rename the above to DFNS, then this module can be getSmokeTests()

Copy link
Member

@exterkamp exterkamp left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -0,0 +1,128 @@
'use strict';
Copy link
Member

Choose a reason for hiding this comment

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

/**
 * @license Copyright 2019 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 */

@@ -0,0 +1,229 @@
/* eslint-disable no-console */
Copy link
Member

Choose a reason for hiding this comment

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

/**
 * @license Copyright 2019 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 */

@@ -0,0 +1,30 @@
declare module Smokehouse {
Copy link
Member

Choose a reason for hiding this comment

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

/**
 * @license Copyright 2019 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 */

@paulirish paulirish changed the title tests(smokehouse): Refactor so that Smokerider can run smoke tests. tests(smokehouse): refactor to enable Smokerider Mar 6, 2019
@paulirish paulirish merged commit fd86d94 into master Mar 6, 2019
@paulirish paulirish deleted the lr-smokerider branch March 6, 2019 18:29
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.

None yet

5 participants