Skip to content

Commit 2e8ae20

Browse files
authored
Merge branch 'master' into nicholas.hulston/dynamodb-span-pointers
2 parents 94a2c72 + b04ced4 commit 2e8ae20

25 files changed

+481
-232
lines changed

Diff for: integration-tests/ci-visibility/playwright-tests/landing-page-test.js

+29-24
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,34 @@ test.beforeEach(async ({ page }) => {
44
await page.goto(process.env.PW_BASE_URL)
55
})
66

7-
test.describe('playwright', () => {
8-
test('should work with passing tests', async ({ page }) => {
9-
await expect(page.locator('.hello-world')).toHaveText([
10-
'Hello World'
11-
])
12-
})
13-
test.skip('should work with skipped tests', async ({ page }) => {
14-
await expect(page.locator('.hello-world')).toHaveText([
15-
'Hello World'
16-
])
17-
})
18-
test.fixme('should work with fixme', async ({ page }) => {
19-
await expect(page.locator('.hello-world')).toHaveText([
20-
'Hello Warld'
21-
])
22-
})
23-
test('should work with annotated tests', async ({ page }) => {
24-
test.info().annotations.push({ type: 'DD_TAGS[test.memory.usage]', description: 'low' })
25-
test.info().annotations.push({ type: 'DD_TAGS[test.memory.allocations]', description: 16 })
26-
// this is malformed and should be ignored
27-
test.info().annotations.push({ type: 'DD_TAGS[test.invalid', description: 'high' })
28-
await expect(page.locator('.hello-world')).toHaveText([
29-
'Hello World'
30-
])
7+
test.describe('highest-level-describe', () => {
8+
test.describe(' leading and trailing spaces ', () => {
9+
// even empty describe blocks should be allowed
10+
test.describe(' ', () => {
11+
test('should work with passing tests', async ({ page }) => {
12+
await expect(page.locator('.hello-world')).toHaveText([
13+
'Hello World'
14+
])
15+
})
16+
test.skip('should work with skipped tests', async ({ page }) => {
17+
await expect(page.locator('.hello-world')).toHaveText([
18+
'Hello World'
19+
])
20+
})
21+
test.fixme('should work with fixme', async ({ page }) => {
22+
await expect(page.locator('.hello-world')).toHaveText([
23+
'Hello Warld'
24+
])
25+
})
26+
test('should work with annotated tests', async ({ page }) => {
27+
test.info().annotations.push({ type: 'DD_TAGS[test.memory.usage]', description: 'low' })
28+
test.info().annotations.push({ type: 'DD_TAGS[test.memory.allocations]', description: 16 })
29+
// this is malformed and should be ignored
30+
test.info().annotations.push({ type: 'DD_TAGS[test.invalid', description: 'high' })
31+
await expect(page.locator('.hello-world')).toHaveText([
32+
'Hello World'
33+
])
34+
})
35+
})
3136
})
3237
})

Diff for: integration-tests/playwright/playwright.spec.js

+35-30
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,15 @@ versions.forEach((version) => {
123123
})
124124

125125
assert.includeMembers(testEvents.map(test => test.content.resource), [
126-
'landing-page-test.js.should work with passing tests',
127-
'landing-page-test.js.should work with skipped tests',
128-
'landing-page-test.js.should work with fixme',
129-
'landing-page-test.js.should work with annotated tests',
130-
'todo-list-page-test.js.should work with failing tests',
126+
'landing-page-test.js.highest-level-describe' +
127+
' leading and trailing spaces should work with passing tests',
128+
'landing-page-test.js.highest-level-describe' +
129+
' leading and trailing spaces should work with skipped tests',
130+
'landing-page-test.js.highest-level-describe' +
131+
' leading and trailing spaces should work with fixme',
132+
'landing-page-test.js.highest-level-describe' +
133+
' leading and trailing spaces should work with annotated tests',
134+
'todo-list-page-test.js.playwright should work with failing tests',
131135
'todo-list-page-test.js.should work with fixme root'
132136
])
133137

@@ -155,7 +159,7 @@ versions.forEach((version) => {
155159
assert.property(stepEvent.content.meta, 'playwright.step')
156160
})
157161
const annotatedTest = testEvents.find(test =>
158-
test.content.resource === 'landing-page-test.js.should work with annotated tests'
162+
test.content.resource.endsWith('should work with annotated tests')
159163
)
160164

161165
assert.propertyVal(annotatedTest.content.meta, 'test.memory.usage', 'low')
@@ -187,8 +191,8 @@ versions.forEach((version) => {
187191
const events = payloads.flatMap(({ payload }) => payload.events)
188192
const testEvents = events.filter(event => event.type === 'test')
189193
assert.includeMembers(testEvents.map(test => test.content.resource), [
190-
'playwright-tests-ts/one-test.js.should work with passing tests',
191-
'playwright-tests-ts/one-test.js.should work with skipped tests'
194+
'playwright-tests-ts/one-test.js.playwright should work with passing tests',
195+
'playwright-tests-ts/one-test.js.playwright should work with skipped tests'
192196
])
193197
assert.include(testOutput, '1 passed')
194198
assert.include(testOutput, '1 skipped')
@@ -263,16 +267,17 @@ versions.forEach((version) => {
263267
{
264268
playwright: {
265269
'landing-page-test.js': [
266-
// 'should work with passing tests', // it will be considered new
267-
'should work with skipped tests',
268-
'should work with fixme',
269-
'should work with annotated tests'
270+
// it will be considered new
271+
// 'highest-level-describe leading and trailing spaces should work with passing tests',
272+
'highest-level-describe leading and trailing spaces should work with skipped tests',
273+
'highest-level-describe leading and trailing spaces should work with fixme',
274+
'highest-level-describe leading and trailing spaces should work with annotated tests'
270275
],
271276
'skipped-suite-test.js': [
272277
'should work with fixme root'
273278
],
274279
'todo-list-page-test.js': [
275-
'should work with failing tests',
280+
'playwright should work with failing tests',
276281
'should work with fixme root'
277282
]
278283
}
@@ -288,8 +293,7 @@ versions.forEach((version) => {
288293

289294
const tests = events.filter(event => event.type === 'test').map(event => event.content)
290295
const newTests = tests.filter(test =>
291-
test.resource ===
292-
'landing-page-test.js.should work with passing tests'
296+
test.resource.endsWith('should work with passing tests')
293297
)
294298
newTests.forEach(test => {
295299
assert.propertyVal(test.meta, TEST_IS_NEW, 'true')
@@ -337,16 +341,17 @@ versions.forEach((version) => {
337341
{
338342
playwright: {
339343
'landing-page-test.js': [
340-
// 'should work with passing tests', // it will be considered new
341-
'should work with skipped tests',
342-
'should work with fixme',
343-
'should work with annotated tests'
344+
// it will be considered new
345+
// 'highest-level-describe leading and trailing spaces should work with passing tests',
346+
'highest-level-describe leading and trailing spaces should work with skipped tests',
347+
'highest-level-describe leading and trailing spaces should work with fixme',
348+
'highest-level-describe leading and trailing spaces should work with annotated tests'
344349
],
345350
'skipped-suite-test.js': [
346351
'should work with fixme root'
347352
],
348353
'todo-list-page-test.js': [
349-
'should work with failing tests',
354+
'playwright should work with failing tests',
350355
'should work with fixme root'
351356
]
352357
}
@@ -359,8 +364,7 @@ versions.forEach((version) => {
359364
const tests = events.filter(event => event.type === 'test').map(event => event.content)
360365

361366
const newTests = tests.filter(test =>
362-
test.resource ===
363-
'landing-page-test.js.should work with passing tests'
367+
test.resource.endsWith('should work with passing tests')
364368
)
365369
newTests.forEach(test => {
366370
assert.notProperty(test.meta, TEST_IS_NEW)
@@ -406,16 +410,18 @@ versions.forEach((version) => {
406410
{
407411
playwright: {
408412
'landing-page-test.js': [
409-
'should work with passing tests',
410-
// 'should work with skipped tests', // new but not retried because it's skipped
411-
// 'should work with fixme', // new but not retried because it's skipped
412-
'should work with annotated tests'
413+
'highest-level-describe leading and trailing spaces should work with passing tests',
414+
// new but not retried because it's skipped
415+
// 'highest-level-describe leading and trailing spaces should work with skipped tests',
416+
// new but not retried because it's skipped
417+
// 'highest-level-describe leading and trailing spaces should work with fixme',
418+
'highest-level-describe leading and trailing spaces should work with annotated tests'
413419
],
414420
'skipped-suite-test.js': [
415421
'should work with fixme root'
416422
],
417423
'todo-list-page-test.js': [
418-
'should work with failing tests',
424+
'playwright should work with failing tests',
419425
'should work with fixme root'
420426
]
421427
}
@@ -428,9 +434,8 @@ versions.forEach((version) => {
428434
const tests = events.filter(event => event.type === 'test').map(event => event.content)
429435

430436
const newTests = tests.filter(test =>
431-
test.resource ===
432-
'landing-page-test.js.should work with skipped tests' ||
433-
test.resource === 'landing-page-test.js.should work with fixme'
437+
test.resource.endsWith('should work with skipped tests') ||
438+
test.resource.endsWith('should work with fixme')
434439
)
435440
// no retries
436441
assert.equal(newTests.length, 2)

Diff for: packages/datadog-instrumentations/src/express.js

+38-4
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ function wrapResponseRender (render) {
5959

6060
addHook({ name: 'express', versions: ['>=4'] }, express => {
6161
shimmer.wrap(express.application, 'handle', wrapHandle)
62-
shimmer.wrap(express.Router, 'use', wrapRouterMethod)
63-
shimmer.wrap(express.Router, 'route', wrapRouterMethod)
6462

6563
shimmer.wrap(express.response, 'json', wrapResponseJson)
6664
shimmer.wrap(express.response, 'jsonp', wrapResponseJson)
@@ -69,6 +67,20 @@ addHook({ name: 'express', versions: ['>=4'] }, express => {
6967
return express
7068
})
7169

70+
addHook({ name: 'express', versions: ['4'] }, express => {
71+
shimmer.wrap(express.Router, 'use', wrapRouterMethod)
72+
shimmer.wrap(express.Router, 'route', wrapRouterMethod)
73+
74+
return express
75+
})
76+
77+
addHook({ name: 'express', versions: ['>=5.0.0'] }, express => {
78+
shimmer.wrap(express.Router.prototype, 'use', wrapRouterMethod)
79+
shimmer.wrap(express.Router.prototype, 'route', wrapRouterMethod)
80+
81+
return express
82+
})
83+
7284
const queryParserReadCh = channel('datadog:query:read:finish')
7385

7486
function publishQueryParsedAndNext (req, res, next) {
@@ -88,7 +100,7 @@ function publishQueryParsedAndNext (req, res, next) {
88100

89101
addHook({
90102
name: 'express',
91-
versions: ['>=4'],
103+
versions: ['4'],
92104
file: 'lib/middleware/query.js'
93105
}, query => {
94106
return shimmer.wrapFunction(query, query => function () {
@@ -129,7 +141,29 @@ addHook({ name: 'express', versions: ['>=4.0.0 <4.3.0'] }, express => {
129141
return express
130142
})
131143

132-
addHook({ name: 'express', versions: ['>=4.3.0'] }, express => {
144+
addHook({ name: 'express', versions: ['>=4.3.0 <5.0.0'] }, express => {
133145
shimmer.wrap(express.Router, 'process_params', wrapProcessParamsMethod(2))
134146
return express
135147
})
148+
149+
const queryReadCh = channel('datadog:express:query:finish')
150+
151+
addHook({ name: 'express', file: ['lib/request.js'], versions: ['>=5.0.0'] }, request => {
152+
const requestDescriptor = Object.getOwnPropertyDescriptor(request, 'query')
153+
154+
shimmer.wrap(requestDescriptor, 'get', function (originalGet) {
155+
return function wrappedGet () {
156+
const query = originalGet.apply(this, arguments)
157+
158+
if (queryReadCh.hasSubscribers && query) {
159+
queryReadCh.publish({ query })
160+
}
161+
162+
return query
163+
}
164+
})
165+
166+
Object.defineProperty(request, 'query', requestDescriptor)
167+
168+
return request
169+
})

Diff for: packages/datadog-instrumentations/src/helpers/hooks.js

-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ module.exports = {
111111
protobufjs: () => require('../protobufjs'),
112112
pug: () => require('../pug'),
113113
q: () => require('../q'),
114-
qs: () => require('../qs'),
115114
redis: () => require('../redis'),
116115
restify: () => require('../restify'),
117116
rhea: () => require('../rhea'),

Diff for: packages/datadog-instrumentations/src/playwright.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function isNewTest (test) {
4747
const testSuite = getTestSuitePath(test._requireFile, rootDir)
4848
const testsForSuite = knownTests?.playwright?.[testSuite] || []
4949

50-
return !testsForSuite.includes(test.title)
50+
return !testsForSuite.includes(getTestFullname(test))
5151
}
5252

5353
function getSuiteType (test, type) {
@@ -224,10 +224,21 @@ function testWillRetry (test, testStatus) {
224224
return testStatus === 'fail' && test.results.length <= test.retries
225225
}
226226

227+
function getTestFullname (test) {
228+
let parent = test.parent
229+
const names = [test.title]
230+
while (parent?._type === 'describe' || parent?._isDescribe) {
231+
if (parent.title) {
232+
names.unshift(parent.title)
233+
}
234+
parent = parent.parent
235+
}
236+
return names.join(' ')
237+
}
238+
227239
function testBeginHandler (test, browserName) {
228240
const {
229241
_requireFile: testSuiteAbsolutePath,
230-
title: testName,
231242
_type,
232243
location: {
233244
line: testSourceLine
@@ -238,6 +249,8 @@ function testBeginHandler (test, browserName) {
238249
return
239250
}
240251

252+
const testName = getTestFullname(test)
253+
241254
const isNewTestSuite = !startedSuites.includes(testSuiteAbsolutePath)
242255

243256
if (isNewTestSuite) {

Diff for: packages/datadog-instrumentations/src/qs.js

-24
This file was deleted.

0 commit comments

Comments
 (0)