Skip to content

Commit

Permalink
add configuration flag
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-fernandez committed Aug 16, 2024
1 parent 604b6ea commit 97fdb5b
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
50 changes: 50 additions & 0 deletions integration-tests/jest/jest.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2232,5 +2232,55 @@ describe('jest CommonJS', () => {
}).catch(done)
})
})

it('is disabled if DD_CIVISIBILITY_FLAKY_RETRY_ENABLED is false', (done) => {
receiver.setSettings({
itr_enabled: false,
code_coverage: false,
tests_skipping: false,
flaky_test_retries_enabled: true,
early_flake_detection: {
enabled: false
}
})

const eventsPromise = receiver
.gatherPayloadsMaxTimeout(({ url }) => url.endsWith('/api/v2/citestcycle'), (payloads) => {
const events = payloads.flatMap(({ payload }) => payload.events)

const tests = events.filter(event => event.type === 'test').map(event => event.content)

assert.equal(tests.length, 3)
assert.includeMembers(tests.map(test => test.resource), [
// does not retry anything
'ci-visibility/jest-flaky/flaky-passes.js.test-flaky-test-retries will not retry passed tests',
'ci-visibility/jest-flaky/flaky-passes.js.test-flaky-test-retries can retry flaky tests',
'ci-visibility/jest-flaky/flaky-fails.js.test-flaky-test-retries can retry failed tests'
])

const retriedTests = tests.filter(test => test.meta[TEST_IS_RETRY] === 'true')

assert.equal(retriedTests.length, 0)
})

childProcess = exec(
runTestsWithCoverageCommand,
{
cwd,
env: {
...getCiVisEvpProxyConfig(receiver.port),
TESTS_TO_RUN: 'jest-flaky/flaky-',
DD_CIVISIBILITY_FLAKY_RETRY_ENABLED: 'false'
},
stdio: 'inherit'
}
)

childProcess.on('exit', () => {
eventsPromise.then(() => {
done()
}).catch(done)
})
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class CiVisibilityExporter extends AgentInfoExporter {
isEarlyFlakeDetectionEnabled: isEarlyFlakeDetectionEnabled && this._config.isEarlyFlakeDetectionEnabled,
earlyFlakeDetectionNumRetries,
earlyFlakeDetectionFaultyThreshold,
isFlakyTestRetriesEnabled
isFlakyTestRetriesEnabled: isFlakyTestRetriesEnabled && this._config.isFlakyTestRetriesEnabled
}
}

Expand Down
9 changes: 8 additions & 1 deletion packages/dd-trace/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ class Config {
this._setValue(defaults, 'isAzureFunction', false)
this._setValue(defaults, 'isCiVisibility', false)
this._setValue(defaults, 'isEarlyFlakeDetectionEnabled', false)
this._setValue(defaults, 'isFlakyTestRetriesEnabled', false)
this._setValue(defaults, 'isGCPFunction', false)
this._setValue(defaults, 'isGitUploadEnabled', false)
this._setValue(defaults, 'isIntelligentTestRunnerEnabled', false)
Expand Down Expand Up @@ -981,7 +982,8 @@ class Config {

const {
DD_CIVISIBILITY_AGENTLESS_URL,
DD_CIVISIBILITY_EARLY_FLAKE_DETECTION_ENABLED
DD_CIVISIBILITY_EARLY_FLAKE_DETECTION_ENABLED,
DD_CIVISIBILITY_FLAKY_RETRY_ENABLED
} = process.env

if (DD_CIVISIBILITY_AGENTLESS_URL) {
Expand All @@ -992,6 +994,11 @@ class Config {
if (this._isCiVisibility()) {
this._setBoolean(calc, 'isEarlyFlakeDetectionEnabled',
coalesce(DD_CIVISIBILITY_EARLY_FLAKE_DETECTION_ENABLED, true))
console.log('coalesce(DD_CIVISIBILITY_FLAKY_RETRY_ENABLED, true)', coalesce(DD_CIVISIBILITY_FLAKY_RETRY_ENABLED, true))

Check failure on line 997 in packages/dd-trace/src/config.js

View workflow job for this annotation

GitHub Actions / lint

This line has a length of 125. Maximum allowed is 120

Check failure on line 997 in packages/dd-trace/src/config.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

this._setBoolean(calc, 'isFlakyTestRetriesEnabled',
coalesce(DD_CIVISIBILITY_FLAKY_RETRY_ENABLED, true))
console.log('calc.isFlakyTestRetriesEnabled', calc.isFlakyTestRetriesEnabled)

Check failure on line 1001 in packages/dd-trace/src/config.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
this._setBoolean(calc, 'isIntelligentTestRunnerEnabled', isTrue(this._isCiVisibilityItrEnabled()))
this._setBoolean(calc, 'isManualApiEnabled', this._isCiVisibilityManualApiEnabled())
}
Expand Down

0 comments on commit 97fdb5b

Please sign in to comment.