@@ -4,7 +4,7 @@ const os = require('os')
4
4
5
5
const { assert } = require ( 'chai' )
6
6
const { pollInterval, setup } = require ( './utils' )
7
- const { assertObjectContains, assertUUID, failOnException } = require ( '../helpers' )
7
+ const { assertObjectContains, assertUUID } = require ( '../helpers' )
8
8
const { ACKNOWLEDGED , ERROR } = require ( '../../packages/dd-trace/src/appsec/remote_config/apply_states' )
9
9
const { version } = require ( '../../package.json' )
10
10
@@ -35,17 +35,17 @@ describe('Dynamic Instrumentation', function () {
35
35
debugger : { diagnostics : { probeId, probeVersion : 0 , status : 'EMITTING' } }
36
36
} ]
37
37
38
- t . agent . on ( 'remote-config-ack-update' , failOnException ( done , ( id , version , state , error ) => {
38
+ t . agent . on ( 'remote-config-ack-update' , ( id , version , state , error ) => {
39
39
assert . strictEqual ( id , t . rcConfig . id )
40
40
assert . strictEqual ( version , 1 )
41
41
assert . strictEqual ( state , ACKNOWLEDGED )
42
42
assert . notOk ( error ) // falsy check since error will be an empty string, but that's an implementation detail
43
43
44
44
receivedAckUpdate = true
45
45
endIfDone ( )
46
- } ) )
46
+ } )
47
47
48
- t . agent . on ( 'debugger-diagnostics' , failOnException ( done , ( { payload } ) => {
48
+ t . agent . on ( 'debugger-diagnostics' , ( { payload } ) => {
49
49
const expected = expectedPayloads . shift ( )
50
50
assertObjectContains ( payload , expected )
51
51
assertUUID ( payload . debugger . diagnostics . runtimeId )
@@ -60,7 +60,7 @@ describe('Dynamic Instrumentation', function () {
60
60
} else {
61
61
endIfDone ( )
62
62
}
63
- } ) )
63
+ } )
64
64
65
65
t . agent . addRemoteConfig ( t . rcConfig )
66
66
@@ -97,22 +97,22 @@ describe('Dynamic Instrumentation', function () {
97
97
( ) => { }
98
98
]
99
99
100
- t . agent . on ( 'remote-config-ack-update' , failOnException ( done , ( id , version , state , error ) => {
100
+ t . agent . on ( 'remote-config-ack-update' , ( id , version , state , error ) => {
101
101
assert . strictEqual ( id , t . rcConfig . id )
102
102
assert . strictEqual ( version , ++ receivedAckUpdates )
103
103
assert . strictEqual ( state , ACKNOWLEDGED )
104
104
assert . notOk ( error ) // falsy check since error will be an empty string, but that's an implementation detail
105
105
106
106
endIfDone ( )
107
- } ) )
107
+ } )
108
108
109
- t . agent . on ( 'debugger-diagnostics' , failOnException ( done , ( { payload } ) => {
109
+ t . agent . on ( 'debugger-diagnostics' , ( { payload } ) => {
110
110
const expected = expectedPayloads . shift ( )
111
111
assertObjectContains ( payload , expected )
112
112
assertUUID ( payload . debugger . diagnostics . runtimeId )
113
113
if ( payload . debugger . diagnostics . status === 'INSTALLED' ) triggers . shift ( ) ( )
114
114
endIfDone ( )
115
- } ) )
115
+ } )
116
116
117
117
t . agent . addRemoteConfig ( t . rcConfig )
118
118
@@ -135,17 +135,17 @@ describe('Dynamic Instrumentation', function () {
135
135
debugger : { diagnostics : { probeId, probeVersion : 0 , status : 'INSTALLED' } }
136
136
} ]
137
137
138
- t . agent . on ( 'remote-config-ack-update' , failOnException ( done , ( id , version , state , error ) => {
138
+ t . agent . on ( 'remote-config-ack-update' , ( id , version , state , error ) => {
139
139
assert . strictEqual ( id , t . rcConfig . id )
140
140
assert . strictEqual ( version , 1 )
141
141
assert . strictEqual ( state , ACKNOWLEDGED )
142
142
assert . notOk ( error ) // falsy check since error will be an empty string, but that's an implementation detail
143
143
144
144
receivedAckUpdate = true
145
145
endIfDone ( )
146
- } ) )
146
+ } )
147
147
148
- t . agent . on ( 'debugger-diagnostics' , failOnException ( done , ( { payload } ) => {
148
+ t . agent . on ( 'debugger-diagnostics' , ( { payload } ) => {
149
149
const expected = expectedPayloads . shift ( )
150
150
assertObjectContains ( payload , expected )
151
151
assertUUID ( payload . debugger . diagnostics . runtimeId )
@@ -158,7 +158,7 @@ describe('Dynamic Instrumentation', function () {
158
158
endIfDone ( )
159
159
} , pollInterval * 2 * 1000 ) // wait twice as long as the RC poll interval
160
160
}
161
- } ) )
161
+ } )
162
162
163
163
t . agent . addRemoteConfig ( t . rcConfig )
164
164
@@ -183,15 +183,15 @@ describe('Dynamic Instrumentation', function () {
183
183
it ( title , function ( done ) {
184
184
let receivedAckUpdate = false
185
185
186
- t . agent . on ( 'remote-config-ack-update' , failOnException ( done , ( id , version , state , error ) => {
186
+ t . agent . on ( 'remote-config-ack-update' , ( id , version , state , error ) => {
187
187
assert . strictEqual ( id , `logProbe_${ config . id } ` )
188
188
assert . strictEqual ( version , 1 )
189
189
assert . strictEqual ( state , ERROR )
190
190
assert . strictEqual ( error . slice ( 0 , 6 ) , 'Error:' )
191
191
192
192
receivedAckUpdate = true
193
193
endIfDone ( )
194
- } ) )
194
+ } )
195
195
196
196
const probeId = config . id
197
197
const expectedPayloads = [ {
@@ -204,7 +204,7 @@ describe('Dynamic Instrumentation', function () {
204
204
debugger : { diagnostics : customErrorDiagnosticsObj ?? { probeId, probeVersion : 0 , status : 'ERROR' } }
205
205
} ]
206
206
207
- t . agent . on ( 'debugger-diagnostics' , failOnException ( done , ( { payload } ) => {
207
+ t . agent . on ( 'debugger-diagnostics' , ( { payload } ) => {
208
208
const expected = expectedPayloads . shift ( )
209
209
assertObjectContains ( payload , expected )
210
210
const { diagnostics } = payload . debugger
@@ -218,7 +218,7 @@ describe('Dynamic Instrumentation', function () {
218
218
}
219
219
220
220
endIfDone ( )
221
- } ) )
221
+ } )
222
222
223
223
t . agent . addRemoteConfig ( {
224
224
product : 'LIVE_DEBUGGING' ,
@@ -237,7 +237,7 @@ describe('Dynamic Instrumentation', function () {
237
237
it ( 'should capture and send expected payload when a log line probe is triggered' , function ( done ) {
238
238
t . triggerBreakpoint ( )
239
239
240
- t . agent . on ( 'debugger-input' , failOnException ( done , ( { payload } ) => {
240
+ t . agent . on ( 'debugger-input' , ( { payload } ) => {
241
241
const expected = {
242
242
ddsource : 'dd_debugger' ,
243
243
hostname : os . hostname ( ) ,
@@ -284,7 +284,7 @@ describe('Dynamic Instrumentation', function () {
284
284
assert . strictEqual ( topFrame . columnNumber , 3 )
285
285
286
286
done ( )
287
- } ) )
287
+ } )
288
288
289
289
t . agent . addRemoteConfig ( t . rcConfig )
290
290
} )
@@ -307,31 +307,31 @@ describe('Dynamic Instrumentation', function () {
307
307
if ( payload . debugger . diagnostics . status === 'INSTALLED' ) triggers . shift ( ) ( ) . catch ( done )
308
308
} )
309
309
310
- t . agent . on ( 'debugger-input' , failOnException ( done , ( { payload } ) => {
310
+ t . agent . on ( 'debugger-input' , ( { payload } ) => {
311
311
assert . strictEqual ( payload . message , expectedMessages . shift ( ) )
312
312
if ( expectedMessages . length === 0 ) done ( )
313
- } ) )
313
+ } )
314
314
315
315
t . agent . addRemoteConfig ( t . rcConfig )
316
316
} )
317
317
318
318
it ( 'should not trigger if probe is deleted' , function ( done ) {
319
- t . agent . on ( 'debugger-diagnostics' , failOnException ( done , ( { payload } ) => {
319
+ t . agent . on ( 'debugger-diagnostics' , ( { payload } ) => {
320
320
if ( payload . debugger . diagnostics . status === 'INSTALLED' ) {
321
- t . agent . once ( 'remote-confg-responded' , failOnException ( done , async ( ) => {
321
+ t . agent . once ( 'remote-confg-responded' , async ( ) => {
322
322
await t . axios . get ( '/foo' )
323
323
// We want to wait enough time to see if the client triggers on the breakpoint so that the test can fail
324
324
// if it does, but not so long that the test times out.
325
325
// TODO: Is there some signal we can use instead of a timer?
326
326
setTimeout ( done , pollInterval * 2 * 1000 ) // wait twice as long as the RC poll interval
327
- } ) )
327
+ } )
328
328
329
329
t . agent . removeRemoteConfig ( t . rcConfig . id )
330
330
}
331
- } ) )
331
+ } )
332
332
333
333
t . agent . on ( 'debugger-input' , ( ) => {
334
- done ( new Error ( 'should not capture anything when the probe is deleted' ) )
334
+ assert . fail ( 'should not capture anything when the probe is deleted' )
335
335
} )
336
336
337
337
t . agent . addRemoteConfig ( t . rcConfig )
@@ -342,8 +342,7 @@ describe('Dynamic Instrumentation', function () {
342
342
it ( 'should remove the last breakpoint completely before trying to add a new one' , function ( done ) {
343
343
const rcConfig2 = t . generateRemoteConfig ( )
344
344
345
- t . agent . on ( 'debugger-diagnostics' , failOnException ( done , ( { payload } ) => {
346
- const { status, probeId } = payload . debugger . diagnostics
345
+ t . agent . on ( 'debugger-diagnostics' , ( { payload : { debugger : { diagnostics : { status, probeId } } } } ) => {
347
346
if ( status !== 'INSTALLED' ) return
348
347
349
348
if ( probeId === t . rcConfig . config . id ) {
@@ -376,7 +375,7 @@ describe('Dynamic Instrumentation', function () {
376
375
if ( ! finished ) done ( err )
377
376
} )
378
377
}
379
- } ) )
378
+ } )
380
379
381
380
t . agent . addRemoteConfig ( t . rcConfig )
382
381
} )
0 commit comments