Skip to content

Commit

Permalink
Merge branch 'master' into zarir/remove-inferred-http-route
Browse files Browse the repository at this point in the history
  • Loading branch information
zarirhamza authored Jan 22, 2025
2 parents 1570f8b + 37546ab commit 79b7904
Show file tree
Hide file tree
Showing 28 changed files with 1,163 additions and 419 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ Most of the documentation for `dd-trace` is available on these webpages:

## Version Release Lines and Maintenance

| Release Line | Latest Version | Node.js | Status |Initial Release | End of Life |
| :---: | :---: | :---: | :---: | :---: | :---: |
| [`v1`](https://github.com/DataDog/dd-trace-js/tree/v1.x) | ![npm v1](https://img.shields.io/npm/v/dd-trace/legacy-v1?color=white&label=%20&style=flat-square) | `>= v12` | **End of Life** | 2021-07-13 | 2022-02-25 |
| [`v2`](https://github.com/DataDog/dd-trace-js/tree/v2.x) | ![npm v2](https://img.shields.io/npm/v/dd-trace/latest-node12?color=white&label=%20&style=flat-square) | `>= v12` | **End of Life** | 2022-01-28 | 2023-08-15 |
| [`v3`](https://github.com/DataDog/dd-trace-js/tree/v3.x) | ![npm v3](https://img.shields.io/npm/v/dd-trace/latest-node14?color=white&label=%20&style=flat-square) | `>= v14` | **End of Life** | 2022-08-15 | 2024-05-15 |
| [`v4`](https://github.com/DataDog/dd-trace-js/tree/v4.x) | ![npm v4](https://img.shields.io/npm/v/dd-trace/latest-node16?color=white&label=%20&style=flat-square) | `>= v16` | **Maintenance** | 2023-05-12 | 2025-01-11 |
| [`v5`](https://github.com/DataDog/dd-trace-js/tree/v5.x) | ![npm v5](https://img.shields.io/npm/v/dd-trace/latest?color=white&label=%20&style=flat-square) | `>= v18` | **Current** | 2024-01-11 | Unknown |
| Release Line | Latest Version | Node.js | [SSI](https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/single-step-apm/?tab=linuxhostorvm) | [K8s Injection](https://docs.datadoghq.com/tracing/trace_collection/library_injection_local/?tab=kubernetes) |Status |Initial Release | End of Life |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| [`v1`](https://github.com/DataDog/dd-trace-js/tree/v1.x) | ![npm v1](https://img.shields.io/npm/v/dd-trace/legacy-v1?color=white&label=%20&style=flat-square) | `>= v12` | NO | NO | **End of Life** | 2021-07-13 | 2022-02-25 |
| [`v2`](https://github.com/DataDog/dd-trace-js/tree/v2.x) | ![npm v2](https://img.shields.io/npm/v/dd-trace/latest-node12?color=white&label=%20&style=flat-square) | `>= v12` | NO | NO | **End of Life** | 2022-01-28 | 2023-08-15 |
| [`v3`](https://github.com/DataDog/dd-trace-js/tree/v3.x) | ![npm v3](https://img.shields.io/npm/v/dd-trace/latest-node14?color=white&label=%20&style=flat-square) | `>= v14` | NO | YES | **End of Life** | 2022-08-15 | 2024-05-15 |
| [`v4`](https://github.com/DataDog/dd-trace-js/tree/v4.x) | ![npm v4](https://img.shields.io/npm/v/dd-trace/latest-node16?color=white&label=%20&style=flat-square) | `>= v16` | YES | YES | **Maintenance** | 2023-05-12 | 2025-01-11 |
| [`v5`](https://github.com/DataDog/dd-trace-js/tree/v5.x) | ![npm v5](https://img.shields.io/npm/v/dd-trace/latest?color=white&label=%20&style=flat-square) | `>= v18` | YES | YES | **Current** | 2024-01-11 | Unknown |

* SSI = Single-Step Install

We currently maintain two release lines, namely `v5`, and `v4`.
Features and bug fixes that are merged are released to the `v5` line and, if appropriate, also `v4`.
Expand Down
175 changes: 132 additions & 43 deletions integration-tests/cucumber/cucumber.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ const {
DI_DEBUG_ERROR_PREFIX,
DI_DEBUG_ERROR_FILE_SUFFIX,
DI_DEBUG_ERROR_SNAPSHOT_ID_SUFFIX,
DI_DEBUG_ERROR_LINE_SUFFIX
DI_DEBUG_ERROR_LINE_SUFFIX,
TEST_RETRY_REASON
} = require('../../packages/dd-trace/src/plugins/util/test')
const { DD_HOST_CPU_COUNT } = require('../../packages/dd-trace/src/plugins/util/env')

Expand Down Expand Up @@ -844,15 +845,13 @@ versions.forEach(version => {
it('retries new tests', (done) => {
const NUM_RETRIES_EFD = 3
receiver.setSettings({
itr_enabled: false,
code_coverage: false,
tests_skipping: false,
early_flake_detection: {
enabled: true,
slow_test_retries: {
'5s': NUM_RETRIES_EFD
}
}
},
known_tests_enabled: true
})
// cucumber.ci-visibility/features/farewell.feature.Say whatever will be considered new
receiver.setKnownTests(
Expand Down Expand Up @@ -884,6 +883,9 @@ versions.forEach(version => {
retriedTests.length
)
assert.equal(retriedTests.length, NUM_RETRIES_EFD)
retriedTests.forEach(test => {
assert.propertyVal(test.meta, TEST_RETRY_REASON, 'efd')
})
// Test name does not change
newTests.forEach(test => {
assert.equal(test.meta[TEST_NAME], 'Say whatever')
Expand All @@ -907,15 +909,13 @@ versions.forEach(version => {
it('is disabled if DD_CIVISIBILITY_EARLY_FLAKE_DETECTION_ENABLED is false', (done) => {
const NUM_RETRIES_EFD = 3
receiver.setSettings({
itr_enabled: false,
code_coverage: false,
tests_skipping: false,
early_flake_detection: {
enabled: true,
slow_test_retries: {
'5s': NUM_RETRIES_EFD
}
}
},
known_tests_enabled: true
})

const eventsPromise = receiver
Expand All @@ -928,8 +928,12 @@ versions.forEach(version => {
const newTests = tests.filter(test =>
test.meta[TEST_IS_NEW] === 'true'
)
// new tests are not detected
assert.equal(newTests.length, 0)
// new tests are detected but not retried
assert.equal(newTests.length, 1)
const retriedTests = tests.filter(test =>
test.meta[TEST_IS_RETRY] === 'true'
)
assert.equal(retriedTests.length, 0)
})
// cucumber.ci-visibility/features/farewell.feature.Say whatever will be considered new
receiver.setKnownTests({
Expand Down Expand Up @@ -957,15 +961,13 @@ versions.forEach(version => {
it('retries flaky tests and sets exit code to 0 as long as one attempt passes', (done) => {
const NUM_RETRIES_EFD = 3
receiver.setSettings({
itr_enabled: false,
code_coverage: false,
tests_skipping: false,
early_flake_detection: {
enabled: true,
slow_test_retries: {
'5s': NUM_RETRIES_EFD
}
}
},
known_tests_enabled: true
})
// Tests in "cucumber.ci-visibility/features-flaky/flaky.feature" will be considered new
receiver.setKnownTests({})
Expand Down Expand Up @@ -1014,15 +1016,13 @@ versions.forEach(version => {
it('does not retry tests that are skipped', (done) => {
const NUM_RETRIES_EFD = 3
receiver.setSettings({
itr_enabled: false,
code_coverage: false,
tests_skipping: false,
early_flake_detection: {
enabled: true,
slow_test_retries: {
'5s': NUM_RETRIES_EFD
}
}
},
known_tests_enabled: true
})
// "cucumber.ci-visibility/features/farewell.feature.Say whatever" will be considered new
// "cucumber.ci-visibility/features/greetings.feature.Say skip" will be considered new
Expand Down Expand Up @@ -1066,15 +1066,13 @@ versions.forEach(version => {
it('does not run EFD if the known tests request fails', (done) => {
const NUM_RETRIES_EFD = 3
receiver.setSettings({
itr_enabled: false,
code_coverage: false,
tests_skipping: false,
early_flake_detection: {
enabled: true,
slow_test_retries: {
'5s': NUM_RETRIES_EFD
}
}
},
known_tests_enabled: true
})
receiver.setKnownTestsResponseCode(500)
receiver.setKnownTests({})
Expand Down Expand Up @@ -1108,16 +1106,14 @@ versions.forEach(version => {
it('bails out of EFD if the percentage of new tests is too high', (done) => {
const NUM_RETRIES_EFD = 3
receiver.setSettings({
itr_enabled: false,
code_coverage: false,
tests_skipping: false,
early_flake_detection: {
enabled: true,
slow_test_retries: {
'5s': NUM_RETRIES_EFD
},
faulty_session_threshold: 0
}
},
known_tests_enabled: true
})
// tests in cucumber.ci-visibility/features/farewell.feature will be considered new
receiver.setKnownTests(
Expand Down Expand Up @@ -1160,20 +1156,70 @@ versions.forEach(version => {
})
})

it('disables early flake detection if known tests should not be requested', (done) => {
const NUM_RETRIES_EFD = 3
receiver.setSettings({
early_flake_detection: {
enabled: true,
slow_test_retries: {
'5s': NUM_RETRIES_EFD
}
},
known_tests_enabled: false
})
// cucumber.ci-visibility/features/farewell.feature.Say whatever will be considered new
receiver.setKnownTests(
{
cucumber: {
'ci-visibility/features/farewell.feature': ['Say farewell'],
'ci-visibility/features/greetings.feature': ['Say greetings', 'Say yeah', 'Say yo', 'Say skip']
}
}
)
const eventsPromise = receiver
.gatherPayloadsMaxTimeout(({ url }) => url.endsWith('/api/v2/citestcycle'), (payloads) => {
const events = payloads.flatMap(({ payload }) => payload.events)

const testSession = events.find(event => event.type === 'test_session_end').content
assert.notProperty(testSession.meta, TEST_EARLY_FLAKE_ENABLED)
const tests = events.filter(event => event.type === 'test').map(event => event.content)

// no new tests detected
const newTests = tests.filter(test => test.meta[TEST_IS_NEW] === 'true')
assert.equal(newTests.length, 0)
// no retries
const retriedTests = newTests.filter(test => test.meta[TEST_IS_RETRY] === 'true')
assert.equal(retriedTests.length, 0)
})

childProcess = exec(
runTestsCommand,
{
cwd,
env: envVars,
stdio: 'pipe'
}
)

childProcess.on('exit', () => {
eventsPromise.then(() => {
done()
}).catch(done)
})
})

if (version !== '7.0.0') { // EFD in parallel mode only supported from cucumber>=11
context('parallel mode', () => {
it('retries new tests', (done) => {
const NUM_RETRIES_EFD = 3
receiver.setSettings({
itr_enabled: false,
code_coverage: false,
tests_skipping: false,
early_flake_detection: {
enabled: true,
slow_test_retries: {
'5s': NUM_RETRIES_EFD
}
}
},
known_tests_enabled: true
})
// cucumber.ci-visibility/features/farewell.feature.Say whatever will be considered new
receiver.setKnownTests(
Expand Down Expand Up @@ -1231,15 +1277,13 @@ versions.forEach(version => {
it('retries flaky tests and sets exit code to 0 as long as one attempt passes', (done) => {
const NUM_RETRIES_EFD = 3
receiver.setSettings({
itr_enabled: false,
code_coverage: false,
tests_skipping: false,
early_flake_detection: {
enabled: true,
slow_test_retries: {
'5s': NUM_RETRIES_EFD
}
}
},
known_tests_enabled: true
})
// Tests in "cucumber.ci-visibility/features-flaky/flaky.feature" will be considered new
receiver.setKnownTests({})
Expand Down Expand Up @@ -1293,16 +1337,14 @@ versions.forEach(version => {
it('bails out of EFD if the percentage of new tests is too high', (done) => {
const NUM_RETRIES_EFD = 3
receiver.setSettings({
itr_enabled: false,
code_coverage: false,
tests_skipping: false,
early_flake_detection: {
enabled: true,
slow_test_retries: {
'5s': NUM_RETRIES_EFD
},
faulty_session_threshold: 0
}
},
known_tests_enabled: true
})
// tests in cucumber.ci-visibility/features/farewell.feature will be considered new
receiver.setKnownTests(
Expand Down Expand Up @@ -1350,15 +1392,13 @@ versions.forEach(version => {
it('does not retry tests that are skipped', (done) => {
const NUM_RETRIES_EFD = 3
receiver.setSettings({
itr_enabled: false,
code_coverage: false,
tests_skipping: false,
early_flake_detection: {
enabled: true,
slow_test_retries: {
'5s': NUM_RETRIES_EFD
}
}
},
known_tests_enabled: true
})
// "cucumber.ci-visibility/features/farewell.feature.Say whatever" will be considered new
// "cucumber.ci-visibility/features/greetings.feature.Say skip" will be considered new
Expand Down Expand Up @@ -1909,5 +1949,54 @@ versions.forEach(version => {
})
})
})

context('known tests without early flake detection', () => {
it('detects new tests without retrying them', (done) => {
receiver.setSettings({
early_flake_detection: {
enabled: false
},
known_tests_enabled: true
})
// cucumber.ci-visibility/features/farewell.feature.Say whatever will be considered new
receiver.setKnownTests(
{
cucumber: {
'ci-visibility/features/farewell.feature': ['Say farewell'],
'ci-visibility/features/greetings.feature': ['Say greetings', 'Say yeah', 'Say yo', 'Say skip']
}
}
)
const eventsPromise = receiver
.gatherPayloadsMaxTimeout(({ url }) => url.endsWith('/api/v2/citestcycle'), (payloads) => {
const events = payloads.flatMap(({ payload }) => payload.events)

const testSession = events.find(event => event.type === 'test_session_end').content
assert.notProperty(testSession.meta, TEST_EARLY_FLAKE_ENABLED)
const tests = events.filter(event => event.type === 'test').map(event => event.content)

// new tests detected but not retried
const newTests = tests.filter(test => test.meta[TEST_IS_NEW] === 'true')
assert.equal(newTests.length, 1)
const retriedTests = newTests.filter(test => test.meta[TEST_IS_RETRY] === 'true')
assert.equal(retriedTests.length, 0)
})

childProcess = exec(
runTestsCommand,
{
cwd,
env: getCiVisAgentlessConfig(receiver.port),
stdio: 'pipe'
}
)

childProcess.on('exit', () => {
eventsPromise.then(() => {
done()
}).catch(done)
})
})
})
})
})
Loading

0 comments on commit 79b7904

Please sign in to comment.