Skip to content

Commit 9912bca

Browse files
committed
test: test
1 parent aec8601 commit 9912bca

1 file changed

Lines changed: 62 additions & 1 deletion

File tree

  • packages/collector/test/integration/currencies/databases/redis

packages/collector/test/integration/currencies/databases/redis/test_base.js

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,67 @@ module.exports = function (name, version, isLatest, mode) {
998998
});
999999
});
10001000
});
1001+
1002+
mochaSuiteFn('disable redis:', function () {
1003+
describe('when both agent config and env var are set, env var takes precedence', () => {
1004+
const customAgentControls = new AgentStubControls();
1005+
let controls;
1006+
1007+
before(async () => {
1008+
await customAgentControls.startAgent({
1009+
disable: { redis: false }
1010+
});
1011+
1012+
controls = new ProcessControls({
1013+
agentControls: customAgentControls,
1014+
dirname: __dirname,
1015+
appName: isLegacyVersion ? 'legacyApp' : 'app',
1016+
env: {
1017+
LIBRARY_LATEST: isLatest,
1018+
LIBRARY_VERSION: version,
1019+
LIBRARY_NAME: name,
1020+
REDIS_SETUP_TYPE: mode,
1021+
INSTANA_TRACING_DISABLE: 'redis'
1022+
}
1023+
});
1024+
await controls.startAndWaitForAgentConnection(5000, Date.now() + 1000 * 60 * 5);
1025+
});
1026+
1027+
beforeEach(async () => {
1028+
await customAgentControls.clearReceivedTraceData();
1029+
});
1030+
1031+
after(async () => {
1032+
await customAgentControls.stopAgent();
1033+
await controls.stop();
1034+
});
1035+
1036+
it('should use env var config and disable redis tracing', async () => {
1037+
await controls
1038+
.sendRequest({
1039+
method: 'POST',
1040+
path: '/values',
1041+
qs: {
1042+
key: 'discount',
1043+
value: 50
1044+
}
1045+
})
1046+
.then(async () => {
1047+
return retry(async () => {
1048+
const spans = await customAgentControls.getSpans();
1049+
// 1 x http entry span
1050+
// 1 x http client span
1051+
// No redis spans because redis is disabled via env var
1052+
expect(spans.length).to.equal(2);
1053+
1054+
spans.forEach(span => {
1055+
expect(span.n).not.to.equal('redis');
1056+
});
1057+
});
1058+
});
1059+
});
1060+
});
1061+
});
10011062
});
10021063

10031064
mochaSuiteFn('ignore-endpoints:', function () {
@@ -1157,7 +1218,7 @@ module.exports = function (name, version, isLatest, mode) {
11571218
expect(spans.length).to.equal(4);
11581219
expect(spans.some(span => span.n === 'redis')).to.be.true;
11591220
});
1160-
});
1221+
});
11611222
});
11621223
});
11631224

0 commit comments

Comments
 (0)