Skip to content

Commit

Permalink
Merge branch 'main' into api-dep
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan authored May 11, 2022
2 parents 9b58ab0 + d39c642 commit 4a245d6
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ jobs:
RUN_MSSQL_TESTS: 1
RUN_POSTGRES_TESTS: 1
RUN_REDIS_TESTS: 1
RUN_RABBIT_TESTS: 1
CASSANDRA_HOST: localhost
MONGODB_DB: opentelemetry-tests
MONGODB_HOST: 127.0.0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
SemanticAttributes,
} from '@opentelemetry/semantic-conventions';
import { context, SpanKind } from '@opentelemetry/api';
import { asyncConfirmSend, asyncConsume } from './utils';
import { asyncConfirmSend, asyncConsume, shouldTest } from './utils';
import {
censoredUrl,
rabbitMqUrl,
Expand All @@ -42,14 +42,22 @@ const queueName = 'queue-name-from-unittest';

describe('amqplib instrumentation callback model', () => {
let conn: amqpCallback.Connection;
before(done => {
amqpCallback.connect(rabbitMqUrl, (err, connection) => {
conn = connection;
done(err);
});
before(function (done) {
if (!shouldTest) {
this.skip();
} else {
amqpCallback.connect(rabbitMqUrl, (err, connection) => {
conn = connection;
done(err);
});
}
});
after(done => {
conn.close(() => done());
if (!shouldTest) {
done();
} else {
conn.close(() => done());
}
});

describe('channel', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
import 'mocha';
import * as expect from 'expect';
import { shouldTest } from './utils';
import {
censoredUrl,
rabbitMqUrl,
Expand All @@ -34,6 +35,12 @@ import * as amqp from 'amqplib';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';

describe('amqplib instrumentation connection', () => {
before(function () {
if (!shouldTest) {
this.skip();
}
});

describe('connect with url object', () => {
it('should extract connection attributes form url options', async function () {
const testName = this.test!.title;
Expand Down
13 changes: 10 additions & 3 deletions plugins/node/instrumentation-amqplib/test/amqplib-promise.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
} from '@opentelemetry/semantic-conventions';
import { Span, SpanKind, SpanStatusCode } from '@opentelemetry/api';
import { asyncConfirmPublish, asyncConfirmSend, asyncConsume } from './utils';
import { shouldTest } from './utils';
import {
censoredUrl,
rabbitMqUrl,
Expand All @@ -60,11 +61,17 @@ const CHANNEL_CLOSED_IN_TEST = Symbol(

describe('amqplib instrumentation promise model', () => {
let conn: amqp.Connection;
before(async () => {
conn = await amqp.connect(rabbitMqUrl);
before(async function () {
if (!shouldTest) {
this.skip();
} else {
conn = await amqp.connect(rabbitMqUrl);
}
});
after(async () => {
await conn.close();
if (shouldTest) {
await conn.close();
}
});

let endHookSpy: SinonSpy;
Expand Down
13 changes: 10 additions & 3 deletions plugins/node/instrumentation-amqplib/test/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,23 @@ import {
} from '../src/utils';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import * as amqp from 'amqplib';
import { shouldTest } from './utils';
import { rabbitMqUrl } from './config';

describe('utils', () => {
describe('getConnectionAttributesFromServer', () => {
let conn: amqp.Connection;
before(async () => {
conn = await amqp.connect(rabbitMqUrl);
before(async function () {
if (!shouldTest) {
this.skip();
} else {
conn = await amqp.connect(rabbitMqUrl);
}
});
after(async () => {
await conn.close();
if (shouldTest) {
await conn.close();
}
});

it('messaging system attribute', () => {
Expand Down
2 changes: 2 additions & 0 deletions plugins/node/instrumentation-amqplib/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,5 @@ export const asyncConsume = (
)
);
};

export const shouldTest = !!process.env.RUN_RABBIT_TESTS;
6 changes: 3 additions & 3 deletions plugins/node/opentelemetry-instrumentation-aws-sdk/.tav.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
"aws-sdk":
# there are so many version to test, it can take forever.
# we will just sample few of them
versions: ">=2.1004.0 || 2.1002.0 || 2.950.0 || 2.903.0 || 2.880.0 || 2.706.0 || 2.608.0 || 2.518.0 || 2.422.0 || 2.308.0"
versions: ">=2.1130.0 || 2.1048.0 || 2.1012.0 || 2.647.0 || 2.308.0"
commands:
- npm run test
# Fix missing `contrib-test-utils` package
pretest: npm run --prefix ../../../ lerna:link

"@aws-sdk/client-s3":
versions: ">=3.33.0 || 3.27.0 || 3.18.0 || 3.6.1 || 3.3.0"
versions: ">=3.83.0 || 3.58.0 || 3.54.0 || 3.6.1"
commands:
- npm run test
# Fix missing `contrib-test-utils` package
pretest: npm run --prefix ../../../ lerna:link

"@aws-sdk/client-sqs":
versions: ">=3.33.0 || 3.24.0 || 3.19.0 || 3.1.0"
versions: ">=3.85.0 || 3.82.0 || 3.58.0 || 3.54.0 || 3.43.0 || 3.24.0"
commands:
- npm run test
# Fix missing `contrib-test-utils` package
Expand Down

0 comments on commit 4a245d6

Please sign in to comment.