Skip to content

Commit 8a52338

Browse files
committed
move testing of redis v2/v3 to 'npm run test-all-versions'; fix tests against earlier redis v4 versions
Also drop unused secondary redis v4 install: "redis-v4": "npm:[email protected]",
1 parent f46e166 commit 8a52338

File tree

5 files changed

+63
-111
lines changed

5 files changed

+63
-111
lines changed

package-lock.json

Lines changed: 49 additions & 99 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/node/opentelemetry-instrumentation-redis/.tav.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ redis:
22
- versions:
33
include: '>=2.6.0 <4'
44
mode: latest-minors
5-
commands: npm run test-v2-v3-run
5+
commands: npm run test-v2-v3
66
- versions:
77
include: '>=4 <5'
88
# "4.6.9" was a bad release that accidentally broke node v14 support.
99
exclude: "4.6.9"
1010
mode: latest-minors
11-
commands: npm run test-v4-run
11+
commands: npm test

plugins/node/opentelemetry-instrumentation-redis/package.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66
"types": "build/src/index.d.ts",
77
"repository": "open-telemetry/opentelemetry-js-contrib",
88
"scripts": {
9-
"test": "npm run test-v2-v3 && npm run test-v4",
10-
"test-v2-v3": "tav redis 3.1.2 npm run test-v2-v3-run",
11-
"test-v4": "tav redis 4.7.1 npm run test-v4-run",
12-
"test-v2-v3-run": "nyc mocha --no-clean --require '@opentelemetry/contrib-test-utils' 'test/v2-v3/*.test.ts'",
13-
"test-v4-run": "nyc mocha --no-clean --require '@opentelemetry/contrib-test-utils' 'test/v4/*.test.ts'",
9+
"test-v2-v3": "nyc mocha --require '@opentelemetry/contrib-test-utils' 'test/v2-v3/*.test.ts'",
10+
"test": "nyc mocha --require '@opentelemetry/contrib-test-utils' 'test/v4/*.test.ts'",
1411
"test:debug": "cross-env RUN_REDIS_TESTS_LOCAL=true mocha --inspect-brk --no-timeouts 'test/**/*.test.ts'",
1512
"test:local": "cross-env RUN_REDIS_TESTS_LOCAL=true npm run test",
1613
"test:docker:run": "docker run --rm -d --name otel-redis -p 63790:6379 redis:alpine",
@@ -62,8 +59,7 @@
6259
"@types/redis": "2.8.32",
6360
"cross-env": "7.0.3",
6461
"nyc": "17.1.0",
65-
"redis": "3.1.2",
66-
"redis-v4": "npm:[email protected]",
62+
"redis": "^4.7.1",
6763
"rimraf": "5.0.10",
6864
"test-all-versions": "6.1.0",
6965
"typescript": "5.0.4"

plugins/node/opentelemetry-instrumentation-redis/test/v2-v3/redis.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const unsetStatus: SpanStatus = {
6464
code: SpanStatusCode.UNSET,
6565
};
6666

67-
describe('redis@2.x', () => {
67+
describe('redis v2-v3', () => {
6868
let redis: typeof redisTypes;
6969
const shouldTestLocal = process.env.RUN_REDIS_TESTS_LOCAL;
7070
const shouldTest = process.env.RUN_REDIS_TESTS || shouldTestLocal;

plugins/node/opentelemetry-instrumentation-redis/test/v4/redis.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import {
5555
import { RedisResponseCustomAttributeFunction } from '../../src/types';
5656
import { hrTimeToMilliseconds, suppressTracing } from '@opentelemetry/core';
5757

58-
describe('redis@^4.0.0', () => {
58+
describe('redis v4', () => {
5959
before(function () {
6060
// needs to be "function" to have MochaContext "this" context
6161
if (!shouldTest) {
@@ -315,7 +315,13 @@ describe('redis@^4.0.0', () => {
315315
// Ignore. If the test Redis is not at the default port we expect this
316316
// to error.
317317
}
318-
await newClient.disconnect();
318+
// See https://github.com/open-telemetry/opentelemetry-js-contrib/pull/2914
319+
try {
320+
await newClient.disconnect();
321+
} catch (_disconnectErr) {
322+
// Ignore. In [email protected] and earlier this disconnect throws
323+
// "The client is closed" if the connect failed.
324+
}
319325

320326
const [span] = getTestSpans();
321327
assert.strictEqual(span.name, 'redis-connect');

0 commit comments

Comments
 (0)