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

v3.28.0 proposal #3383

Merged
merged 14 commits into from
Jul 14, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions benchmark/sirun/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# The version of this file in master is used across all PRs regardless of upstream branch
FROM --platform=linux/amd64 ubuntu:22.04

RUN apt-get update && apt-get install --no-install-recommends -y \
Expand Down Expand Up @@ -25,11 +26,14 @@ RUN wget -O sirun.tar.gz https://github.com/DataDog/sirun/releases/download/v0.1
&& rm sirun.tar.gz \
&& mv sirun /usr/bin/sirun

# This list of installed Node.js versions should include all versions used by any active release line
RUN mkdir -p /usr/local/nvm \
&& wget -q -O - https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install --no-progress 14.20.1 \
&& nvm install --no-progress 16.17.1 \
&& nvm install --no-progress 18.10.0 \
&& nvm install --no-progress 12.22.12 \
&& nvm install --no-progress 14.21.3 \
&& nvm install --no-progress 16.20.1 \
&& nvm install --no-progress 18.16.1 \
&& nvm install --no-progress 20.4.0 \
&& nvm alias default 18 \
&& nvm use 18
2 changes: 1 addition & 1 deletion benchmark/sirun/appsec-iast/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

module.exports = {
port: 3331 + parseInt(process.env.CPU_AFFINITY || '0'),
reqs: 200
reqs: 100
}
2 changes: 1 addition & 1 deletion benchmark/sirun/appsec-iast/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "appsec-iast",
"cachegrind": false,
"instructions": true,
"iterations": 30,
"iterations": 15,
"variants": {
"no-vulnerability-control": {
"setup": "bash -c \"nohup node client.js >/dev/null 2>&1 &\"",
Expand Down
1 change: 1 addition & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ tracer.use('pg', {
* [net](./interfaces/plugins.net.html)
* [next](./interfaces/plugins.next.html)
* [opensearch](./interfaces/plugins.opensearch.html)
* [openai](./interfaces/plugins.openai.html)
* [oracledb](./interfaces/plugins.oracledb.html)
* [paperplane](./interfaces/plugins.paperplane.html)
* [pino](./interfaces/plugins.pino.html)
Expand Down
68 changes: 68 additions & 0 deletions integration-tests/ci-visibility.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,40 @@ testFrameworks.forEach(({
}
)
})
it('sets _dd.ci.itr.tests_skipped to false if the received suite is not skipped', (done) => {
receiver.setSuitesToSkip([{
type: 'suite',
attributes: {
suite: 'ci-visibility/test/not-existing-test.js'
}
}])
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.propertyVal(testSession.meta, TEST_ITR_TESTS_SKIPPED, 'false')
assert.propertyVal(testSession.meta, TEST_CODE_COVERAGE_ENABLED, 'true')
assert.propertyVal(testSession.meta, TEST_ITR_SKIPPING_ENABLED, 'true')
const testModule = events.find(event => event.type === 'test_module_end').content
assert.propertyVal(testModule.meta, TEST_ITR_TESTS_SKIPPED, 'false')
assert.propertyVal(testModule.meta, TEST_CODE_COVERAGE_ENABLED, 'true')
assert.propertyVal(testModule.meta, TEST_ITR_SKIPPING_ENABLED, 'true')
}, 25000)

childProcess = exec(
runTestsWithCoverageCommand,
{
cwd,
env: getCiVisAgentlessConfig(receiver.port),
stdio: 'inherit'
}
)
childProcess.on('exit', () => {
eventsPromise.then(() => {
done()
}).catch(done)
})
})
})

