Skip to content

Commit

Permalink
test: added span length assertions for mysql tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aryamohanan committed Dec 3, 2024
1 parent 5491461 commit e38a15a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/collector/test/tracing/database/mysql/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function registerSuite(agentControls, driverMode, useExecute) {
env.USE_EXECUTE = 'true';
}

test(env, agentControls);
test(env, agentControls, driverMode);
});

describe('suppressed', function () {
Expand Down Expand Up @@ -102,7 +102,7 @@ function registerSuite(agentControls, driverMode, useExecute) {
});
}

function test(env, agentControls) {
function test(env, agentControls, driverMode) {
let controls;

before(async () => {
Expand Down Expand Up @@ -139,6 +139,11 @@ function test(env, agentControls) {
.then(() =>
testUtils.retry(() =>
agentControls.getSpans().then(spans => {
// 1 x mysql
// 1 x httpserver
// 1 x otel fs(not included in mysql2/promise)
const expectedSpanCount = driverMode === 'mysql2/promises' ? 2 : 3;
expect(spans.length).to.equal(expectedSpanCount);
const entrySpan = testUtils.expectAtLeastOneMatching(spans, [
span => expect(span.n).to.equal('node.http.server'),
span => expect(span.f.e).to.equal(String(controls.getPid())),
Expand Down Expand Up @@ -181,6 +186,9 @@ function test(env, agentControls) {

return testUtils.retry(() =>
agentControls.getSpans().then(spans => {
// 2 x mysql
// 2 x httpserver
expect(spans.length).to.equal(4);
const postEntrySpan = testUtils.expectAtLeastOneMatching(spans, [
span => expect(span.n).to.equal('node.http.server'),
span => expect(span.f.e).to.equal(String(controls.getPid())),
Expand Down Expand Up @@ -245,6 +253,12 @@ function test(env, agentControls) {

return testUtils.retry(() =>
agentControls.getSpans().then(spans => {
// 1 x mysql
// 1 x httpserver
// 1 x httpclient
// 1 x otel fs(included in mysql2/promise)
const expectedSpanCount = driverMode === 'mysql2/promises' ? 4 : 3;
expect(spans.length).to.equal(expectedSpanCount);
const postEntrySpan = testUtils.expectAtLeastOneMatching(spans, [
span => expect(span.n).to.equal('node.http.server'),
span => expect(span.f.e).to.equal(String(controls.getPid())),
Expand Down

0 comments on commit e38a15a

Please sign in to comment.