Skip to content

Commit 8fc9a03

Browse files
committed
DEVEXP-593 : Filter tests based on server versions.
1 parent cf2bf00 commit 8fc9a03

19 files changed

+315
-176
lines changed

etc/test-lib.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,12 @@ function createManager(adminClient) {
195195
return new Manager(adminClient);
196196
}
197197

198-
function findServerConfiguration(){
198+
function findServerConfiguration(serverConfiguration){
199199
const manageClient = marklogic.createDatabaseClient(testconfig.manageAdminConnection);
200-
return new Manager(manageClient).get({
200+
new Manager(manageClient).get({
201201
endpoint: '/manage/v2?format=json',
202+
}).result(function(response){
203+
serverConfiguration.serverVersion = parseFloat(response.data['local-cluster-default'].version).toFixed(2);
202204
});
203205
}
204206

test-basic/bindingFromParam.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,23 @@ const op = marklogic.planBuilder;
2121
let should = require('should');
2222
const fs = require("fs");
2323
const testlib = require("../etc/test-lib");
24-
let serverVersionGreaterThanEqual11 = false;
24+
let serverConfiguration = {};
2525

2626
describe('optic-update fromParam tests', function(){
27-
27+
this.timeout(20000);
2828
before(function (done) {
29-
testlib.findServerConfiguration().result(function (response) {
30-
serverVersionGreaterThanEqual11 = (parseInt(response.data['local-cluster-default'].version) >= 11);
31-
done();
32-
}).catch(error => done(error));
29+
try {
30+
testlib.findServerConfiguration(serverConfiguration);
31+
setTimeout(()=>{done();}, 3000);
32+
} catch(error){
33+
done(error);
34+
}
3335
});
3436

3537
describe('binding from param', function () {
36-
this.timeout(20000);
38+
3739
before(function(done){
38-
if(!serverVersionGreaterThanEqual11){
40+
if(serverConfiguration.serverVersion < 11){
3941
this.skip();
4042
}
4143
done();

test-basic/docColTypes-test.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,22 @@ const marklogic = require('../');
2020
const testlib = require("../etc/test-lib");
2121
const db = marklogic.createDatabaseClient(testconfig.restWriterConnection);
2222
const op = marklogic.planBuilder;
23-
let serverVersionGreaterThanEqual11 = false;
23+
let serverConfiguration = {};
2424

2525
describe('optic-update docColTypes tests', function() {
26+
this.timeout(6000);
2627
before(function (done) {
27-
testlib.findServerConfiguration().result(function (response) {
28-
serverVersionGreaterThanEqual11 = (parseInt(response.data['local-cluster-default'].version) >= 11);
29-
done();
30-
}).catch(error => done(error));
28+
try {
29+
testlib.findServerConfiguration(serverConfiguration);
30+
setTimeout(()=>{done();}, 3000);
31+
} catch(error){
32+
done(error);
33+
}
3134
});
3235

3336
describe('optic docColTypes test ', function () {
3437
before(function(done){
35-
if(!serverVersionGreaterThanEqual11){
38+
if(serverConfiguration.serverVersion < 11){
3639
this.skip();
3740
}
3841
done();

test-basic/documents-data-movement-rows-queryAll.js

Lines changed: 73 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const Stream = require('stream');
2323
const streamToArray = require('stream-to-array');
2424
const p = marklogic.planBuilder;
2525
const fs = require('fs');
26+
const testlib = require("../etc/test-lib");
2627
const tdeWriter = marklogic.createDatabaseClient({
2728
database: 'unittest-nodeapi-modules',
2829
host: 'localhost',
@@ -35,68 +36,37 @@ const tdeWriter = marklogic.createDatabaseClient({
3536
let uris = new Set();
3637
let result = [];
3738
const planFromBuilderTemplate = p.fromView('soccer', 'matches', '');
39+
let serverConfiguration = {};
3840

39-
describe.skip('data movement rows-queryAll', function() {
41+
describe('data movement rows-queryAll', function() {
4042
this.timeout(15000);
4143
before(function(done){
42-
const view = [
43-
{
44-
uri:'/test/exporting-rows.xml',
45-
collections:['http://marklogic.com/xdmp/tde'],
46-
contentType:'application/xml',
47-
content:fs.createReadStream('./test-basic/data/exportingRows.tdex'),
48-
permissions: [
49-
{'role-name': 'rest-reader', capabilities: ['read']},
50-
{'role-name': 'rest-writer', capabilities: ['read', 'update','execute']}
51-
]
52-
}];
53-
tdeWriter.documents.write(view)
54-
.result(function(response){
55-
let readable = new Stream.Readable({objectMode: true});
56-
for(let i=1; i<=200;i++){
57-
let temp = {
58-
uri: '/test/dataMovement/requests/exporting-rows/'+i+'.xml',
59-
contentType: 'application/xml',
60-
content: '<?xml version="1.0" encoding="UTF-8"?>\n' +
61-
'<match>\n' +
62-
'<id>'+i+'</id>\n' +
63-
'<docUri>/test/dataMovement/requests/exporting-rows/'+i+'.xml</docUri>\n' +
64-
'<match-date>2016-10-12</match-date>\n' +
65-
'<league>Premier-'+i+'</league>\n' +
66-
'<score>\n' +
67-
'<home>'+i+'</home>\n' +
68-
'</score>\n' +
69-
'</match>'
70-
};
71-
uris.add(temp.uri);
72-
readable.push(temp);
44+
try {
45+
testlib.findServerConfiguration(serverConfiguration);
46+
setTimeout(()=>{
47+
if(serverConfiguration.serverVersion >= 12){
48+
this.skip();
7349
}
74-
readable.push(null);
75-
dbWriter.documents.writeAll(readable,{
76-
defaultMetadata: {
77-
collections: ['source1'],
78-
permissions: [
79-
{'role-name': 'rest-reader', capabilities: ['read']},
80-
{'role-name': 'rest-writer', capabilities: ['read', 'update']}
81-
],
82-
},onCompletion: ((summary) => {
83-
done();
84-
})
85-
});
86-
});
50+
setUp(done);
51+
}, 3000);
52+
} catch(error){
53+
done(error);
54+
}
8755
});
8856

8957
after(function(done){
90-
const q = marklogic.queryBuilder;
91-
const ctsQb = marklogic.ctsQueryBuilder;
92-
const query = q.where(ctsQb.cts.directoryQuery('/test/dataMovement/requests/exporting-rows/'));
93-
dbWriter.documents.queryToRemoveAll(query, {
94-
onCompletion: ((summary) => {
95-
tdeWriter.documents.remove('/test/exporting-rows.xml')
96-
.result(function(response){})
97-
.then(done());
98-
})
99-
});
58+
if(serverConfiguration.serverVersion < 12){
59+
const q = marklogic.queryBuilder;
60+
const ctsQb = marklogic.ctsQueryBuilder;
61+
const query = q.where(ctsQb.cts.directoryQuery('/test/dataMovement/requests/exporting-rows/'));
62+
dbWriter.documents.queryToRemoveAll(query, {
63+
onCompletion: ((summary) => {
64+
tdeWriter.documents.remove('/test/exporting-rows.xml')
65+
.result(function(response){})
66+
.then(done());
67+
})
68+
});
69+
} else {done();}
10070
});
10171

10272
it('should queryAll documents with onCompletion, batchSize and concurrentRequests options', function (done){
@@ -271,3 +241,51 @@ function verifyDocs(done){
271241
result = [];
272242
done();
273243
}
244+
245+
function setUp(done) {
246+
const view = [
247+
{
248+
uri:'/test/exporting-rows.xml',
249+
collections:['http://marklogic.com/xdmp/tde'],
250+
contentType:'application/xml',
251+
content:fs.createReadStream('./test-basic/data/exportingRows.tdex'),
252+
permissions: [
253+
{'role-name': 'rest-reader', capabilities: ['read']},
254+
{'role-name': 'rest-writer', capabilities: ['read', 'update','execute']}
255+
]
256+
}];
257+
tdeWriter.documents.write(view)
258+
.result(function(response){
259+
let readable = new Stream.Readable({objectMode: true});
260+
for(let i=1; i<=200;i++){
261+
let temp = {
262+
uri: '/test/dataMovement/requests/exporting-rows/'+i+'.xml',
263+
contentType: 'application/xml',
264+
content: '<?xml version="1.0" encoding="UTF-8"?>\n' +
265+
'<match>\n' +
266+
'<id>'+i+'</id>\n' +
267+
'<docUri>/test/dataMovement/requests/exporting-rows/'+i+'.xml</docUri>\n' +
268+
'<match-date>2016-10-12</match-date>\n' +
269+
'<league>Premier-'+i+'</league>\n' +
270+
'<score>\n' +
271+
'<home>'+i+'</home>\n' +
272+
'</score>\n' +
273+
'</match>'
274+
};
275+
uris.add(temp.uri);
276+
readable.push(temp);
277+
}
278+
readable.push(null);
279+
dbWriter.documents.writeAll(readable,{
280+
defaultMetadata: {
281+
collections: ['source1'],
282+
permissions: [
283+
{'role-name': 'rest-reader', capabilities: ['read']},
284+
{'role-name': 'rest-writer', capabilities: ['read', 'update']}
285+
],
286+
},onCompletion: ((summary) => {
287+
done();
288+
})
289+
});
290+
});
291+
}

test-basic/fromDocDescriptors-test.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,21 @@ const marklogic = require('../');
2020
const testlib = require("../etc/test-lib");
2121
const db = marklogic.createDatabaseClient(testconfig.restAdminConnection);
2222
const op = marklogic.planBuilder;
23-
let serverVersionGreaterThanEqual11 = false;
23+
let serverConfiguration = {};
2424
describe('optic-update fromDocDescriptors tests', function() {
25+
this.timeout(10000);
2526
before(function (done) {
26-
testlib.findServerConfiguration().result(function (response) {
27-
serverVersionGreaterThanEqual11 = (parseInt(response.data['local-cluster-default'].version) >= 11);
28-
done();
29-
}).catch(error => done(error));
27+
try {
28+
testlib.findServerConfiguration(serverConfiguration);
29+
setTimeout(()=>{done();}, 3000);
30+
} catch(error){
31+
done(error);
32+
}
3033
});
3134

3235
describe('fromDocDescriptors ', function () {
3336
before(function(done){
34-
if(!serverVersionGreaterThanEqual11){
37+
if(serverConfiguration.serverVersion < 11){
3538
this.skip();
3639
}
3740
done();

test-basic/joinDocCols-test.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,21 @@ const {first} = require("../lib/mlutil");
2323
const testlib = require("../etc/test-lib");
2424
const op = marklogic.planBuilder;
2525
let removeStream = new Stream.PassThrough({objectMode: true});
26-
let serverVersionGreaterThanEqual11 = false;
26+
let serverConfiguration = {};
2727
describe('optic-update joinDocCols tests', function() {
28+
this.timeout(6000);
2829
before(function (done) {
29-
testlib.findServerConfiguration().result(function (response) {
30-
serverVersionGreaterThanEqual11 = (parseInt(response.data['local-cluster-default'].version) >= 11);
31-
done();
32-
}).catch(error => done(error));
30+
try {
31+
testlib.findServerConfiguration(serverConfiguration);
32+
setTimeout(()=>{done();}, 3000);
33+
} catch(error){
34+
done(error);
35+
}
3336
});
3437

3538
describe('optic joinDocCols test ', function () {
36-
this.timeout(4000);
3739
before(function (done) {
38-
if(!serverVersionGreaterThanEqual11){
40+
if(serverConfiguration.serverVersion < 11){
3941
this.skip();
4042
}
4143
let readable = new Stream.Readable({objectMode: true});
@@ -59,12 +61,16 @@ describe('optic-update joinDocCols tests', function() {
5961
});
6062

6163
after(function (done) {
62-
db.documents.remove("/test/optic/joinDocCols/musician1.json")
63-
.result(function (response) {
64-
done();
65-
})
66-
.catch(err => done(err))
67-
.catch(done);
64+
if(serverConfiguration.serverVersion < 11){
65+
done();
66+
} else {
67+
db.documents.remove("/test/optic/joinDocCols/musician1.json")
68+
.result(function (response) {
69+
done();
70+
})
71+
.catch(err => done(err))
72+
.catch(done);
73+
}
6874
});
6975

7076
it('test default columns with no qualifier', function (done) {

test-basic/lockForUpdate-test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,21 @@ const db = marklogic.createDatabaseClient(testconfig.restWriterConnection);
1919
const op = marklogic.planBuilder;
2020
const should = require('should');
2121
const testlib = require("../etc/test-lib");
22-
let serverVersionGreaterThanEqual11 = false;
22+
let serverConfiguration = {};
2323
describe('optic-update lockForUpdate tests', function() {
24+
this.timeout(6000);
2425
before(function (done) {
25-
testlib.findServerConfiguration().result(function (response) {
26-
serverVersionGreaterThanEqual11 = (parseInt(response.data['local-cluster-default'].version) >= 11);
27-
done();
28-
}).catch(error => done(error));
26+
try {
27+
testlib.findServerConfiguration(serverConfiguration);
28+
setTimeout(()=>{done();}, 3000);
29+
} catch(error){
30+
done(error);
31+
}
2932
});
3033

3134
describe('test lockForUpdate', function () {
32-
this.timeout(6000);
3335
before(function(done){
34-
if(!serverVersionGreaterThanEqual11){
36+
if(serverConfiguration.serverVersion < 11){
3537
this.skip();
3638
}
3739
done();
@@ -120,7 +122,5 @@ describe('optic-update lockForUpdate tests', function() {
120122
}
121123
}).catch(e => done(e));
122124
});
123-
124-
125125
});
126126
});

test-basic/optic-fromDocUris.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,22 @@ const Stream = require('stream');
1414
const testlib = require("../etc/test-lib");
1515
let result = new Set();
1616
let uris = [];
17-
let serverVersionGreaterThanEqual11 = false;
17+
let serverConfiguration = {};
1818
describe('optic-update fromDocUris tests', function() {
19+
this.timeout(15000);
1920
before(function (done) {
20-
testlib.findServerConfiguration().result(function (response) {
21-
serverVersionGreaterThanEqual11 = (parseInt(response.data['local-cluster-default'].version) >= 11);
22-
done();
23-
}).catch(error => done(error));
21+
try {
22+
testlib.findServerConfiguration(serverConfiguration);
23+
setTimeout(()=>{done();}, 3000);
24+
} catch(error){
25+
done(error);
26+
}
2427
});
2528

2629
describe('fromDocUris', function () {
27-
this.timeout(15000);
30+
2831
before(function (done) {
29-
if(!serverVersionGreaterThanEqual11){
32+
if(serverConfiguration.serverVersion < 11){
3033
this.skip();
3134
}
3235
let readable = new Stream.Readable({objectMode: true});
@@ -49,12 +52,16 @@ describe('optic-update fromDocUris tests', function() {
4952
});
5053

5154
after(function (done) {
52-
db.documents.remove(uris)
53-
.result(function (response) {
54-
done();
55-
})
56-
.catch(err => done(err))
57-
.catch(done);
55+
if(serverConfiguration.serverVersion < 11){
56+
db.documents.remove(uris)
57+
.result(function (response) {
58+
done();
59+
})
60+
.catch(err => done(err))
61+
.catch(done);
62+
} else {
63+
done();
64+
}
5865
});
5966

6067
it('basic', function (done) {

0 commit comments

Comments
 (0)