describe('evp proxy', () => {
Expand Down Expand Up @@ -921,6 +955,40 @@ testFrameworks.forEach(({
}
)
})
it('sets _dd.ci.itr.tests_skipped to false if the received suite is not skipped', (done) => {
receiver.setSuitesToSkip([{
type: 'suite',
attributes: {
suite: 'ci-visibility/test/not-existing-test.js'
}
}])
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.propertyVal(testSession.meta, TEST_ITR_TESTS_SKIPPED, 'false')
assert.propertyVal(testSession.meta, TEST_CODE_COVERAGE_ENABLED, 'true')
assert.propertyVal(testSession.meta, TEST_ITR_SKIPPING_ENABLED, 'true')
const testModule = events.find(event => event.type === 'test_module_end').content
assert.propertyVal(testModule.meta, TEST_ITR_TESTS_SKIPPED, 'false')
assert.propertyVal(testModule.meta, TEST_CODE_COVERAGE_ENABLED, 'true')
assert.propertyVal(testModule.meta, TEST_ITR_SKIPPING_ENABLED, 'true')
}, 25000)

childProcess = exec(
runTestsWithCoverageCommand,
{
cwd,
env: getCiVisEvpProxyConfig(receiver.port),
stdio: 'inherit'
}
)
childProcess.on('exit', () => {
eventsPromise.then(() => {
done()
}).catch(done)
})
})
})
})
})
34 changes: 34 additions & 0 deletions integration-tests/cucumber/cucumber.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,40 @@ versions.forEach(version => {
}
)
})
it('sets _dd.ci.itr.tests_skipped to false if the received suite is not skipped', (done) => {
receiver.setSuitesToSkip([{
type: 'suite',
attributes: {
suite: 'ci-visibility/features/not-existing.feature'
}
}])
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.propertyVal(testSession.meta, TEST_ITR_TESTS_SKIPPED, 'false')
assert.propertyVal(testSession.meta, TEST_CODE_COVERAGE_ENABLED, 'true')
assert.propertyVal(testSession.meta, TEST_ITR_SKIPPING_ENABLED, 'true')
const testModule = events.find(event => event.type === 'test_module_end').content
assert.propertyVal(testModule.meta, TEST_ITR_TESTS_SKIPPED, 'false')
assert.propertyVal(testModule.meta, TEST_CODE_COVERAGE_ENABLED, 'true')
assert.propertyVal(testModule.meta, TEST_ITR_SKIPPING_ENABLED, 'true')
}, 25000)

childProcess = exec(
runTestsWithCoverageCommand,
{
cwd,
env: envVars,
stdio: 'inherit'
}
)
childProcess.on('exit', () => {
eventsPromise.then(() => {
done()
}).catch(done)
})
})
if (!isAgentless) {
context('if the agent is not event platform proxy compatible', () => {
it('does not do any intelligent test runner request', (done) => {
Expand Down
52 changes: 51 additions & 1 deletion integration-tests/cypress/cypress.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ describe(`cypress@${version}`, function () {
}).catch(done)
})
})
it('can skip suites received by the intelligent test runner API and still reports code coverage', (done) => {
it('can skip tests received by the intelligent test runner API and still reports code coverage', (done) => {
receiver.setSuitesToSkip([{
type: 'test',
attributes: {
Expand Down Expand Up @@ -473,5 +473,55 @@ describe(`cypress@${version}`, function () {
}).catch(done)
})
})
it('sets _dd.ci.itr.tests_skipped to false if the received test is not skipped', (done) => {
receiver.setSuitesToSkip([{
type: 'test',
attributes: {
name: 'fake name',
suite: 'i/dont/exist.spec.js'
}
}])
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.propertyVal(testSession.meta, TEST_ITR_TESTS_SKIPPED, 'false')
assert.propertyVal(testSession.meta, TEST_CODE_COVERAGE_ENABLED, 'true')
assert.propertyVal(testSession.meta, TEST_ITR_SKIPPING_ENABLED, 'true')
const testModule = events.find(event => event.type === 'test_module_end').content
assert.propertyVal(testModule.meta, TEST_ITR_TESTS_SKIPPED, 'false')
assert.propertyVal(testModule.meta, TEST_CODE_COVERAGE_ENABLED, 'true')
assert.propertyVal(testModule.meta, TEST_ITR_SKIPPING_ENABLED, 'true')
}, 25000)

const skippableRequestPromise = receiver
.payloadReceived(({ url }) => url.endsWith('/api/v2/ci/tests/skippable'))
.then(skippableRequest => {
assert.propertyVal(skippableRequest.headers, 'dd-api-key', '1')
assert.propertyVal(skippableRequest.headers, 'dd-application-key', '1')
})

const {
NODE_OPTIONS,
...restEnvVars
} = getCiVisAgentlessConfig(receiver.port)

childProcess = exec(
`./node_modules/.bin/cypress run --quiet ${commandSuffix}`,
{
cwd,
env: {
...restEnvVars,
CYPRESS_BASE_URL: `http://localhost:${webAppPort}`
},
stdio: 'pipe'
}
)
childProcess.on('exit', () => {
Promise.all([eventsPromise, skippableRequestPromise]).then(() => {
done()
}).catch(done)
})
})
})
})
5 changes: 3 additions & 2 deletions integration-tests/playwright/playwright.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const {
} = require('../helpers')
const { FakeCiVisIntake } = require('../ci-visibility-intake')
const webAppServer = require('../ci-visibility/web-app-server')
const { TEST_STATUS, TEST_SOURCE_START } = require('../../packages/dd-trace/src/plugins/util/test')
const { TEST_STATUS, TEST_SOURCE_START, TEST_TYPE } = require('../../packages/dd-trace/src/plugins/util/test')

