Skip to content

Commit 947c5a5

Browse files
CLDSRV-741: Test backbeat bucket indexing 501
1 parent 6e415d8 commit 947c5a5

File tree

2 files changed

+94
-64
lines changed

2 files changed

+94
-64
lines changed

tests/functional/backbeat/bucketIndexing.js

Lines changed: 94 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const async = require('async');
44
const { makeRequest } = require('../../functional/raw-node/utils/makeRequest');
55
const BucketUtility =
66
require('../../functional/aws-node-sdk/lib/utility/bucket-util');
7-
const { runIfMongo } = require('./utils');
87

98
const ipAddress = process.env.IP ? process.env.IP : '127.0.0.1';
109

@@ -15,7 +14,7 @@ const backbeatAuthCredentials = {
1514
secretKey: s3.config.credentials.secretAccessKey,
1615
};
1716

18-
const TEST_BUCKET = 'backbeatbucket';
17+
const TEST_BUCKET = 'bucket-for-bucket-indexing';
1918

2019
function indexDeleteRequest(payload, bucket, cb) {
2120
makeRequest({
@@ -102,7 +101,10 @@ const indexRespObject = [
102101
},
103102
];
104103

105-
runIfMongo('Indexing Routes', () => {
104+
const describeIfMongo = process.env.S3METADATA === 'mongodb' ? describe : describe.skip;
105+
const describeIfNotMongo = process.env.S3METADATA !== 'mongodb' ? describe : describe.skip;
106+
107+
describe('Indexing Routes', () => {
106108
before(done => {
107109
s3.createBucket({ Bucket: TEST_BUCKET }).promise()
108110
.then(() => done())
@@ -112,11 +114,11 @@ runIfMongo('Indexing Routes', () => {
112114
});
113115
});
114116

115-
// after(done => {
116-
// bucketUtil.empty(TEST_BUCKET)
117-
// .then(() => s3.deleteBucket({ Bucket: TEST_BUCKET }).promise())
118-
// .then(() => done());
119-
// });
117+
after(done => {
118+
bucketUtil.empty(TEST_BUCKET)
119+
.then(() => s3.deleteBucket({ Bucket: TEST_BUCKET }).promise())
120+
.then(() => done());
121+
});
120122

121123
it('should reject non-authenticated requests', done => {
122124
makeRequest({
@@ -158,61 +160,92 @@ runIfMongo('Indexing Routes', () => {
158160
});
159161
});
160162

161-
it('should successfully add indexes', done => {
162-
async.series([
163-
next => {
164-
indexPutRequest(indexReqObject, TEST_BUCKET, err => {
165-
assert.ifError(err);
166-
next();
167-
});
168-
},
169-
next => {
170-
indexGetRequest(TEST_BUCKET, (err, data) => {
171-
assert.ifError(err);
172-
const res = JSON.parse(data.body);
173-
assert.deepStrictEqual(res.Indexes, indexRespObject);
174-
next();
175-
});
176-
},
177-
], done);
163+
describeIfMongo('with mongodb metadata', () => {
164+
it('should successfully add indexes', done => {
165+
async.series([
166+
next => {
167+
indexPutRequest(indexReqObject, TEST_BUCKET, err => {
168+
assert.ifError(err);
169+
next();
170+
});
171+
},
172+
next => {
173+
indexGetRequest(TEST_BUCKET, (err, data) => {
174+
assert.ifError(err);
175+
const res = JSON.parse(data.body);
176+
assert.deepStrictEqual(res.Indexes, indexRespObject);
177+
next();
178+
});
179+
},
180+
], done);
181+
});
182+
183+
it('should successfully delete indexes', done => {
184+
async.series([
185+
next => {
186+
indexPutRequest(indexReqObject, TEST_BUCKET, err => {
187+
assert.ifError(err);
188+
next();
189+
});
190+
},
191+
next => {
192+
indexGetRequest(TEST_BUCKET, (err, data) => {
193+
assert.ifError(err);
194+
const res = JSON.parse(data.body);
195+
assert.deepStrictEqual(res.Indexes, indexRespObject);
196+
next();
197+
});
198+
},
199+
next => {
200+
indexDeleteRequest(indexReqObject, TEST_BUCKET, err => {
201+
assert.ifError(err);
202+
next();
203+
});
204+
},
205+
next => {
206+
indexGetRequest(TEST_BUCKET, (err, data) => {
207+
assert.ifError(err);
208+
const res = JSON.parse(data.body);
209+
assert.deepStrictEqual(res.Indexes, [
210+
{
211+
name: '_id_',
212+
keys: [{ key: '_id', order: 1 }],
213+
}
214+
]);
215+
next();
216+
});
217+
},
218+
], done);
219+
});
178220
});
179221

180-
it('should successfully delete indexes', done => {
181-
async.series([
182-
next => {
183-
indexPutRequest(indexReqObject, TEST_BUCKET, err => {
184-
assert.ifError(err);
185-
next();
186-
});
187-
},
188-
next => {
189-
indexGetRequest(TEST_BUCKET, (err, data) => {
190-
assert.ifError(err);
191-
const res = JSON.parse(data.body);
192-
assert.deepStrictEqual(res.Indexes, indexRespObject);
193-
next();
194-
});
195-
},
196-
next => {
197-
indexDeleteRequest(indexReqObject, TEST_BUCKET, err => {
198-
assert.ifError(err);
199-
next();
200-
});
201-
},
202-
next => {
203-
indexGetRequest(TEST_BUCKET, (err, data) => {
204-
assert.ifError(err);
205-
const res = JSON.parse(data.body);
206-
assert.deepStrictEqual(res.Indexes, [
207-
{
208-
name: '_id_',
209-
keys: [{ key: '_id', order: 1 }],
210-
}
211-
]);
212-
next();
213-
});
214-
},
215-
], done);
222+
describeIfNotMongo('without mongodb metadata', () => {
223+
it('should return NotImplemented add indexes', done => {
224+
indexPutRequest(indexReqObject, TEST_BUCKET, err => {
225+
assert(err);
226+
assert.strictEqual(err.code, 'NotImplemented');
227+
assert.strictEqual(err.statusCode, 501);
228+
done();
229+
});
230+
});
231+
232+
it('should return NotImplemented get indexes', done => {
233+
indexGetRequest(TEST_BUCKET, err => {
234+
assert(err);
235+
assert.strictEqual(err.code, 'NotImplemented');
236+
assert.strictEqual(err.statusCode, 501);
237+
done();
238+
});
239+
});
240+
241+
it('should return NotImplemented delete indexes', done => {
242+
indexDeleteRequest(indexReqObject, TEST_BUCKET, err => {
243+
assert(err);
244+
assert.strictEqual(err.code, 'NotImplemented');
245+
assert.strictEqual(err.statusCode, 501);
246+
done();
247+
});
248+
});
216249
});
217250
});
218251

tests/functional/backbeat/utils.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ function makeBackbeatRequest(params, callback) {
8383
makeRequest(options, callback);
8484
}
8585

86-
const runIfMongo = process.env.S3METADATA === 'mongodb' ? describe : describe.skip;
87-
8886
module.exports = {
8987
makeBackbeatRequest,
90-
runIfMongo,
9188
updateMetadata,
9289
};

0 commit comments

Comments
 (0)