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

[ci-visibility] Fix cucumber parallel mode #3156

Merged
merged 2 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 28 additions & 0 deletions integration-tests/cucumber/cucumber.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,34 @@ versions.forEach(version => {
})
const reportMethods = ['agentless', 'evp proxy']

it('does not crash with parallel mode', (done) => {
let testOutput
childProcess = exec(
juan-fernandez marked this conversation as resolved.
Show resolved Hide resolved
`./node_modules/.bin/cucumber-js ci-visibility/features/farewell.feature --parallel 2 --publish-quiet`,
{
cwd,
env: {
...getCiVisAgentlessConfig(receiver.port),
DD_TRACE_DEBUG: 1,
DD_TRACE_LOG_LEVEL: 'warn'
},
stdio: 'inherit'
}
)
childProcess.stdout.on('data', (chunk) => {
testOutput += chunk.toString()
})
childProcess.stderr.on('data', (chunk) => {
testOutput += chunk.toString()
})
childProcess.on('exit', (code) => {
assert.notInclude(testOutput, 'TypeError')
assert.include(testOutput, 'Unable to initialize CI Visibility because Cucumber is running in parallel mode.')
assert.equal(code, 0)
done()
})
})

reportMethods.forEach((reportMethod) => {
context(`reporting via ${reportMethod}`, () => {
let envVars, isAgentless
Expand Down
13 changes: 13 additions & 0 deletions packages/datadog-instrumentations/src/cucumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { createCoverageMap } = require('istanbul-lib-coverage')

const { addHook, channel, AsyncResource } = require('./helpers/instrument')
const shimmer = require('../../datadog-shimmer')
const log = require('../../dd-trace/src/log')

const testStartCh = channel('ci:cucumber:test:start')
const testFinishCh = channel('ci:cucumber:test:finish') // used for test steps too
Expand Down Expand Up @@ -175,6 +176,12 @@ function wrapRun (pl, isLatestVersion) {
}

function pickleHook (PickleRunner) {
if (process.env.CUCUMBER_WORKER_ID) {
// Parallel mode is not supported
log.warn('Unable to initialize CI Visibility because Cucumber is running in parallel mode.')
return PickleRunner
}

const pl = PickleRunner.default

wrapRun(pl, false)
Expand All @@ -183,6 +190,12 @@ function pickleHook (PickleRunner) {
}

function testCaseHook (TestCaseRunner) {
if (process.env.CUCUMBER_WORKER_ID) {
// Parallel mode is not supported
log.warn('Unable to initialize CI Visibility because Cucumber is running in parallel mode.')
return TestCaseRunner
}

const pl = TestCaseRunner.default

wrapRun(pl, true)
Expand Down