// TODO: remove when 2.x support is removed.
// This is done because from playwright@>=1.22.0 node 12 is not supported
Expand Down Expand Up @@ -73,7 +73,8 @@ versions.forEach((version) => {
assert.equal(testSessionEvent.content.meta[TEST_STATUS], 'fail')
assert.include(testModuleEvent.content.resource, 'test_module.playwright test')
assert.equal(testModuleEvent.content.meta[TEST_STATUS], 'fail')

assert.equal(testSessionEvent.content.meta[TEST_TYPE], 'browser')
assert.equal(testModuleEvent.content.meta[TEST_TYPE], 'browser')
assert.includeMembers(testSuiteEvents.map(suite => suite.content.resource), [
'test_suite.todo-list-page-test.js',
'test_suite.landing-page-test.js',
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dd-trace",
"version": "3.27.0",
"version": "3.28.0",
"description": "Datadog APM tracing client for JavaScript",
"main": "index.js",
"typings": "index.d.ts",
Expand Down Expand Up @@ -70,7 +70,7 @@
"@datadog/native-iast-rewriter": "2.0.1",
"@datadog/native-iast-taint-tracking": "^1.5.0",
"@datadog/native-metrics": "^2.0.0",
"@datadog/pprof": "2.2.3",
"@datadog/pprof": "3.0.0",
"@datadog/sketches-js": "^2.1.0",
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/core": "^1.14.0",
Expand All @@ -94,7 +94,7 @@
"node-abort-controller": "^3.0.1",
"opentracing": ">=0.12.1",
"path-to-regexp": "^0.1.2",
"protobufjs": "^7.1.2",
"protobufjs": "^7.2.4",
"retry": "^0.10.1",
"semver": "^7.3.8"
},
Expand Down
7 changes: 5 additions & 2 deletions packages/datadog-instrumentations/src/cucumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const patched = new WeakSet()

let pickleByFile = {}
const pickleResultByFile = {}
let isSuitesSkipped = false

function getSuiteStatusFromTestStatuses (testStatuses) {
if (testStatuses.some(status => status === 'fail')) {
Expand Down Expand Up @@ -264,7 +265,9 @@ addHook({
const { err, skippableSuites } = await skippableSuitesPromise

if (!err) {
this.pickleIds = getPicklesToRun(this, skippableSuites)
const newPickleIds = getPicklesToRun(this, skippableSuites)
isSuitesSkipped = newPickleIds.length !== this.pickleIds.length
this.pickleIds = newPickleIds
}

pickleByFile = getPickleByFile(this)
Expand Down Expand Up @@ -292,7 +295,7 @@ addHook({
asyncResource.runInAsyncScope(() => {
sessionFinishCh.publish({
status: success ? 'pass' : 'fail',
isSuitesSkipped: skippableSuites ? !!skippableSuites.length : false,
isSuitesSkipped,
testCodeCoverageLinesTotal
})
})
Expand Down
Loading