From 9431f017defb1e3c1dafcac3f7c633f5d4dd3ef1 Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Fri, 13 Dec 2024 17:12:34 +0100 Subject: [PATCH] Fix flaky dns and net timeline event tests (#5011) --- integration-tests/profiler/profiler.spec.js | 30 ++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/integration-tests/profiler/profiler.spec.js b/integration-tests/profiler/profiler.spec.js index 9a963202934..80be4c8fd36 100644 --- a/integration-tests/profiler/profiler.spec.js +++ b/integration-tests/profiler/profiler.spec.js @@ -133,6 +133,7 @@ async function gatherNetworkTimelineEvents (cwd, scriptFilePath, eventType, args const events = [] for (const sample of profile.sample) { let ts, event, host, address, port, name, spanId, localRootSpanId + const unexpectedLabels = [] for (const label of sample.label) { switch (label.key) { case tsKey: ts = label.num; break @@ -143,23 +144,28 @@ async function gatherNetworkTimelineEvents (cwd, scriptFilePath, eventType, args case portKey: port = label.num; break case spanIdKey: spanId = label.str; break case localRootSpanIdKey: localRootSpanId = label.str; break - default: assert.fail(`Unexpected label key ${label.key} ${strings.strings[label.key]} ${encoded}`) + default: unexpectedLabels.push(label.key) } } - // Timestamp must be defined and be between process start and end time - assert.isDefined(ts, encoded) - assert.isTrue(ts <= procEnd, encoded) - assert.isTrue(ts >= procStart, encoded) - if (process.platform !== 'win32') { - assert.isDefined(spanId, encoded) - assert.isDefined(localRootSpanId, encoded) - } else { - assert.isUndefined(spanId, encoded) - assert.isUndefined(localRootSpanId, encoded) - } // Gather only DNS events; ignore sporadic GC events if (event === eventValue) { + // Timestamp must be defined and be between process start and end time + assert.isDefined(ts, encoded) + assert.isTrue(ts <= procEnd, encoded) + assert.isTrue(ts >= procStart, encoded) + if (process.platform !== 'win32') { + assert.isDefined(spanId, encoded) + assert.isDefined(localRootSpanId, encoded) + } else { + assert.isUndefined(spanId, encoded) + assert.isUndefined(localRootSpanId, encoded) + } assert.isDefined(name, encoded) + if (unexpectedLabels.length > 0) { + const labelsStr = JSON.stringify(unexpectedLabels) + const labelsStrStr = unexpectedLabels.map(k => strings.strings[k]).join(',') + assert.fail(`Unexpected labels: ${labelsStr}\n${labelsStrStr}\n${encoded}`) + } // Exactly one of these is defined assert.isTrue(!!address !== !!host, encoded) const ev = { name: strings.strings[name] }