Skip to content

Commit

Permalink
[DI] DRY up integration test code (#4685)
Browse files Browse the repository at this point in the history
  • Loading branch information
watson authored and juan-fernandez committed Sep 30, 2024
1 parent cf05fde commit b68a8b3
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions integration-tests/debugger/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ describe('Dynamic Instrumentation', function () {
})

beforeEach(async function () {
const probeId = randomUUID()
rcConfig = {
product: 'LIVE_DEBUGGING',
id: `logProbe_${probeId}`,
config: generateProbeConfig({ id: probeId })
}
rcConfig = generateRemoteConfig()
appPort = await getPort()
agent = await new FakeAgent().start()
proc = await spawnProc(appFile, {
Expand Down Expand Up @@ -385,18 +380,12 @@ describe('Dynamic Instrumentation', function () {

describe('race conditions', () => {
it('should remove the last breakpoint completely before trying to add a new one', (done) => {
const probeId1 = rcConfig.config.id
const probeId2 = randomUUID()
const rcConfig2 = {
product: 'LIVE_DEBUGGING',
id: `logProbe_${probeId2}`,
config: generateProbeConfig({ id: probeId2 })
}
const rcConfig2 = generateRemoteConfig()

agent.on('debugger-diagnostics', ({ payload: { debugger: { diagnostics: { status, probeId } } } }) => {
if (status !== 'INSTALLED') return

if (probeId === probeId1) {
if (probeId === rcConfig.config.id) {
// First INSTALLED payload: Try to trigger the race condition.
agent.removeRemoteConfig(rcConfig.id)
agent.addRemoteConfig(rcConfig2)
Expand Down Expand Up @@ -433,6 +422,15 @@ describe('Dynamic Instrumentation', function () {
})
})

function generateRemoteConfig (overrides = {}) {
overrides.id = overrides.id || randomUUID()
return {
product: 'LIVE_DEBUGGING',
id: `logProbe_${overrides.id}`,
config: generateProbeConfig(overrides)
}
}

function generateProbeConfig (overrides) {
return {
id: randomUUID(),
Expand Down

0 comments on commit b68a8b3

Please sign in to comment.