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

Smoke test that runs in travis #747

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

KenCoder
Copy link
Contributor

Don't merge yet - I intentionally put a console.error statement to see if this fails travis on the PR build.

package.json Outdated
@@ -21,7 +21,7 @@
"build-compare": "webpack --config ./compare/webpack.config.js",
"dev-compare": "webpack-dev-server --content-base ./compare/output --config ./compare/webpack.config.js",
"integration-test": "rm -rf newdir && mkdir newdir && cd newdir && node ../cli/index.js genConfig && node ../cli/index.js reference && node ../cli/index.js test && node -e \"require('../')('test')\"",
"smoke-test": "cd test/configs/; node ../../cli/index.js test --config=backstop_features",
"smoke-test": "node test/smoke/smoke_test.js",
Copy link
Owner

Choose a reason for hiding this comment

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

Very nice harness you built there!

A suggestion: would you consider leaving the smoke-test command the same (so it executes the backstop_features test like before) -- and add a new command for your new harness. Maybe call it like, travis-test or git-commit-test or deploy-test?

I am totally open to suggestions -- my instinct is to keep it convenient for devs to still be able to run the raw smoke-test and see results (passing or non-passing).

Does this make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the harness works well for devs too because it tells them if it succeeds at the end. Right now it's hard to notice if something breaks (e.g., incorrect # of comparison failures or that a timeout). There are some scary looking messages in the output that I don't know if they mean somethings wrong or not (selector not found, etc).

The only difference is that the CI test doesn't pop up the browser report at the end.

But I will add an argument so if you do
npm run smoke-test

It will behave just like today with additional niceness and popup the browser, and

npm run smoke-test -- ci

Will do it without the browser report.

Question for you: Will this have to run in Docker? It seems like launching in travis doesn't really work. If so I can't currently see the docker cloud config - maybe you can share it with me?

Copy link
Owner

@garris garris Apr 19, 2018

Choose a reason for hiding this comment

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

Sounds good!

I honestly am not an expert in docker -- I just know enough to get me into trouble. I am happy to share the configs with you -- they should all be in the /docker directory.

Also -- just so I am understanding correctly -- when you say...

It seems like launching in travis doesn't really work

...are you saying you cant run backstop tests in travis?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems like launching in travis doesn't really work

Well that's the way it is now - you can click below and see the error. I wasn't sure if you already knew this. If not - no worries I think I can fix this problem. So expect an updated PR shortly.

Copy link
Owner

@garris garris left a comment

Choose a reason for hiding this comment

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

Thank you for working on all of this! I am really really under the gun at work — it could take a little bit for me to test/merge this. It will happen ASAP! Thanks for your patience. Cheers.

@KenCoder
Copy link
Contributor Author

Don't merge yet! I'm still working on it - unfortunately chrome in Linux produces image mismatch with chrome on the mac, so likely the mac version will have to use a docker container to generate the reference bitmaps. I will let you know when it's ready, and no worries about work - I know how it is.

@garris
Copy link
Owner

garris commented Apr 24, 2018

😄 ok thank you.

BTW: if you are running into rendering differences you could try adding this to the settings...

    "args": [
      "--no-sandbox",
      "--disable-setuid-sandbox",
      "--disable-gpu", 
      "--force-device-scale-factor=1", 
      "--disable-infobars=true"
    ]

In particular, —disable-gpu when used on Mac and Linux may fix the font rendering issues. It does seem to work across macOS boxes and may work across Linux and Mac.

It would be good to know if this in fact can solve the issue. I am happy to rerender the images using that setting if you don’t have a Mac handy.

And again, thanks so much for your effort 😊.

