Skip to content

Commit 39b0032

Browse files
committed
Re-enable couchbase testing
This change re-enables testing for the couchbase integration. In order to do so, there are a few changes which were made: 1. Use a new container repository for couchbase (previously owned by sabrenner, now owned by DataDog). 1. Drop testing support for Couchbase API versions 2.6.5, 3.0.0-3.2.0, and 3.2.2 **Reasons for dropping versions** * 2.6.5 - Couchbase only supports this version for node versions 6, 8, and 10. Since dd-trace-js does not support these versions, 2.6.5 is dropped. * 3.0.0 <= x < 3.2.0 - Couchbase officialy dropped support for 3.0.x in Jul 2022 and 3.1 in June 2023. Since these dates have passed, we are dropping support in dd-trace-js * 3.2.2 - This version of couchbase encounters segfaults when calling 'upsert' with couchbase server 6.0. These issues can be fixed by using Couchbase API 4.0+ with Couchbase Server 7.0+. However, dd-trace-js does not yet support testing against either of these.
1 parent 7804e9b commit 39b0032

File tree

5 files changed

+22
-225
lines changed

5 files changed

+22
-225
lines changed

.github/workflows/plugins.yml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -182,24 +182,25 @@ jobs:
182182
uses: ./.github/actions/testagent/logs
183183
- uses: codecov/codecov-action@v2
184184

185-
# couchbase:
186-
# runs-on: ubuntu-latest
187-
# services:
188-
# couchbase:
189-
# image: sabrenner/couchbase-server-sandbox:latest
190-
# ports:
191-
# - 8091-8095:8091-8095
192-
# - 11210:11210
193-
# env:
194-
# PLUGINS: couchbase
195-
# SERVICES: couchbase
196-
# steps:
197-
# - uses: actions/checkout@v2
198-
# - uses: ./.github/actions/node/setup
199-
# - run: yarn install
200-
# - uses: ./.github/actions/node/oldest
201-
# - run: yarn test:plugins:ci
202-
# - uses: codecov/codecov-action@v2
185+
couchbase:
186+
runs-on: ubuntu-latest
187+
services:
188+
couchbase:
189+
image: ghcr.io/datadog/couchbase-server-sandbox:latest
190+
ports:
191+
- 8091-8095:8091-8095
192+
- 11210:11210
193+
env:
194+
PLUGINS: couchbase
195+
SERVICES: couchbase
196+
steps:
197+
- uses: actions/checkout@v2
198+
- uses: ./.github/actions/testagent/start
199+
- uses: ./.github/actions/node/setup
200+
- run: yarn install
201+
- uses: ./.github/actions/node/oldest
202+
- run: yarn test:plugins:ci
203+
- uses: codecov/codecov-action@v2
203204

204205
connect:
205206
runs-on: ubuntu-latest

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: "2"
22
services:
33
couchbase:
4-
image: sabrenner/couchbase-server-sandbox:latest
4+
image: ghcr.io/datadog/couchbase-server-sandbox:latest
55
ports:
66
- "127.0.0.1:8091-8095:8091-8095"
77
- "127.0.0.1:11210:11210"

packages/datadog-instrumentations/src/couchbase.js

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -159,76 +159,6 @@ function wrapV3Query (query) {
159159
}
160160
}
161161

