From d3f1235d58bab65f0a77dd8b1e132fcede5a4283 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Mon, 16 Sep 2024 11:14:13 +0200 Subject: [PATCH] [DI] DRY up integration test code (#4685) --- integration-tests/debugger/index.spec.js | 26 +++++++++++------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/integration-tests/debugger/index.spec.js b/integration-tests/debugger/index.spec.js index 355427adbf6..4c3f84d8112 100644 --- a/integration-tests/debugger/index.spec.js +++ b/integration-tests/debugger/index.spec.js @@ -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, { @@ -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) @@ -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(),