Skip to content

Commit

Permalink
feat: added support for couchbase v4.4.4 (#1466)
Browse files Browse the repository at this point in the history
refs INSTA-20554
  • Loading branch information
abhilash-sivan authored Dec 11, 2024
1 parent fcbbed7 commit fb06bdc
Show file tree
Hide file tree
Showing 7 changed files with 911 additions and 678 deletions.
182 changes: 152 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@
"yargs": "^17.5.1"
},
"optionalDependencies": {
"couchbase": "^4.4.3",
"couchbase": "^4.4.4",
"couchbase-v443": "npm:[email protected]",
"ibm_db": "^3.2.5",
"kafka-avro": "^3.2.0",
"node-rdkafka": "^3.2.1",
Expand Down
36 changes: 21 additions & 15 deletions packages/collector/test/tracing/database/couchbase/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ process.on('SIGTERM', () => {
process.exit(0);
});

require('./mockVersion');

require('../../../..')();

const couchbase = require('couchbase');
const bodyParser = require('body-parser');
const express = require('express');
const uuid = require('uuid');
const morgan = require('morgan');
const fetch = require('node-fetch-v2');
const port = require('../../../test_util/app-port')();
const { delay } = require('../../../../../core/test/test_util');
const agentPort = process.env.INSTANA_AGENT_PORT;
Expand Down Expand Up @@ -685,23 +686,28 @@ app.post('/queryindexes-callback', (req, res) => {
scope2.query(qs1, err3 => {
if (err3) return res.status(500).json({ err: err3.message });

scope2.query(qs2, () => {
// ignore this error because we expect it to fail

cluster.queryIndexes().dropIndex(bucket2.name, idx2, err5 => {
if (err5) return res.status(500).json({ err: err5.message });

cluster.queryIndexes().dropPrimaryIndex(bucket1.name, { name: idx1 }, err6 => {
if (err6) return res.status(500).json({ err: err6.message });

cluster.queryIndexes().getAllIndexes(bucket2.name, err7 => {
if (err7) return res.status(500).json({ err: err7.message });

res.json({ success: true });
// Added a temporary promise catch handler due to an issue in the package.
// see https://github.com/couchbase/couchnode/issues/123
scope2
.query(qs2)
.catch(() => {
// Ignore this error because we expect it to fail
})
.finally(() => {
cluster.queryIndexes().dropIndex(bucket2.name, idx2, err5 => {
if (err5) return res.status(500).json({ err: err5.message });

cluster.queryIndexes().dropPrimaryIndex(bucket1.name, { name: idx1 }, err6 => {
if (err6) return res.status(500).json({ err: err6.message });

cluster.queryIndexes().getAllIndexes(bucket2.name, err7 => {
if (err7) return res.status(500).json({ err: err7.message });

res.json({ success: true });
});
});
});
});
});
});
});
});
Expand Down
20 changes: 13 additions & 7 deletions packages/collector/test/tracing/database/couchbase/app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import bodyParser from 'body-parser';
import express from 'express';
import { v1 } from 'uuid';
import morgan from 'morgan';
import fetch from 'node-fetch';
import portFactory from '../../../test_util/app-port.js';
import testUtil from '../../../../../core/test/test_util/index.js';

Expand Down Expand Up @@ -567,15 +566,22 @@ app.post('/queryindexes-callback', (req, res) => {
cluster.queryIndexes().createIndex(bucket2.name, idx2, ['name'], () => {
cluster.query(qs, () => {
scope2.query(qs1, () => {
scope2.query(qs2, () => {
cluster.queryIndexes().dropIndex(bucket1.name, idx1, () => {
cluster.queryIndexes().dropPrimaryIndex(bucket2.name, { name: idx2 }, () => {
cluster.queryIndexes().getAllIndexes(bucket2.name, () => {
res.json({ success: true });
// Added a temporary promise catch handler due to an issue in the package.
// see https://github.com/couchbase/couchnode/issues/123
scope2
.query(qs2)
.catch(() => {
// Ignore this error because we expect it to fail
})
.finally(() => {
cluster.queryIndexes().dropIndex(bucket1.name, idx1, () => {
cluster.queryIndexes().dropPrimaryIndex(bucket2.name, { name: idx2 }, () => {
cluster.queryIndexes().getAllIndexes(bucket2.name, () => {
res.json({ success: true });
});
});
});
});
});
});
});
});
Expand Down
13 changes: 13 additions & 0 deletions packages/collector/test/tracing/database/couchbase/mockVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* (c) Copyright IBM Corp. 2024
*/

'use strict';

const mock = require('mock-require');
const COUCHBASE_VERSION = process.env.COUCHBASE_VERSION;
const COUCHBASE_REQUIRE = process.env.COUCHBASE_VERSION === 'latest' ? 'couchbase' : `couchbase-${COUCHBASE_VERSION}`;

if (COUCHBASE_REQUIRE !== 'couchbase') {
mock('couchbase', COUCHBASE_REQUIRE);
}
Loading

0 comments on commit fb06bdc

Please sign in to comment.