162-
// semver >=2 <3
163-
addHook({ name: 'couchbase', file: 'lib/bucket.js', versions: ['^2.6.5'] }, Bucket => {
164-
const startCh = channel('apm:couchbase:query:start')
165-
const finishCh = channel('apm:couchbase:query:finish')
166-
const errorCh = channel('apm:couchbase:query:error')
167-
168-
Bucket.prototype._maybeInvoke = wrapMaybeInvoke(Bucket.prototype._maybeInvoke)
169-
Bucket.prototype.query = wrapQuery(Bucket.prototype.query)
170-
171-
shimmer.wrap(Bucket.prototype, '_n1qlReq', _n1qlReq => function (host, q, adhoc, emitter) {
172-
if (!startCh.hasSubscribers) {
173-
return _n1qlReq.apply(this, arguments)
174-
}
175-
176-
if (!emitter || !emitter.once) return _n1qlReq.apply(this, arguments)
177-
178-
const n1qlQuery = getQueryResource(q)
179-
180-
const asyncResource = new AsyncResource('bound-anonymous-fn')
181-
return asyncResource.runInAsyncScope(() => {
182-
startCh.publish({ resource: n1qlQuery, bucket: { name: this.name || this._name } })
183-
184-
emitter.once('rows', asyncResource.bind(() => {
185-
finishCh.publish(undefined)
186-
}))
187-
188-
emitter.once('error', asyncResource.bind((error) => {
189-
errorCh.publish(error)
190-
finishCh.publish(undefined)
191-
}))
192-
193-
try {
194-
return _n1qlReq.apply(this, arguments)
195-
} catch (err) {
196-
err.stack // trigger getting the stack at the original throwing point
197-
errorCh.publish(err)
198-
199-
throw err
200-
}
201-
})
202-
})
203-
204-
wrapAllNames(['upsert', 'insert', 'replace', 'append', 'prepend'], name => {
205-
Bucket.prototype[name] = wrap(`apm:couchbase:${name}`, Bucket.prototype[name])
206-
})
207-
208-
return Bucket
209-
})
210-
211-
addHook({ name: 'couchbase', file: 'lib/cluster.js', versions: ['^2.6.5'] }, Cluster => {
212-
Cluster.prototype._maybeInvoke = wrapMaybeInvoke(Cluster.prototype._maybeInvoke)
213-
Cluster.prototype.query = wrapQuery(Cluster.prototype.query)
214-
215-
return Cluster
216-
})
217-
218-
// semver >=3 <3.2.0
219-
220-
addHook({ name: 'couchbase', file: 'lib/collection.js', versions: ['>=3.0.0 <3.2.0'] }, Collection => {
221-
wrapAllNames(['upsert', 'insert', 'replace'], name => {
222-
shimmer.wrap(Collection.prototype, name, wrapWithName(name))
223-
})
224-
225-
return Collection
226-
})
227-
228-
addHook({ name: 'couchbase', file: 'lib/cluster.js', versions: ['>=3.0.0 <3.2.0'] }, Cluster => {
229-
shimmer.wrap(Cluster.prototype, 'query', wrapV3Query)
230-
return Cluster
231-
})
232162

233163
// semver >=3.2.0
234164

packages/datadog-plugin-couchbase/test/index.spec.js

Lines changed: 1 addition & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -18,141 +18,7 @@ describe('Plugin', () => {
1818
tracer = global.tracer = require('../../dd-trace')
1919
})
2020

21-
withVersions('couchbase', 'couchbase', '<3.0.0', version => {
22-
let N1qlQuery
23-
describe('without configuration', () => {
24-
beforeEach(done => {
25-
agent.load('couchbase').then(() => {
26-
couchbase = proxyquire(`../../../versions/couchbase@${version}`, {}).get()
27-
N1qlQuery = couchbase.N1qlQuery
28-
cluster = new couchbase.Cluster('localhost:8091')
29-
cluster.authenticate('Administrator', 'password')
30-
cluster.enableCbas('localhost:8095')
31-
bucket = cluster.openBucket('datadog-test', (err) => done(err))
32-
})
33-
})
34-
35-
afterEach(() => {
36-
bucket.disconnect()
37-
})
38-
39-
after(() => {
40-
return agent.close({ ritmReset: false })
41-
})
42-
43-
it('should run the Query callback in the parent context', done => {
44-
const query = 'SELECT 1+1'
45-
const span = tracer.startSpan('test.query.cb')
46-
47-
tracer.scope().activate(span, () => {
48-
const n1qlQuery = N1qlQuery.fromString(query)
49-
cluster.query(n1qlQuery, (err, rows) => {
50-
expect(tracer.scope().active()).to.equal(span)
51-
done(err)
52-
})
53-
})
54-
})
55-
56-
it('should run any Bucket operations in the parent context', done => {
57-
const span = tracer.startSpan('test')
58-
59-
tracer.scope().activate(span, () => {
60-
bucket.get('1', () => {
61-
expect(tracer.scope().active()).to.equal(span)
62-
done()
63-
})
64-
})
65-
})
66-
67-
describe('queries on cluster', () => {
68-
it('should handle N1QL queries', done => {
69-
const query = 'SELECT 1+1'
70-
71-
agent
72-
.use(traces => {
73-
const span = traces[0][0]
74-
expect(span).to.have.property('name', 'couchbase.query')
75-
expect(span).to.have.property('service', 'test-couchbase')
76-
expect(span).to.have.property('resource', query)
77-
expect(span).to.have.property('type', 'sql')
78-
expect(span.meta).to.have.property('span.kind', 'client')
79-
expect(span.meta).to.have.property('couchbase.bucket.name', 'datadog-test')
80-
expect(span.meta).to.have.property('component', 'couchbase')
81-
})
82-
.then(done)
83-
.catch(done)
84-
85-
const n1qlQuery = N1qlQuery.fromString(query)
86-
cluster.query(n1qlQuery, (err) => {
87-
if (err) done(err)
88-
})
89-
90-
if (semver.intersects(version, '2.4.0 - 2.5.0')) {
91-
// Due to bug JSCBC-491 in Couchbase, we have to reconnect to dispatch waiting queries
92-
const triggerBucket = cluster.openBucket('datadog-test', (err) => {
93-
if (err) done(err)
94-
})
95-
triggerBucket.on('connect', () => triggerBucket.disconnect())
96-
}
97-
})
98-
99-
it('should handle storage queries', done => {
100-
agent
101-
.use(traces => {
102-
const span = traces[0][0]
103-
expect(span).to.have.property('name', 'couchbase.upsert')
104-
expect(span).to.have.property('service', 'test-couchbase')
105-
expect(span).to.have.property('resource', 'couchbase.upsert')
106-
expect(span.meta).to.have.property('span.kind', 'client')
107-
expect(span.meta).to.have.property('couchbase.bucket.name', 'datadog-test')
108-
expect(span.meta).to.have.property('component', 'couchbase')
109-
})
110-
.then(done)
111-
.catch(done)
112-
113-
bucket.upsert('testdoc', { name: 'Frank' }, (err, result) => {
114-
if (err) done(err)
115-
})
116-
})
117-
118-
it('should skip instrumentation for invalid arguments', (done) => {
119-
try {
120-
bucket.upsert('testdoc', { name: 'Frank' })
121-
} catch (e) {
122-
expect(e.message).to.equal('Third argument needs to be an object or callback.')
123-
done()
124-
}
125-
})
126-
})
127-
128-
describe('queries on buckets', () => {
129-
it('should handle N1QL queries', done => {
130-
const query = 'SELECT 1+2'
131-
132-
agent
133-
.use(traces => {
134-
const span = traces[0][0]
135-
expect(span).to.have.property('name', 'couchbase.query')
136-
expect(span).to.have.property('service', 'test-couchbase')
137-
expect(span).to.have.property('resource', query)
138-
expect(span).to.have.property('type', 'sql')
139-
expect(span.meta).to.have.property('span.kind', 'client')
140-
expect(span.meta).to.have.property('couchbase.bucket.name', 'datadog-test')
141-
expect(span.meta).to.have.property('component', 'couchbase')
142-
})
143-
.then(done)
144-
.catch(done)
145-
146-
const n1qlQuery = N1qlQuery.fromString(query)
147-
bucket.query(n1qlQuery, (err) => {
148-
if (err) done(err)
149-
})
150-
})
151-
})
152-
})
153-
})
154-
155-
withVersions('couchbase', 'couchbase', '>=3.0.0', version => {
21+
withVersions('couchbase', 'couchbase', '3.2.0 - 3.2.1', version => {
15622
beforeEach(() => {
15723
tracer = global.tracer = require('../../dd-trace')
15824
})

scripts/install_plugin_modules.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const externals = require('../packages/dd-trace/test/plugins/externals')
1212

1313
const requirePackageJsonPath = require.resolve('../packages/dd-trace/src/require-package-json')
1414

15-
const excludeList = os.arch() === 'arm64' ? ['couchbase', 'grpc', 'oracledb'] : []
15+
const excludeList = os.arch() === 'arm64' ? ['grpc', 'oracledb'] : []
1616
const workspaces = new Set()
1717
const versionLists = {}
1818
const deps = {}

0 commit comments

Comments
 (0)