Skip to content

Commit 6d97621

Browse files
committed
fixup on test
1 parent 58f8c81 commit 6d97621

File tree

1 file changed

+92
-201
lines changed

1 file changed

+92
-201
lines changed

tests/multipleBackend/routes/routeBackbeatForReplication.js

Lines changed: 92 additions & 201 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,210 +1180,101 @@ describe(`backbeat routes for replication (${name})`, () => {
11801180
});
11811181

11821182
it('should replicate/put metadata to a destination that has a suspended null version', done => {
1183-
let objMD;
1184-
let versionId;
1185-
1186-
async.series({
1187-
suspendVersioningDestination: next => dstS3.send(new PutBucketVersioningCommand({
1188-
Bucket: bucketDestination,
1189-
VersioningConfiguration: { Status: 'Suspended' }
1190-
})).then(data => next(null, data)).catch(err => next(err)),
1191-
1192-
putObjectDestinationInitial: next => dstS3.send(new PutObjectCommand({
1193-
Bucket: bucketDestination,
1194-
Key: keyName,
1195-
Body: Buffer.from(testData)
1196-
})).then(data => next(null, data)).catch(err => next(err)),
1197-
1198-
enableVersioningSource: next => srcS3.send(new PutBucketVersioningCommand({
1199-
Bucket: bucketSource,
1200-
VersioningConfiguration: { Status: 'Enabled' }
1201-
})).then(data => next(null, data)).catch(err => next(err)),
1202-
1203-
putObjectSource: next => srcS3.send(new PutObjectCommand({
1204-
Bucket: bucketSource,
1205-
Key: keyName,
1206-
Body: Buffer.from(testData)
1207-
})).then(data => {
1208-
versionId = data.VersionId;
1209-
return next(null, data);
1210-
}).catch(err => next(err)),
1211-
1212-
getMetadata: next => makeBackbeatRequest({
1213-
method: 'GET',
1214-
resourceType: 'metadata',
1215-
bucket: bucketSource,
1216-
objectKey: keyName,
1217-
queryObj: {
1218-
versionId,
1219-
},
1220-
authCredentials: sourceAuthCredentials,
1221-
}, (err, data) => {
1222-
if (err) {
1223-
return next(err);
1224-
}
1225-
objMD = objectMDWithUpdatedAccountInfo(data, src === dst ? null : dstAccountInfo);
1226-
return next();
1227-
}),
1228-
replicateMetadata: next => makeBackbeatRequest({
1229-
method: 'PUT',
1230-
resourceType: 'metadata',
1231-
bucket: bucketDestination,
1232-
objectKey: keyName,
1233-
queryObj: {
1234-
versionId,
1235-
},
1236-
authCredentials: destinationAuthCredentials,
1237-
requestBody: objMD,
1238-
}, next),
1239-
headObjectNullVersion: next => dstS3.send(new HeadObjectCommand({
1240-
Bucket: bucketDestination,
1241-
Key: keyName,
1242-
VersionId: 'null'
1243-
})).then(data => next(null, data)).catch(err => next(err)),
1244-
listObjectVersions: next => dstS3.send(new ListObjectVersionsCommand({
1245-
Bucket: bucketDestination
1246-
})).then(data => next(null, data)).catch(err => next(err)),
1247-
}, (err, results) => {
1248-
if (err) {
1249-
return done(err);
1250-
}
1251-
1252-
const headObjectRes = results.headObjectNullVersion;
1253-
assert.strictEqual(headObjectRes.VersionId, 'null');
1254-
1255-
const listObjectVersionsRes = results.listObjectVersions;
1256-
const { Versions } = listObjectVersionsRes;
1257-
1258-
assert.strictEqual(Versions.length, 2);
1259-
const [currentVersion, nonCurrentVersion] = Versions;
1260-
1261-
assert.strictEqual(currentVersion.VersionId, versionId);
1262-
assert.strictEqual(currentVersion.IsLatest, true);
1263-
1264-
assert.strictEqual(nonCurrentVersion.VersionId, 'null');
1265-
assert.strictEqual(nonCurrentVersion.IsLatest, false);
1266-
1267-
return done();
1268-
});
1269-
});
1270-
1271-
it('should replicate/put metadata to a destination that has a previously updated null version', done => {
1272-
let objMD;
1273-
let objMDNull;
1274-
let versionId;
1275-
1276-
async.series({
1277-
putObjectDestinationInitial: next => dstS3.send(new PutObjectCommand({
1278-
Bucket: bucketDestination,
1279-
Key: keyName,
1280-
Body: Buffer.from(testData)
1281-
})).then(data => next(null, data)).catch(err => next(err)),
1282-
1283-
enableVersioningDestination: next => dstS3.send(new PutBucketVersioningCommand({
1284-
Bucket: bucketDestination,
1285-
VersioningConfiguration: { Status: 'Enabled' }
1286-
})).then(data => next(null, data)).catch(err => next(err)),
1287-
1288-
getMetadataNullVersion: next => makeBackbeatRequest({
1289-
method: 'GET',
1290-
resourceType: 'metadata',
1291-
bucket: bucketDestination,
1292-
objectKey: keyName,
1293-
queryObj: {
1294-
versionId: 'null',
1295-
},
1296-
authCredentials: destinationAuthCredentials,
1297-
}, (err, data) => {
1298-
if (err) {
1299-
return next(err);
1300-
}
1301-
objMDNull = JSON.parse(data.body).Body;
1302-
return next();
1303-
}),
1304-
updateMetadataNullVersion: next => makeBackbeatRequest({
1305-
method: 'PUT',
1306-
resourceType: 'metadata',
1307-
bucket: bucketDestination,
1308-
objectKey: keyName,
1309-
queryObj: {
1310-
versionId: 'null',
1311-
},
1312-
authCredentials: destinationAuthCredentials,
1313-
requestBody: objMDNull,
1314-
}, next),
1315-
enableVersioningSource: next => srcS3.send(new PutBucketVersioningCommand({
1316-
Bucket: bucketSource,
1317-
VersioningConfiguration: { Status: 'Enabled' }
1318-
})).then(data => next(null, data)).catch(err => next(err)),
1319-
1320-
putObjectSource: next => srcS3.send(new PutObjectCommand({
1321-
Bucket: bucketSource,
1322-
Key: keyName,
1323-
Body: Buffer.from(testData)
1324-
})).then(data => {
1325-
versionId = data.VersionId;
1326-
return next(null, data);
1327-
}).catch(err => next(err)),
1328-
1329-
getMetadata: next => makeBackbeatRequest({
1330-
method: 'GET',
1331-
resourceType: 'metadata',
1332-
bucket: bucketSource,
1333-
objectKey: keyName,
1334-
queryObj: {
1335-
versionId,
1336-
},
1337-
authCredentials: sourceAuthCredentials,
1338-
}, (err, data) => {
1339-
if (err) {
1340-
return next(err);
1341-
}
1342-
objMD = objectMDWithUpdatedAccountInfo(data, src === dst ? null : dstAccountInfo);
1343-
return next();
1344-
}),
1345-
replicateMetadata: next => makeBackbeatRequest({
1346-
method: 'PUT',
1347-
resourceType: 'metadata',
1348-
bucket: bucketDestination,
1349-
objectKey: keyName,
1350-
queryObj: {
1351-
versionId,
1352-
},
1353-
authCredentials: destinationAuthCredentials,
1354-
requestBody: objMD,
1355-
}, next),
1356-
headObjectNullVersion: next => dstS3.send(new HeadObjectCommand({
1357-
Bucket: bucketDestination,
1358-
Key: keyName,
1359-
VersionId: 'null'
1360-
})).then(data => next(null, data)).catch(err => next(err)),
1361-
listObjectVersions: next => dstS3.send(new ListObjectVersionsCommand({
1362-
Bucket: bucketDestination
1363-
})).then(data => next(null, data)).catch(err => next(err)),
1364-
}, (err, results) => {
1183+
let objMD;
1184+
let versionId;
1185+
1186+
async.series({
1187+
suspendVersioningDestination: next => dstS3.send(new PutBucketVersioningCommand({
1188+
Bucket: bucketDestination,
1189+
VersioningConfiguration: { Status: 'Suspended' }
1190+
})).then(data => next(null, data)).catch(err => next(err)),
1191+
1192+
putObjectDestinationInitial: next => dstS3.send(new PutObjectCommand({
1193+
Bucket: bucketDestination,
1194+
Key: keyName,
1195+
Body: Buffer.from(testData)
1196+
})).then(data => next(null, data)).catch(err => next(err)),
1197+
1198+
enableVersioningDestination: next => dstS3.send(new PutBucketVersioningCommand({
1199+
Bucket: bucketDestination,
1200+
VersioningConfiguration: { Status: 'Enabled' }
1201+
})).then(data => next(null, data)).catch(err => next(err)),
1202+
1203+
enableVersioningSource: next => srcS3.send(new PutBucketVersioningCommand({
1204+
Bucket: bucketSource,
1205+
VersioningConfiguration: { Status: 'Enabled' }
1206+
})).then(data => next(null, data)).catch(err => next(err)),
1207+
1208+
putObjectSource: next => srcS3.send(new PutObjectCommand({
1209+
Bucket: bucketSource,
1210+
Key: keyName,
1211+
Body: Buffer.from(testData)
1212+
})).then(data => {
1213+
versionId = data.VersionId;
1214+
return next(null, data);
1215+
}).catch(err => next(err)),
1216+
1217+
getMetadata: next => makeBackbeatRequest({
1218+
method: 'GET',
1219+
resourceType: 'metadata',
1220+
bucket: bucketSource,
1221+
objectKey: keyName,
1222+
queryObj: {
1223+
versionId,
1224+
},
1225+
authCredentials: sourceAuthCredentials,
1226+
}, (err, data) => {
13651227
if (err) {
1366-
return done(err);
1228+
return next(err);
13671229
}
1368-
1369-
const headObjectRes = results.headObjectNullVersion;
1370-
assert.strictEqual(headObjectRes.VersionId, 'null');
1371-
1372-
const listObjectVersionsRes = results.listObjectVersions;
1373-
const { Versions } = listObjectVersionsRes;
1374-
1375-
assert.strictEqual(Versions.length, 2);
1376-
const [currentVersion, nonCurrentVersion] = Versions;
1377-
1378-
assert.strictEqual(currentVersion.VersionId, versionId);
1379-
assert.strictEqual(currentVersion.IsLatest, true);
1380-
1381-
assert.strictEqual(nonCurrentVersion.VersionId, 'null');
1382-
assert.strictEqual(nonCurrentVersion.IsLatest, false);
1383-
1384-
return done();
1385-
});
1230+
objMD = objectMDWithUpdatedAccountInfo(data, src === dst ? null : dstAccountInfo);
1231+
return next();
1232+
}),
1233+
1234+
replicateMetadata: next => makeBackbeatRequest({
1235+
method: 'PUT',
1236+
resourceType: 'metadata',
1237+
bucket: bucketDestination,
1238+
objectKey: keyName,
1239+
queryObj: {
1240+
versionId,
1241+
},
1242+
authCredentials: destinationAuthCredentials,
1243+
requestBody: objMD,
1244+
}, next),
1245+
1246+
headObjectNullVersion: next => dstS3.send(new HeadObjectCommand({
1247+
Bucket: bucketDestination,
1248+
Key: keyName,
1249+
VersionId: 'null'
1250+
})).then(data => next(null, data)).catch(err => next(err)),
1251+
1252+
listObjectVersions: next => dstS3.send(new ListObjectVersionsCommand({
1253+
Bucket: bucketDestination
1254+
})).then(data => next(null, data)).catch(err => next(err)),
1255+
}, (err, results) => {
1256+
if (err) {
1257+
return done(err);
1258+
}
1259+
1260+
const headObjectRes = results.headObjectNullVersion;
1261+
assert.strictEqual(headObjectRes.VersionId, 'null');
1262+
1263+
const listObjectVersionsRes = results.listObjectVersions;
1264+
const { Versions } = listObjectVersionsRes;
1265+
1266+
assert.strictEqual(Versions.length, 2);
1267+
const [currentVersion, nonCurrentVersion] = Versions;
1268+
1269+
assert.strictEqual(currentVersion.VersionId, versionId);
1270+
assert.strictEqual(currentVersion.IsLatest, true);
1271+
1272+
assert.strictEqual(nonCurrentVersion.VersionId, 'null');
1273+
assert.strictEqual(nonCurrentVersion.IsLatest, false);
1274+
1275+
return done();
13861276
});
1277+
});
13871278

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

0 commit comments

Comments
 (0)