Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky dns and net timeline event tests #5011

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 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,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] }
Expand Down
Loading