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

[ftr] take screenshots on failure #11709

Merged
merged 6 commits into from
May 11, 2017

Conversation

spalger
Copy link
Contributor

@spalger spalger commented May 10, 2017

Just like the functional tests used to, these changes update them to take screenshots automatically on any test failure. To accomplish this the lifecycle service now has testFailure and testHookFailure events that can asynchronously do some action at those points. The screenshot service was then updated to use those lifecycle events to take the screenshots.

@spalger spalger added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc test v5.5.0 v6.0.0 labels May 10, 2017
@spalger spalger requested review from rhoboat and stacey-gammon May 10, 2017 19:08
@stacey-gammon
Copy link
Contributor

Whoa you weren't kidding that was non-trivial! I skimmed the code, but most of it was over my head. :) I did sync locally and it ran and stored a screenshot, so LGTM! 🎉

@spalger
Copy link
Contributor Author

spalger commented May 10, 2017

Haha :) yeah, https://github.com/elastic/kibana/blob/5.3/test/support/utils/bdd_wrapper.js was a lot harder to implement for mocha

Copy link

@rhoboat rhoboat left a comment

Choose a reason for hiding this comment

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

LGTM! ⛵️ :electron: 🖌

@@ -11,7 +11,7 @@ import {
VisualizePageProvider,
SettingsPageProvider,
MonitoringPageProvider,
PointSeriesPageProvider
PointSeriesPageProvider,
Copy link

Choose a reason for hiding this comment

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

💓 Thank you, for this, and other changes like it.

@@ -22,7 +22,8 @@ import {
KibanaServerProvider,
EsProvider,
EsArchiverProvider,
DocTableProvider
DocTableProvider,
ScreenshotsProvider,
Copy link

Choose a reason for hiding this comment

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

Going through all the files, I got tired of reading "screenshots.take". I'm wondering whether you considered calling it screenshot, singular. ScreenshotProvider, screenshot.take, getService("screenshot"). What do you think?

Copy link

Choose a reason for hiding this comment

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

Hmm.. Nevermind on this comment. I think it's more consistent to have it plural.

await fcb(cb => mkdirp(directory, cb));
const [screenshot] = await Promise.all([
remote.takeScreenshot(),
fcb(cb => mkdirp(dirname(path), cb)),
Copy link

Choose a reason for hiding this comment

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

This is okay to do in parallel, is that why we are making this change? I think it's thoughtful that you noticed this.

} catch(e) {
done();
return;
}
Copy link

Choose a reason for hiding this comment

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

Nice, thanks.

Copy link

Choose a reason for hiding this comment

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

also line 3, no need to change path to resolve, but thought i'd point it out.

})
.catch(function (error) {
expect(error.message).to.be('fail.');
done();
Copy link

Choose a reason for hiding this comment

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

Nice

})
.on('testHookFailure', async (err, test) => {
log.info('testHookFailure %s %s', err.message, test.fullTitle());
await delay(10);
Copy link

Choose a reason for hiding this comment

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

why the delay? mimicking a screenshot.take?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just verifying that it's waiting for the hook to run async.


expect(tests).to.have.length(0);
});
});
Copy link

Choose a reason for hiding this comment

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

Interesting way to test this!

}

return createAssignmentProxy(context, assignmentInterceptor);
}
Copy link

Choose a reason for hiding this comment

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

Okay, so the original thing that was wrapping our methods was doing it one way for describe functions and another way for all non-describe functions. The new implementation cares about more types of functions because we want to enforce single top level suite and no functions outside of describes. Nice work

@spalger spalger merged commit 2e7fed8 into elastic:master May 11, 2017
spalger added a commit to spalger/kibana that referenced this pull request May 11, 2017
* [tests/functional] move screenshots to their own service

* [ftr] add testFailure and testHookFailure lifecycle hooks

* [tests/functional/screenshots] cleanup old screenshots at startup

* [test/functional/screenshots] take screenshots when tests fail

* [cli_plugin/install] fix test

* [ui/scanner] fix test

(cherry picked from commit 2e7fed8)
spalger added a commit that referenced this pull request May 11, 2017
* [tests/functional] move screenshots to their own service

* [ftr] add testFailure and testHookFailure lifecycle hooks

* [tests/functional/screenshots] cleanup old screenshots at startup

* [test/functional/screenshots] take screenshots when tests fail

* [cli_plugin/install] fix test

* [ui/scanner] fix test

(cherry picked from commit 2e7fed8)
snide pushed a commit to snide/kibana that referenced this pull request May 30, 2017
* [tests/functional] move screenshots to their own service

* [ftr] add testFailure and testHookFailure lifecycle hooks

* [tests/functional/screenshots] cleanup old screenshots at startup

* [test/functional/screenshots] take screenshots when tests fail

* [cli_plugin/install] fix test

* [ui/scanner] fix test
@spalger spalger deleted the fix/screenshots-on-failure branch October 18, 2019 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc test v5.5.0 v6.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants