Skip to content

Commit

Permalink
Merge branch 'master' into khanayan123/implement-consistent-config
Browse files Browse the repository at this point in the history
  • Loading branch information
khanayan123 authored Feb 18, 2025
2 parents ee4392d + 052a833 commit a1e069a
Show file tree
Hide file tree
Showing 78 changed files with 2,517 additions and 414 deletions.
2 changes: 1 addition & 1 deletion .gitlab/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ variables:
tags: ["runner:apm-k8s-tweaked-metal"]
image: $MICROBENCHMARKS_CI_IMAGE
interruptible: true
timeout: 15m
timeout: 20m
script:
- git clone --branch dd-trace-js https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform platform && cd platform
- bp-runner bp-runner.yml --debug
Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/plugin-graphql/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"run": "node index.js",
"run_with_affinity": "bash -c \"taskset -c $CPU_AFFINITY node index.js\"",
"cachegrind": false,
"iterations": 2,
"iterations": 30,
"instructions": true,
"variants": {
"control": {},
Expand Down
4 changes: 2 additions & 2 deletions benchmark/sirun/plugin-graphql/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const Human = new graphql.GraphQLObjectType({
async resolve (obj, args) {
const promises = []

for (let i = 0; i < 100; i++) {
for (let i = 0; i < 20; i++) {
promises.push(await Promise.resolve({}))
}

Expand All @@ -115,7 +115,7 @@ const schema = new graphql.GraphQLSchema({
async resolve (obj, args) {
const promises = []

for (let i = 0; i < 100; i++) {
for (let i = 0; i < 20; i++) {
promises.push(await Promise.resolve({}))
}

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ services:
ports:
- "127.0.0.1:6379:6379"
mongo:
image: circleci/mongo:3.6
image: circleci/mongo:4.4
platform: linux/amd64
ports:
- "127.0.0.1:27017:27017"
Expand Down
3 changes: 2 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ export default [
'**/versions', // This is effectively a node_modules tree.
'**/acmeair-nodejs', // We don't own this.
'**/vendor', // Generally, we didn't author this code.
'integration-tests/debugger/target-app/source-map-support/minify.min.js', // Generated
'integration-tests/debugger/target-app/source-map-support/typescript.js', // Generated
'integration-tests/esbuild/out.js', // Generated
'integration-tests/esbuild/aws-sdk-out.js', // Generated
'packages/dd-trace/src/appsec/blocked_templates.js', // TODO Why is this ignored?
'packages/dd-trace/src/payload-tagging/jsonpath-plus.js' // Vendored
]
},
Expand Down
47 changes: 44 additions & 3 deletions integration-tests/ci-visibility-intake.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,43 @@ const DEFAULT_SETTINGS = {
code_coverage: true,
tests_skipping: true,
itr_enabled: true,
require_git: false,
early_flake_detection: {
enabled: false,
slow_test_retries: {
'5s': 3
}
},
flaky_test_retries_enabled: false,
di_enabled: false,
known_tests_enabled: false,
test_management: {
enabled: false
}
}

const DEFAULT_SUITES_TO_SKIP = []
const DEFAULT_GIT_UPLOAD_STATUS = 200
const DEFAULT_KNOWN_TESTS_UPLOAD_STATUS = 200
const DEFAULT_KNOWN_TESTS_RESPONSE_STATUS = 200
const DEFAULT_INFO_RESPONSE = {
endpoints: ['/evp_proxy/v2', '/debugger/v1/input']
}
const DEFAULT_CORRELATION_ID = '1234'
const DEFAULT_KNOWN_TESTS = ['test-suite1.js.test-name1', 'test-suite2.js.test-name2']

const DEFAULT_QUARANTINED_TESTS = {}
const DEFAULT_QUARANTINED_TESTS_RESPONSE_STATUS = 200

let settings = DEFAULT_SETTINGS
let suitesToSkip = DEFAULT_SUITES_TO_SKIP
let gitUploadStatus = DEFAULT_GIT_UPLOAD_STATUS
let infoResponse = DEFAULT_INFO_RESPONSE
let correlationId = DEFAULT_CORRELATION_ID
let knownTests = DEFAULT_KNOWN_TESTS
let knownTestsStatusCode = DEFAULT_KNOWN_TESTS_UPLOAD_STATUS
let knownTestsStatusCode = DEFAULT_KNOWN_TESTS_RESPONSE_STATUS
let waitingTime = 0
let quarantineResponse = DEFAULT_QUARANTINED_TESTS
let quarantineResponseStatusCode = DEFAULT_QUARANTINED_TESTS_RESPONSE_STATUS

class FakeCiVisIntake extends FakeAgent {
setKnownTestsResponseCode (statusCode) {
Expand Down Expand Up @@ -71,6 +83,14 @@ class FakeCiVisIntake extends FakeAgent {
waitingTime = newWaitingTime
}

setQuarantinedTests (newQuarantinedTests) {
quarantineResponse = newQuarantinedTests
}

setQuarantinedTestsResponseCode (newStatusCode) {
quarantineResponseStatusCode = newStatusCode
}

async start () {
const app = express()
app.use(bodyParser.raw({ limit: Infinity, type: 'application/msgpack' }))
Expand Down Expand Up @@ -219,6 +239,25 @@ class FakeCiVisIntake extends FakeAgent {
})
})

app.post([
'/api/v2/test/libraries/test-management/tests',
'/evp_proxy/:version/api/v2/test/libraries/test-management/tests'
], (req, res) => {
res.setHeader('content-type', 'application/json')
const data = JSON.stringify({
data: {
attributes: {
modules: quarantineResponse
}
}
})
res.status(quarantineResponseStatusCode).send(data)
this.emit('message', {
headers: req.headers,
url: req.url
})
})

return new Promise((resolve, reject) => {
const timeoutObj = setTimeout(() => {
reject(new Error('Intake timed out starting up'))
Expand All @@ -237,8 +276,10 @@ class FakeCiVisIntake extends FakeAgent {
settings = DEFAULT_SETTINGS
suitesToSkip = DEFAULT_SUITES_TO_SKIP
gitUploadStatus = DEFAULT_GIT_UPLOAD_STATUS
knownTestsStatusCode = DEFAULT_KNOWN_TESTS_UPLOAD_STATUS
knownTestsStatusCode = DEFAULT_KNOWN_TESTS_RESPONSE_STATUS
infoResponse = DEFAULT_INFO_RESPONSE
quarantineResponseStatusCode = DEFAULT_QUARANTINED_TESTS_RESPONSE_STATUS
quarantineResponse = DEFAULT_QUARANTINED_TESTS
this.removeAllListeners()
if (this.waitingTimeoutId) {
clearTimeout(this.waitingTimeoutId)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Feature: Quarantine
Scenario: Say quarantine
When the greeter says quarantine
Then I should have heard "quarantine"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const assert = require('assert')
const { When, Then } = require('@cucumber/cucumber')

Then('I should have heard {string}', function (expectedResponse) {
assert.equal(this.whatIHeard, 'fail')
})

When('the greeter says quarantine', function () {
this.whatIHeard = 'quarantine'
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { test, expect } = require('@playwright/test')

test.beforeEach(async ({ page }) => {
await page.goto(process.env.PW_BASE_URL)
})

test.describe('quarantine', () => {
test('should quarantine failed test', async ({ page }) => {
await expect(page.locator('.hello-world')).toHaveText([
'Hello Warld'
])
})
})
11 changes: 11 additions & 0 deletions integration-tests/ci-visibility/quarantine/test-quarantine-1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { expect } = require('chai')

describe('quarantine tests', () => {
it('can quarantine a test', () => {
expect(1 + 2).to.equal(4)
})

it('can pass normally', () => {
expect(1 + 2).to.equal(3)
})
})
11 changes: 11 additions & 0 deletions integration-tests/ci-visibility/quarantine/test-quarantine-2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { expect } = require('chai')

describe('quarantine tests 2', () => {
it('can quarantine a test', () => {
expect(1 + 2).to.equal(3)
})

it('can pass normally', () => {
expect(1 + 2).to.equal(3)
})
})
6 changes: 5 additions & 1 deletion integration-tests/ci-visibility/run-jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ if (process.env.COLLECT_COVERAGE_FROM) {
jest.runCLI(
options,
options.projects
).then(() => {
).then((results) => {
if (process.send) {
process.send('finished')
}
if (process.env.SHOULD_CHECK_RESULTS) {
const exitCode = results.results.success ? 0 : 1
process.exit(exitCode)
}
})
7 changes: 5 additions & 2 deletions integration-tests/ci-visibility/run-mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ if (process.env.TESTS_TO_RUN) {
mocha.addFile(require.resolve('./test/ci-visibility-test.js'))
mocha.addFile(require.resolve('./test/ci-visibility-test-2.js'))
}
mocha.run(() => {
mocha.run((failures) => {
if (process.send) {
process.send('finished')
}
}).on('end', () => {
if (process.env.SHOULD_CHECK_RESULTS && failures > 0) {
process.exit(1)
}
}).on('end', (res) => {
// eslint-disable-next-line
console.log('end event: can add event listeners to mocha')
})
11 changes: 11 additions & 0 deletions integration-tests/ci-visibility/vitest-tests/test-quarantine.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { describe, test, expect } from 'vitest'

describe('quarantine tests', () => {
test('can quarantine a test', () => {
expect(1 + 2).to.equal(4)
})

test('can pass normally', () => {
expect(1 + 2).to.equal(3)
})
})
Loading

0 comments on commit a1e069a

Please sign in to comment.