@@ -43,7 +43,6 @@ a:hover {
transform: translateZ(200px);
}
.lemurInYourFace {
transition: transform 750ms ease, opacity 750ms ease, visibility 800ms ease;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line was cuasing intermittent failures in the backstop tests. Since the lemurInYourFace is part of the initial styling with the index.html, the fade-in would happen on page load and therefore you'd occasionally get lemurs partially loaded especially in the noDelay scenario

Copy link
Owner

Choose a reason for hiding this comment

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

Of course in real life -- our designer would not let us remove a style because it was inconvenient to test 😄. Can we modify the test if this is causing a failure?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The way to do this is with the transitionend event. This could be a new backstop feature, or one can write custom Javascript to detect the transition and use the readyEvent feature of Backstop. There is already a test of readyEvent - this 'lemurInYourFace' is supposed to be the 'Simple' test case. Demonstrating CSS transition in the "Simple" case seems wrong.

How about we add another issue "demo CSS transition handling" that can be done in a separate PR? I didn't introduce this problem - I'm just cleaning up something that was already flaky.

Copy link
Owner

Choose a reason for hiding this comment

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

yes that works. We can just comment the flaky test now and create an issue.

There is actually an article on dwb which discusses exactly your idea — using the transition event. The onReady test script can attach a listener and just emit a console log which triggers the shot.

@KenCoder
Copy link
Contributor Author

KenCoder commented Apr 27, 2018

Ok I'm ready! Here's what I did:

  • I created two folders: linux and osx, each with a backstop_data folder under it
  • I moved the current backstop_data/bitmaps_reference to osx/backstop_data
  • When you run a regular smoke test, it figures out which machine type you are on and uses that folder. For most people, doing this locally means running on a mac
  • If you run "npm smoke-test -- ci" on the mac, after it runs the mac smoke tests, it will build and run a docker image to check / update the smoke tests that will run in travis. This is how I populated linux/backstop_data/bitmaps_reference
  • In travis, it uses the linux backstop data images
  • The container mounts the current folder to /host-backstop inside docker. There is some magic to isolate the node_modules container inside the container from the one on the mac, since they load different stuff (e.g., the binary version of chrome)
  • the first time you use the container on the mac, it takes a while to build the container. After that it mostly reuses stuff.

@KenCoder
Copy link
Contributor Author

KenCoder commented May 7, 2018

Hey - any luck reviewing this? Any concerns?

@garris
Copy link
Owner

garris commented May 8, 2018

Oh crap — sorry man. So busy... 😿

I have a day to work on the library on 5/18 — but hopefully I can this before that.

Thanks for your patience!

@KenCoder
Copy link
Contributor Author

KenCoder commented May 8, 2018

No worries, not in any big hurry, I just wanted to make sure it was in the queue.

@@ -43,7 +43,6 @@ a:hover {
transform: translateZ(200px);
}
.lemurInYourFace {
transition: transform 750ms ease, opacity 750ms ease, visibility 800ms ease;
Copy link
Owner

Choose a reason for hiding this comment

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

Of course in real life -- our designer would not let us remove a style because it was inconvenient to test 😄. Can we modify the test if this is causing a failure?

const ENGINE = 'puppet';
const SCRIPT_PATH = 'puppet';
const PLATFORM = process.env.BACKSTOP_SMOKE_PLATFORM || (process.platform === 'darwin' ? 'osx' : 'linux');

module.exports = {
id: `${ENGINE}_backstop_features`,
Copy link
Owner

Choose a reason for hiding this comment

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

The ID property is appended to all test images -- so adding your platform parameter there enables backstop to track these resources at file level.

Line 8 can be

id: `${PLATFORM}_${ENGINE}_backstop_features`,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this is much nicer - I changed it to this.

@@ -83,7 +86,7 @@ module.exports = {
},
{
label: 'cookies',
cookiePath: 'backstop_data/cookies.json',
cookiePath: `${PLATFORM}/backstop_data/cookies.json`,
Copy link
Owner

Choose a reason for hiding this comment

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

I noticed that you are not using cookies -- so in this case it seems unnecessary to customize the cookie path. And even if we did have cookies -- it's likely these would share the same file so the original (default) value does not need to be changed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

engine_scripts: 'backstop_data/engine_scripts',
html_report: 'backstop_data/html_report',
ci_report: 'backstop_data/ci_report'
bitmaps_reference: `${PLATFORM}/backstop_data/bitmaps_reference`,
Copy link
Owner

Choose a reason for hiding this comment

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

Reference and test scripts can all remain using their default values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

ci_report: 'backstop_data/ci_report'
bitmaps_reference: `${PLATFORM}/backstop_data/bitmaps_reference`,
bitmaps_test: `${PLATFORM}/backstop_data/bitmaps_test`,
engine_scripts: `engine_scripts`,
Copy link
Owner

Choose a reason for hiding this comment

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

Engine scripts should stay in the backstop_data directory. (keep default value)

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
Copy link
Owner

Choose a reason for hiding this comment

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

I would love to know what each of these lines did. I find it hard to parse docker configs. Particularly lines 5 & 6. I guess I expect we would cd to a workspace, install backstop locally to that space and use the feature tests runner. I don't understand why /test/configs/linux/node_modules is called out in there.

{ cwd: configsDir, env: processEnv }
);

const requiredStdout = [
Copy link
Owner

Choose a reason for hiding this comment

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

This sort of thing should be placed at the top of this script with explicit comments around how to use this array to handle different test scenarios.

In this case we should name it something very clear.

'report | 0 Failed'
];

const allowedStdErr = [
Copy link
Owner

Choose a reason for hiding this comment

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

same comment as above for this array.


let missingStdOut = [...requiredStdout];

child.stdout.on('data', function (buf) {
Copy link
Owner

Choose a reason for hiding this comment

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

Please use named functions for clarity.


const code = await new Promise(resolve => child.on('close', resolve));

const problems = [];
Copy link
Owner

Choose a reason for hiding this comment

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

would prefer if these were encapsulated a bit by functions so that the overall flow of this script can be easily grasped in a few lines.

Copy link
Owner

@garris garris left a comment

Choose a reason for hiding this comment

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

Hi Ken -- thank you very much for all your effort here! This is great work. I do have some comments though. I think this implementation can be significantly tightened up such that it would serve a nice reference implementation for other developers.

I'd like to take a more backstop-centric approach to the layout -- this would improve developer ergonomics and make the system easier to reason about. I called out suggestions which would enable you to allow backstop to manage all resources in it's own scaffolding (as intended by design). Instead of separate directories, images should be tagged 'linux' or 'osx' and managed by backstop in bitmap_reference. Most everything else is platform agnostic so separate platform directories are not necessary.

Let me know what you think.

Copy link
Owner

@garris garris left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes.

I will pull these changes directly from your branch and test on 6/15.

I’ll put the css line back and also take care of line 131.

Thanks for all your work on this — it’s awesome.

Best
Garris

@@ -125,15 +128,16 @@ module.exports = {
paths: {
bitmaps_reference: 'backstop_data/bitmaps_reference',
bitmaps_test: 'backstop_data/bitmaps_test',
engine_scripts: 'backstop_data/engine_scripts',
engine_scripts: 'engine_scripts',
Copy link
Owner

Choose a reason for hiding this comment

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

Should also be under backstop data.

@gabegorelick
Copy link
Contributor

Is there anything preventing this from being merged, aside from needing a rebase? More tests would give contributors a lot of confidence their changes won't break things.

@KenCoder
Copy link
Contributor Author

We need to address #842 for the smoke tests to pass consistently. Then it needs to rebase.

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.

3 participants