Skip to content

Commit f0a4294

Browse files
committed
routeBackbeatForReplication fixup by adding missing test
1 parent 0b979a4 commit f0a4294

File tree

1 file changed

+114
-1
lines changed

1 file changed

+114
-1
lines changed

tests/multipleBackend/routes/routeBackbeatForReplication.js

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,120 @@ describe(`backbeat routes for replication (${name})`, () => {
12741274

12751275
return done();
12761276
});
1277-
});
1277+
});
1278+
1279+
it('should replicate/put metadata to a destination that has a previously updated null version', done => {
1280+
let objMD;
1281+
let objMDNull;
1282+
let versionId;
1283+
1284+
async.series({
1285+
putObjectDestinationInitial: next => dstS3.send(new PutObjectCommand({
1286+
Bucket: bucketDestination,
1287+
Key: keyName,
1288+
Body: Buffer.from(testData),
1289+
})).then(data => next(null, data)).catch(err => next(err)),
1290+
enableVersioningDestination: next => dstS3.send(new PutBucketVersioningCommand({
1291+
Bucket: bucketDestination,
1292+
VersioningConfiguration: { Status: 'Enabled' },
1293+
})).then(data => next(null, data)).catch(err => next(err)),
1294+
getMetadataNullVersion: next => makeBackbeatRequest({
1295+
method: 'GET',
1296+
resourceType: 'metadata',
1297+
bucket: bucketDestination,
1298+
objectKey: keyName,
1299+
queryObj: {
1300+
versionId: 'null',
1301+
},
1302+
authCredentials: destinationAuthCredentials,
1303+
}, (err, data) => {
1304+
if (err) {
1305+
return next(err);
1306+
}
1307+
objMDNull = JSON.parse(data.body).Body;
1308+
return next();
1309+
}),
1310+
updateMetadataNullVersion: next => makeBackbeatRequest({
1311+
method: 'PUT',
1312+
resourceType: 'metadata',
1313+
bucket: bucketDestination,
1314+
objectKey: keyName,
1315+
queryObj: {
1316+
versionId: 'null',
1317+
},
1318+
authCredentials: destinationAuthCredentials,
1319+
requestBody: objMDNull,
1320+
}, next),
1321+
enableVersioningSource: next => srcS3.send(new PutBucketVersioningCommand({
1322+
Bucket: bucketSource,
1323+
VersioningConfiguration: { Status: 'Enabled' },
1324+
})).then(data => next(null, data)).catch(err => next(err)),
1325+
putObjectSource: next => srcS3.send(new PutObjectCommand({
1326+
Bucket: bucketSource,
1327+
Key: keyName,
1328+
Body: Buffer.from(testData),
1329+
})).then(data => {
1330+
versionId = data.VersionId;
1331+
return next(null, data);
1332+
}).catch(err => next(err)),
1333+
getMetadata: next => makeBackbeatRequest({
1334+
method: 'GET',
1335+
resourceType: 'metadata',
1336+
bucket: bucketSource,
1337+
objectKey: keyName,
1338+
queryObj: {
1339+
versionId,
1340+
},
1341+
authCredentials: sourceAuthCredentials,
1342+
}, (err, data) => {
1343+
if (err) {
1344+
return next(err);
1345+
}
1346+
objMD = objectMDWithUpdatedAccountInfo(data, src === dst ? null : dstAccountInfo);
1347+
return next();
1348+
}),
1349+
replicateMetadata: next => makeBackbeatRequest({
1350+
method: 'PUT',
1351+
resourceType: 'metadata',
1352+
bucket: bucketDestination,
1353+
objectKey: keyName,
1354+
queryObj: {
1355+
versionId,
1356+
},
1357+
authCredentials: destinationAuthCredentials,
1358+
requestBody: objMD,
1359+
}, next),
1360+
headObjectNullVersion: next => dstS3.send(new HeadObjectCommand({
1361+
Bucket: bucketDestination,
1362+
Key: keyName,
1363+
VersionId: 'null',
1364+
})).then(data => next(null, data)).catch(err => next(err)),
1365+
listObjectVersions: next => dstS3.send(new ListObjectVersionsCommand({
1366+
Bucket: bucketDestination,
1367+
})).then(data => next(null, data)).catch(err => next(err)),
1368+
}, (err, results) => {
1369+
if (err) {
1370+
return done(err);
1371+
}
1372+
1373+
const headObjectRes = results.headObjectNullVersion;
1374+
assert.strictEqual(headObjectRes.VersionId, 'null');
1375+
1376+
const listObjectVersionsRes = results.listObjectVersions;
1377+
const { Versions } = listObjectVersionsRes;
1378+
1379+
assert.strictEqual(Versions.length, 2);
1380+
const [currentVersion, nonCurrentVersion] = Versions;
1381+
1382+
assert.strictEqual(currentVersion.VersionId, versionId);
1383+
assert.strictEqual(currentVersion.IsLatest, true);
1384+
1385+
assert.strictEqual(nonCurrentVersion.VersionId, 'null');
1386+
assert.strictEqual(nonCurrentVersion.IsLatest, false);
1387+
1388+
return done();
1389+
});
1390+
});
12781391

12791392
it(
12801393
'should replicate/put metadata to a destination that has a suspended null version with internal version',

0 commit comments

Comments
 (0)