-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Honeycomb system-test reporter (#19855)
* Mocha performance reporter Co-authored-by: Tim Griesser <tgriesser10@gmail.com>
- Loading branch information
Showing
8 changed files
with
277 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
const path = require('path') | ||
const chalk = require('chalk') | ||
const Libhoney = require('libhoney') | ||
|
||
const pkg = require('@packages/root') | ||
const ciProvider = require('@packages/server/lib/util/ci_provider') | ||
const { commitInfo } = require('@cypress/commit-info') | ||
|
||
class StatsdReporter { | ||
constructor (runner) { | ||
if (!process.env.HONEYCOMB_API_KEY) { | ||
return | ||
} | ||
|
||
console.log(chalk.green('Reporting to honeycomb')) | ||
|
||
let branch; let commitSha | ||
|
||
this.honey = new Libhoney({ | ||
dataset: 'systemtest-performance', | ||
writeKey: process.env.HONEYCOMB_API_KEY, | ||
}) | ||
|
||
commitInfo().then((commitInformation) => { | ||
const ciInformation = ciProvider.commitParams() || {} | ||
|
||
this.branch = commitInformation.branch || ciInformation.branch | ||
this.commitSha = commitInformation.sha || ciInformation.sha | ||
}) | ||
|
||
runner.on('test', (test) => { | ||
test.wallclockStart = Date.now() | ||
}) | ||
|
||
runner.on('test end', (test) => { | ||
// Skipped tests never get a 'start' event, but they still get 'test end' somehow. | ||
if (!test.state || test.state === 'skipped') { | ||
return | ||
} | ||
|
||
const title = test.titlePath().join(' / ') | ||
// This regex pulls apart a string like `e2e async timeouts / failing1 [electron]` | ||
// into `e2e async timeouts / failing1` and `electron`, letting us use the same | ||
// test name for all browsers, with the browser as a separate field. | ||
// The browser capture group is optional because some tests aren't browser specific, | ||
// in which case it will be undefined and not passed as a field to honeycomb. | ||
const [, testTitle, browser] = title.match(/(.+?)(?: \[([a-z]+)\])?$/) | ||
|
||
const honeycombEvent = this.honey.newEvent() | ||
|
||
honeycombEvent.timestamp = test.wallclockStart | ||
honeycombEvent.add({ | ||
test: testTitle, | ||
specFile: path.basename(test.file), | ||
browser, | ||
state: test.state, | ||
err: test.err && test.err.message, | ||
errStack: test.err && test.err.stack, | ||
durationMs: Date.now() - test.wallclockStart, | ||
mochaDurationMs: test.duration, | ||
branch, | ||
commitSha, | ||
buildUrl: process.env.CIRCLE_BUILD_URL, | ||
platform: process.platform, | ||
arch: process.arch, | ||
version: pkg.version, | ||
}) | ||
|
||
honeycombEvent.send() | ||
}) | ||
} | ||
|
||
// If there is no done callback, then mocha-multi-reporter will kill the process without waiting for our honeycomb post to complete. | ||
done (failures, callback) { | ||
if (this.honey) { | ||
this.honey.flush().then(callback) | ||
} | ||
} | ||
} | ||
|
||
module.exports = StatsdReporter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"reporterEnabled": "spec, mocha-junit-reporter, ../../system-tests/lib/performance-reporter.js", | ||
"mochaJunitReporterReporterOptions": { | ||
"mochaFile": "/tmp/cypress/junit/test-results.[hash].xml" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
f5cb2b9
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.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
f5cb2b9
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.
Circle has built the
win32 x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
f5cb2b9
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.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: