Skip to content

Commit

Permalink
Fix flaky dns and net timeline event tests
Browse files Browse the repository at this point in the history
  • Loading branch information
szegedi committed Dec 13, 2024
1 parent 25d46fc commit 980d0de
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions integration-tests/profiler/profiler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -143,23 +144,24 @@ 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)
assert.isTrue(unexpectedLabels.length === 0, `Unexpected labels: ${JSON.stringify(unexpectedLabels)}\n${unexpectedLabels.map(k => strings.strings[k]).join(',')}\n${encoded}`)

Check failure on line 164 in integration-tests/profiler/profiler.spec.js

View workflow job for this annotation

GitHub Actions / lint

This line has a length of 180. Maximum allowed is 120
// Exactly one of these is defined
assert.isTrue(!!address !== !!host, encoded)
const ev = { name: strings.strings[name] }
Expand Down

0 comments on commit 980d0de

Please sign in to comment.