Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0f44e4c

Browse files
committedFeb 17, 2025·
Remove count items dead code
- MongoClientInterface still implements some duplicate (and outdated) logic implemented by count items in s3utils. - Some dependency functions are removed, and tests cleaned accordingly. - Some functions were also wrong: checking the PENSIEVE collection to check for transient locations was relying on undefined field from a collection that is not used anymore in Zenko 2. The logic itself is only related to statistics, currently overwritten by the count-items implementation. - Transient locations are still supported as usual. Issue: ARSN-459
1 parent 6285cb7 commit 0f44e4c

File tree

3 files changed

+1
-867
lines changed

3 files changed

+1
-867
lines changed
 

‎lib/models/ObjectMDLocation.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export type Location = BaseLocation & {
66
dataStoreETag: string;
77
dataStoreVersionId: string;
88
blockId?: string;
9+
isTransient?: boolean;
910
};
1011
export type ObjectMDLocationData = {
1112
key: string;

‎lib/storage/metadata/mongoclient/MongoClientInterface.ts

-351
Original file line numberDiff line numberDiff line change
@@ -2481,31 +2481,6 @@ class MongoClientInterface {
24812481
});
24822482
}
24832483

2484-
updateCountItems(value: ObjectMDStats, log: werelogs.Logger, cb: ArsenalCallback<void>) {
2485-
const i = this.getCollection<InfostoreDocument>(INFOSTORE);
2486-
if (!i) {
2487-
log.error('updateCountItems: error getting infostore collection');
2488-
return cb(errors.InternalError);
2489-
}
2490-
2491-
return i.updateOne({
2492-
_id: __COUNT_ITEMS,
2493-
}, {
2494-
$set: {
2495-
_id: __COUNT_ITEMS,
2496-
value,
2497-
},
2498-
}, {
2499-
upsert: true,
2500-
}).then(() => cb(null))
2501-
.catch(err => {
2502-
log.error('updateCountItems: error updating count items', {
2503-
error: err.message,
2504-
});
2505-
return cb(errors.InternalError);
2506-
});
2507-
}
2508-
25092484
/*
25102485
* return true if it a special collection and therefore
25112486
* does not need to be collected for infos
@@ -2645,247 +2620,10 @@ class MongoClientInterface {
26452620
});
26462621
}
26472622

2648-
consolidateData(store, dataManaged) {
2649-
if (dataManaged && dataManaged.locations && dataManaged.total) {
2650-
const locations = dataManaged.locations;
2651-
store.dataManaged.total.curr += dataManaged.total.curr;
2652-
store.dataManaged.total.prev += dataManaged.total.prev;
2653-
Object.keys(locations).forEach(site => {
2654-
if (!store.dataManaged.byLocation[site]) {
2655-
store.dataManaged.byLocation[site] =
2656-
Object.assign({}, locations[site]);
2657-
} else {
2658-
store.dataManaged.byLocation[site].curr +=
2659-
locations[site].curr;
2660-
store.dataManaged.byLocation[site].prev +=
2661-
locations[site].prev;
2662-
}
2663-
});
2664-
}
2665-
}
2666-
2667-
scanItemCount(log, cb) {
2668-
const store = {
2669-
objects: 0,
2670-
versions: 0,
2671-
buckets: 0,
2672-
bucketList: <{
2673-
name: string;
2674-
location: string | null;
2675-
isVersioned: boolean;
2676-
ownerCanonicalId: string;
2677-
ingestion: boolean;
2678-
}[]>[],
2679-
dataManaged: {
2680-
total: { curr: 0, prev: 0 },
2681-
byLocation: {},
2682-
},
2683-
stalled: 0,
2684-
};
2685-
2686-
const consolidateData = dataManaged =>
2687-
this.consolidateData(store, dataManaged);
2688-
this.getBucketInfos(log, (err, res?) => {
2689-
if (err) {
2690-
log.error('error getting bucket info', {
2691-
method: 'scanItemCount',
2692-
error: err,
2693-
});
2694-
return cb(err);
2695-
}
2696-
const { bucketCount, bucketInfos } = res!;
2697-
const retBucketInfos = bucketInfos.map(bucket => ({
2698-
name: bucket.getName(),
2699-
location: bucket.getLocationConstraint(),
2700-
isVersioned: !!bucket.getVersioningConfiguration(),
2701-
ownerCanonicalId: bucket.getOwner(),
2702-
ingestion: bucket.isIngestionBucket(),
2703-
}));
2704-
2705-
store.buckets = bucketCount;
2706-
store.bucketList = retBucketInfos;
2707-
2708-
return async.eachLimit(bucketInfos, this.concurrentCursors,
2709-
(bucketInfo: BucketInfo, done) => {
2710-
async.waterfall([
2711-
next => this._getIsTransient(bucketInfo, log, next),
2712-
(isTransient, next) => {
2713-
const bucketName = bucketInfo.getName();
2714-
this.getObjectMDStats(bucketName, bucketInfo,
2715-
isTransient, log, next);
2716-
},
2717-
], (err, results: ObjectMDStats | undefined) => {
2718-
if (err) {
2719-
return done(err);
2720-
}
2721-
if (results!.dataManaged) {
2722-
store.objects += results!.objects;
2723-
store.versions += results!.versions;
2724-
store.stalled += results!.stalled;
2725-
consolidateData(results!.dataManaged);
2726-
}
2727-
return done();
2728-
});
2729-
}, err => {
2730-
if (err) {
2731-
return cb(err);
2732-
}
2733-
// save to infostore
2734-
return this.updateCountItems(store, log, err => {
2735-
if (err) {
2736-
log.error('error saving count items in mongo', {
2737-
method: 'scanItemCount',
2738-
error: err,
2739-
});
2740-
return cb(err);
2741-
}
2742-
return cb(null, store);
2743-
});
2744-
});
2745-
});
2746-
return undefined;
2747-
}
2748-
2749-
_getIsTransient(bucketInfo, log, cb) {
2750-
const locConstraint = bucketInfo.getLocationConstraint();
2751-
2752-
if (this.isLocationTransient) {
2753-
this.isLocationTransient(locConstraint, log, cb);
2754-
return;
2755-
}
2756-
this._pensieveLocationIsTransient(locConstraint, log, cb);
2757-
}
2758-
2759-
_pensieveLocationIsTransient(locConstraint, log, cb) {
2760-
const overlayVersionId = 'configuration/overlay-version';
2761-
2762-
async.waterfall([
2763-
next => this.getObject(PENSIEVE, overlayVersionId, null, log, next),
2764-
(version, next) => {
2765-
const overlayConfigId = `configuration/overlay/${version}`;
2766-
return this.getObject(PENSIEVE, overlayConfigId, null, log, next);
2767-
},
2768-
], (err, res: ObjectMDData | undefined) => {
2769-
if (err) {
2770-
log.error('error getting configuration overlay', {
2771-
method: '_getIsTransient',
2772-
error: err,
2773-
});
2774-
return cb(err);
2775-
}
2776-
const isTransient =
2777-
// TODO ARSN-459
2778-
// @ts-expect-error the locations type is not defined
2779-
// but is the historical check. Is this really needed?
2780-
Boolean(res.locations[locConstraint].isTransient);
2781-
2782-
return cb(null, isTransient);
2783-
});
2784-
}
2785-
27862623
_getLocName(loc) {
27872624
return loc === 'mem' || loc === 'file' ? 'us-east-1' : loc;
27882625
}
27892626

2790-
_handleResults(res, isVersioned) {
2791-
const total = { curr: 0, prev: 0 };
2792-
const locations = {};
2793-
2794-
Object.keys(res.nullData).forEach(loc => {
2795-
const bytes = res.nullData[loc];
2796-
const locName = this._getLocName(loc);
2797-
if (!locations[locName]) {
2798-
locations[locName] = { curr: 0, prev: 0 };
2799-
}
2800-
total.curr += bytes;
2801-
locations[locName].curr += bytes;
2802-
});
2803-
if (isVersioned) {
2804-
Object.keys(res.versionData).forEach(loc => {
2805-
const bytes = res.versionData[loc];
2806-
const locName = this._getLocName(loc);
2807-
if (!locations[locName]) {
2808-
locations[locName] = { curr: 0, prev: 0 };
2809-
}
2810-
total.prev += bytes;
2811-
locations[locName].prev += bytes;
2812-
});
2813-
}
2814-
Object.keys(res.masterData).forEach(loc => {
2815-
const bytes = res.masterData[loc];
2816-
const locName = this._getLocName(loc);
2817-
if (!locations[locName]) {
2818-
locations[locName] = { curr: 0, prev: 0 };
2819-
}
2820-
total.curr += bytes;
2821-
locations[locName].curr += bytes;
2822-
if (isVersioned) {
2823-
total.prev -= bytes;
2824-
total.prev = Math.max(0, total.prev);
2825-
locations[locName].prev -= bytes;
2826-
locations[locName].prev =
2827-
Math.max(0, locations[locName].prev);
2828-
}
2829-
});
2830-
let versionCount = isVersioned ?
2831-
res.versionCount - res.masterCount : 0;
2832-
versionCount = Math.max(0, versionCount);
2833-
return {
2834-
versions: versionCount,
2835-
objects: res.masterCount + res.nullCount,
2836-
dataManaged: {
2837-
total,
2838-
locations,
2839-
},
2840-
stalled: 0,
2841-
};
2842-
}
2843-
2844-
/**
2845-
* @param{object} entry -
2846-
* @param{string} entry._id -
2847-
* @param{object} entry.value -
2848-
* @param{boolean} isTransient -
2849-
* @returns{object.<string, number>} results -
2850-
*/
2851-
_processEntryData(entry, isTransient) {
2852-
const results = {};
2853-
2854-
const size = Number.parseInt(entry.value['content-length'], 10);
2855-
if (Number.isNaN(size)) {
2856-
return {
2857-
data: {},
2858-
error: new Error('invalid content length'),
2859-
};
2860-
}
2861-
2862-
if (!isTransient ||
2863-
entry.value.replicationInfo.status !== 'COMPLETED') {
2864-
if (results[entry.value.dataStoreName]) {
2865-
results[entry.value.dataStoreName] += size;
2866-
} else {
2867-
results[entry.value.dataStoreName] = size;
2868-
}
2869-
} else {
2870-
if (!results[entry.value.dataStoreName]) {
2871-
results[entry.value.dataStoreName] = 0;
2872-
}
2873-
}
2874-
entry.value.replicationInfo.backends.forEach(rep => {
2875-
if (rep.status === 'COMPLETED') {
2876-
if (results[rep.site]) {
2877-
results[rep.site] += size;
2878-
} else {
2879-
results[rep.site] = size;
2880-
}
2881-
}
2882-
});
2883-
return {
2884-
data: results,
2885-
error: null,
2886-
};
2887-
}
2888-
28892627
/**
28902628
* @param{object} entry -
28912629
* @param{string} entry._id -
@@ -2904,95 +2642,6 @@ class MongoClientInterface {
29042642
return true;
29052643
}
29062644

2907-
/*
2908-
* scan and process a single collection (bucket)
2909-
*/
2910-
getObjectMDStats(
2911-
bucketName: string,
2912-
bucketInfo: BucketInfo,
2913-
isTransient: boolean,
2914-
log: werelogs.Logger,
2915-
callback: ArsenalCallback<ObjectMDStats>) {
2916-
const c = this.getCollection<ObjectMetastoreDocument>(bucketName);
2917-
const cursor = c.find({}, {
2918-
projection: {
2919-
'_id': 1,
2920-
'value.last-modified': 1,
2921-
'value.replicationInfo': 1,
2922-
'value.dataStoreName': 1,
2923-
'value.content-length': 1,
2924-
'value.versionId': 1,
2925-
},
2926-
});
2927-
const collRes = {
2928-
masterCount: 0,
2929-
masterData: {},
2930-
nullCount: 0,
2931-
nullData: {},
2932-
versionCount: 0,
2933-
versionData: {},
2934-
};
2935-
let stalledCount = 0;
2936-
const cmpDate = new Date();
2937-
cmpDate.setHours(cmpDate.getHours() - 1);
2938-
2939-
cursor.forEach(
2940-
res => {
2941-
const { data, error } = this._processEntryData(res, isTransient);
2942-
if (error) {
2943-
log.error('Failed to process entry data', {
2944-
method: 'getObjectMDStats',
2945-
entry: res,
2946-
error,
2947-
});
2948-
}
2949-
2950-
let targetCount;
2951-
let targetData;
2952-
if (res._id.indexOf('\0') !== -1) {
2953-
// versioned item
2954-
targetCount = 'versionCount';
2955-
targetData = 'versionData';
2956-
2957-
if (res.value.replicationInfo.backends.length > 0 &&
2958-
this._isReplicationEntryStalled(res, cmpDate)) {
2959-
stalledCount++;
2960-
}
2961-
} else if (res.value.versionId) {
2962-
// master version
2963-
targetCount = 'masterCount';
2964-
targetData = 'masterData';
2965-
} else {
2966-
// null version
2967-
targetCount = 'nullCount';
2968-
targetData = 'nullData';
2969-
}
2970-
collRes[targetCount]++;
2971-
Object.keys(data).forEach(site => {
2972-
if (collRes[targetData][site]) {
2973-
collRes[targetData][site] += data[site];
2974-
} else {
2975-
collRes[targetData][site] = data[site];
2976-
}
2977-
});
2978-
})
2979-
.then(() => {
2980-
const bucketStatus = bucketInfo.getVersioningConfiguration();
2981-
const isVer = (bucketStatus &&
2982-
(bucketStatus.Status === 'Enabled' ||
2983-
bucketStatus.Status === 'Suspended'));
2984-
const retResult = this._handleResults(collRes, isVer);
2985-
retResult.stalled = stalledCount;
2986-
return callback(null, retResult);
2987-
}).catch(err => {
2988-
log.error('Error when processing mongo entries', {
2989-
method: 'getObjectMDStats',
2990-
error: err,
2991-
});
2992-
return callback(err);
2993-
});
2994-
}
2995-
29962645
getIngestionBuckets(log: werelogs.Logger, cb: ArsenalCallback<BucketInfo[]>) {
29972646
const m = this.getCollection<BucketMetastoreDocument>(METASTORE);
29982647
m.find({

‎tests/unit/storage/metadata/mongoclient/MongoClientInterface.spec.js

-516
Original file line numberDiff line numberDiff line change
@@ -31,71 +31,6 @@ const DummyConfigObject = require('./utils/DummyConfigObject');
3131

3232
const mongoTestClient = new MongoClientInterface({});
3333

34-
describe('MongoClientInterface::_handleResults', () => {
35-
it('should return zero-result', () => {
36-
const testInput = {
37-
masterCount: 0, masterData: {},
38-
nullCount: 0, nullData: {},
39-
versionCount: 0, versionData: {},
40-
};
41-
const testResults = mongoTestClient._handleResults(testInput, true);
42-
const expectedRes = {
43-
versions: 0,
44-
objects: 0,
45-
stalled: 0,
46-
dataManaged: {
47-
total: { curr: 0, prev: 0 },
48-
locations: {},
49-
},
50-
};
51-
assert.deepStrictEqual(testResults, expectedRes);
52-
});
53-
54-
it('should return correct value if isVer is false', () => {
55-
const testInput = {
56-
masterCount: 2, masterData: { test1: 10, test2: 10 },
57-
nullCount: 2, nullData: { test1: 10, test2: 10 },
58-
versionCount: 2, versionData: { test1: 20, test2: 20 },
59-
};
60-
const testResults = mongoTestClient._handleResults(testInput, false);
61-
const expectedRes = {
62-
versions: 0,
63-
objects: 4,
64-
stalled: 0,
65-
dataManaged: {
66-
total: { curr: 40, prev: 0 },
67-
locations: {
68-
test1: { curr: 20, prev: 0 },
69-
test2: { curr: 20, prev: 0 },
70-
},
71-
},
72-
};
73-
assert.deepStrictEqual(testResults, expectedRes);
74-
});
75-
76-
it('should return correct value if isVer is true', () => {
77-
const testInput = {
78-
masterCount: 2, masterData: { test1: 10, test2: 10 },
79-
nullCount: 2, nullData: { test1: 10, test2: 10 },
80-
versionCount: 4, versionData: { test1: 20, test2: 20 },
81-
};
82-
const testResults = mongoTestClient._handleResults(testInput, true);
83-
const expectedRes = {
84-
versions: 2,
85-
objects: 4,
86-
stalled: 0,
87-
dataManaged: {
88-
total: { curr: 40, prev: 20 },
89-
locations: {
90-
test1: { curr: 20, prev: 10 },
91-
test2: { curr: 20, prev: 10 },
92-
},
93-
},
94-
};
95-
assert.deepStrictEqual(testResults, expectedRes);
96-
});
97-
});
98-
9934
describe('MongoClientInterface, misc', () => {
10035
let s3ConfigObj;
10136

@@ -110,305 +45,6 @@ describe('MongoClientInterface, misc', () => {
11045
});
11146
});
11247

113-
describe('MongoClientInterface::_processEntryData', () => {
114-
const tests = [
115-
[
116-
'should add content-length to total if replication status != ' +
117-
'COMPLETED and transient == true',
118-
true,
119-
{
120-
_id: 'testkey',
121-
value: {
122-
'last-modified': new Date(),
123-
'replicationInfo': {
124-
status: 'PENDING',
125-
backends: [],
126-
content: [],
127-
destination: '',
128-
storageClass: '',
129-
role: '',
130-
storageType: '',
131-
dataStoreVersionId: '',
132-
isNFS: null,
133-
},
134-
'dataStoreName': 'us-east-1',
135-
'content-length': 42,
136-
'versionId': '0123456789abcdefg',
137-
},
138-
},
139-
{
140-
data: {
141-
'us-east-1': 42,
142-
},
143-
error: null,
144-
},
145-
],
146-
[
147-
'should not add content-length to total if replication ' +
148-
'status == COMPLETED and transient == true',
149-
true,
150-
{
151-
_id: 'testkey',
152-
value: {
153-
'last-modified': new Date(),
154-
'replicationInfo': {
155-
status: 'COMPLETED',
156-
backends: [],
157-
content: [],
158-
destination: '',
159-
storageClass: '',
160-
role: '',
161-
storageType: '',
162-
dataStoreVersionId: '',
163-
isNFS: null,
164-
},
165-
'dataStoreName': 'us-east-1',
166-
'content-length': 42,
167-
'versionId': '0123456789abcdefg',
168-
},
169-
},
170-
{
171-
data: {
172-
'us-east-1': 0,
173-
},
174-
error: null,
175-
},
176-
],
177-
[
178-
'should add content-length to total if replication status != ' +
179-
'COMPLETED and transient == false',
180-
false,
181-
{
182-
_id: 'testkey',
183-
value: {
184-
'last-modified': new Date(),
185-
'replicationInfo': {
186-
status: 'PENDING',
187-
backends: [],
188-
content: [],
189-
destination: '',
190-
storageClass: '',
191-
role: '',
192-
storageType: '',
193-
dataStoreVersionId: '',
194-
isNFS: null,
195-
},
196-
'dataStoreName': 'us-east-1',
197-
'content-length': 42,
198-
'versionId': '0123456789abcdefg',
199-
},
200-
},
201-
{
202-
data: {
203-
'us-east-1': 42,
204-
},
205-
error: null,
206-
},
207-
],
208-
[
209-
'should add content-length to total if replication ' +
210-
'status == COMPLETED and transient == false',
211-
false,
212-
{
213-
_id: 'testkey',
214-
value: {
215-
'last-modified': new Date(),
216-
'replicationInfo': {
217-
status: 'COMPLETED',
218-
backends: [],
219-
content: [],
220-
destination: '',
221-
storageClass: '',
222-
role: '',
223-
storageType: '',
224-
dataStoreVersionId: '',
225-
isNFS: null,
226-
},
227-
'dataStoreName': 'us-east-1',
228-
'content-length': 42,
229-
'versionId': '0123456789abcdefg',
230-
},
231-
},
232-
{
233-
data: {
234-
'us-east-1': 42,
235-
},
236-
error: null,
237-
},
238-
],
239-
[
240-
'should add content-length to total for each COMPLETED backends ' +
241-
'(replication status: COMPLETED)',
242-
true,
243-
{
244-
_id: 'testkey',
245-
value: {
246-
'last-modified': new Date(),
247-
'replicationInfo': {
248-
status: 'COMPLETED',
249-
backends: [
250-
{
251-
status: 'COMPLETED',
252-
site: 'completed-1',
253-
},
254-
{
255-
status: 'COMPLETED',
256-
site: 'completed-2',
257-
},
258-
{
259-
status: 'COMPLETED',
260-
site: 'completed-3',
261-
},
262-
],
263-
content: [],
264-
destination: '',
265-
storageClass: '',
266-
role: '',
267-
storageType: '',
268-
dataStoreVersionId: '',
269-
isNFS: null,
270-
},
271-
'dataStoreName': 'us-east-1',
272-
'content-length': 42,
273-
'versionId': '0123456789abcdefg',
274-
},
275-
},
276-
{
277-
data: {
278-
'us-east-1': 0,
279-
'completed-1': 42,
280-
'completed-2': 42,
281-
'completed-3': 42,
282-
},
283-
error: null,
284-
},
285-
],
286-
[
287-
'should add content-length to total for each COMPLETED backends ' +
288-
'(replication status: PENDING)',
289-
true,
290-
{
291-
_id: 'testkey',
292-
value: {
293-
'last-modified': new Date(),
294-
'replicationInfo': {
295-
status: 'PENDING',
296-
backends: [
297-
{
298-
status: 'PENDING',
299-
site: 'not-completed',
300-
},
301-
{
302-
status: 'COMPLETED',
303-
site: 'completed-1',
304-
},
305-
{
306-
status: 'COMPLETED',
307-
site: 'completed-2',
308-
},
309-
],
310-
content: [],
311-
destination: '',
312-
storageClass: '',
313-
role: '',
314-
storageType: '',
315-
dataStoreVersionId: '',
316-
isNFS: null,
317-
},
318-
'dataStoreName': 'us-east-1',
319-
'content-length': 42,
320-
'versionId': '0123456789abcdefg',
321-
},
322-
},
323-
{
324-
data: {
325-
'us-east-1': 42,
326-
'completed-1': 42,
327-
'completed-2': 42,
328-
},
329-
error: null,
330-
},
331-
],
332-
[
333-
'should error if content-length is invalid',
334-
true,
335-
{
336-
_id: 'testkey',
337-
value: {
338-
'last-modified': new Date(),
339-
'replicationInfo': {
340-
status: 'PENDING',
341-
backends: [
342-
{
343-
status: 'PENDING',
344-
site: 'not-completed',
345-
},
346-
{
347-
status: 'COMPLETED',
348-
site: 'completed-1',
349-
},
350-
{
351-
status: 'COMPLETED',
352-
site: 'completed-2',
353-
},
354-
],
355-
content: [],
356-
destination: '',
357-
storageClass: '',
358-
role: '',
359-
storageType: '',
360-
dataStoreVersionId: '',
361-
isNFS: null,
362-
},
363-
'dataStoreName': 'us-east-1',
364-
'content-length': 'not-a-number',
365-
'versionId': '0123456789abcdefg',
366-
},
367-
},
368-
{
369-
data: {},
370-
error: new Error('invalid content length'),
371-
},
372-
],
373-
[
374-
'should correctly process entry with string typed content-length',
375-
true,
376-
{
377-
_id: 'testkey',
378-
value: {
379-
'last-modified': new Date(),
380-
'replicationInfo': {
381-
status: 'PENDING',
382-
backends: [],
383-
content: [],
384-
destination: '',
385-
storageClass: '',
386-
role: '',
387-
storageType: '',
388-
dataStoreVersionId: '',
389-
isNFS: null,
390-
},
391-
'dataStoreName': 'us-east-1',
392-
'content-length': '42',
393-
'versionId': '0123456789abcdefg',
394-
},
395-
},
396-
{
397-
data: {
398-
'us-east-1': 42,
399-
},
400-
error: null,
401-
},
402-
],
403-
];
404-
tests.forEach(([msg, isTransient, params, expected]) => it(msg, () => {
405-
assert.deepStrictEqual(
406-
mongoTestClient._processEntryData(params, isTransient),
407-
expected,
408-
);
409-
}));
410-
});
411-
41248
describe('MongoClientInterface::_isReplicationEntryStalled', () => {
41349
const hr = 1000 * 60 * 60;
41450
const testDate = new Date();
@@ -545,25 +181,7 @@ function createBucket(client, bucketName, isVersioned, callback) {
545181
client.createBucket(bucketName, bucketMD, logger, callback);
546182
}
547183

548-
function uploadObjects(client, bucketName, objectList, callback) {
549-
async.eachSeries(objectList, (obj, done) => {
550-
const objMD = new ObjectMD()
551-
.setKey(obj.name)
552-
.setDataStoreName('us-east-1')
553-
.setContentLength(100)
554-
.setLastModified(obj.lastModified);
555-
if (obj.repInfo) {
556-
objMD.setReplicationInfo(obj.repInfo);
557-
}
558-
client.putObject(bucketName, obj.name, objMD.getValue(), {
559-
versionId: obj.versionId,
560-
versioning: obj.versioning,
561-
}, logger, done);
562-
}, callback);
563-
}
564-
565184
describe('MongoClientInterface, tests', () => {
566-
const hr = 1000 * 60 * 60;
567185
let client;
568186
beforeAll(done => {
569187
mongoserver.start().then(() => {
@@ -592,140 +210,6 @@ describe('MongoClientInterface, tests', () => {
592210
], done);
593211
});
594212

595-
const tests = [
596-
[
597-
'getObjectMDStats() should return correct results',
598-
{
599-
bucketName: 'test-bucket',
600-
isVersioned: true,
601-
objectList: [
602-
// versioned object 1,
603-
{
604-
name: 'testkey',
605-
versioning: true,
606-
versionId: null,
607-
lastModified: new Date(Date.now()),
608-
repInfo: {
609-
status: 'COMPLETED',
610-
backends: [
611-
{
612-
status: 'COMPLETED',
613-
site: 'rep-loc-1',
614-
},
615-
],
616-
content: [],
617-
destination: '',
618-
storageClass: '',
619-
role: '',
620-
storageType: '',
621-
dataStoreVersionId: '',
622-
isNFS: null,
623-
},
624-
},
625-
// versioned object 2,
626-
{
627-
name: 'testkey',
628-
versioning: true,
629-
versionId: null,
630-
lastModified: new Date(Date.now()),
631-
repInfo: {
632-
status: 'COMPLETED',
633-
backends: [
634-
{
635-
status: 'COMPLETED',
636-
site: 'rep-loc-1',
637-
},
638-
],
639-
content: [],
640-
destination: '',
641-
storageClass: '',
642-
role: '',
643-
storageType: '',
644-
dataStoreVersionId: '',
645-
isNFS: null,
646-
},
647-
},
648-
// stalled object 1
649-
{
650-
name: 'testkey',
651-
versioning: true,
652-
versionId: null,
653-
lastModified: new Date(Date.now() - hr),
654-
repInfo: {
655-
status: 'PENDING',
656-
backends: [
657-
{
658-
status: 'PENDING',
659-
site: 'rep-loc-1',
660-
},
661-
],
662-
content: [],
663-
destination: '',
664-
storageClass: '',
665-
role: '',
666-
storageType: '',
667-
dataStoreVersionId: '',
668-
isNFS: null,
669-
},
670-
},
671-
// null versioned object
672-
{
673-
name: 'nullkey',
674-
lastModified: new Date(Date.now() - hr),
675-
},
676-
],
677-
},
678-
{
679-
dataManaged: {
680-
locations: {
681-
'rep-loc-1': {
682-
curr: 0,
683-
prev: 200,
684-
},
685-
'us-east-1': {
686-
curr: 200,
687-
prev: 200,
688-
},
689-
},
690-
total: {
691-
curr: 200,
692-
prev: 400,
693-
},
694-
},
695-
objects: 2,
696-
stalled: 1,
697-
versions: 2,
698-
},
699-
],
700-
];
701-
tests.forEach(([msg, testCase, expected]) => it.skip(msg, done => {
702-
const {
703-
bucketName,
704-
isVersioned,
705-
objectList,
706-
} = testCase;
707-
async.waterfall([
708-
next => createBucket(
709-
client, bucketName, isVersioned, err => next(err)),
710-
next => uploadObjects(
711-
client, bucketName, objectList, err => next(err)),
712-
next => client.getBucketAttributes(bucketName, logger, next),
713-
(bucketInfo, next) => client.getObjectMDStats(
714-
bucketName,
715-
BucketInfo.fromObj(bucketInfo),
716-
false,
717-
logger,
718-
(err, res) => {
719-
if (err) {
720-
return next(err);
721-
}
722-
assert.deepStrictEqual(res, expected);
723-
return next();
724-
}),
725-
next => client.deleteBucket(bucketName, logger, next),
726-
], done);
727-
}));
728-
729213
it('shall encode/decode tags properly', done => {
730214
const bucketName = 'foo';
731215
const objectName = 'bar';

0 commit comments

Comments
 (0)
Please sign in to comment.