Compare commits

..

No commits in common. "900ff95f595a40e5e9ee6a2e1d2d23a585405ec9" and "11868de36722816462b7d94fb958c173d54cdecd" have entirely different histories.

6 changed files with 6 additions and 33 deletions

View File

@ -99,9 +99,6 @@ const constants = {
migrationOpTranslationMap: { migrationOpTranslationMap: {
listBucketMultipartUploads: 'listMultipartUploads', listBucketMultipartUploads: 'listMultipartUploads',
}, },
ingestionOpTranslationMap: {
putDeleteMarkerObject: 'deleteObject',
},
expirationChunkDuration: 900000000, // 15 minutes in microseconds expirationChunkDuration: 900000000, // 15 minutes in microseconds
}; };

View File

@ -2,7 +2,6 @@ const errors = require('../../../errors');
const { UtapiMetric } = require('../../../models'); const { UtapiMetric } = require('../../../models');
const { client: cacheClient } = require('../../../cache'); const { client: cacheClient } = require('../../../cache');
const { convertTimestamp } = require('../../../utils'); const { convertTimestamp } = require('../../../utils');
const { ingestionOpTranslationMap } = require('../../../constants');
async function ingestMetric(ctx, params) { async function ingestMetric(ctx, params) {
let metrics; let metrics;
@ -10,7 +9,6 @@ async function ingestMetric(ctx, params) {
metrics = params.body.map(m => new UtapiMetric({ metrics = params.body.map(m => new UtapiMetric({
...m, ...m,
timestamp: convertTimestamp(m.timestamp), timestamp: convertTimestamp(m.timestamp),
operationId: ingestionOpTranslationMap[m.operationId] || m.operationId,
})); }));
} catch (error) { } catch (error) {
throw errors.InvalidRequest; throw errors.InvalidRequest;

View File

@ -76,8 +76,10 @@ function errorMiddleware(err, req, res, next) {
} }
res.status(code).send({ res.status(code).send({
error: {
code: code.toString(), code: code.toString(),
message, message,
},
}); });
responseLoggerMiddleware(req, res); responseLoggerMiddleware(req, res);
} }

View File

@ -30,15 +30,10 @@ const emptyOperationsResponse = Object.values(operationToResponse)
async function listMetrics(level, resources, start, end, force403 = false) { async function listMetrics(level, resources, start, end, force403 = false) {
const body = { const body = {
timeRange: [start, end],
[level]: resources, [level]: resources,
}; };
if (end !== undefined) {
body.timeRange = [start, end];
} else {
body.timeRange = [start];
}
const headers = { const headers = {
host: 'localhost', host: 'localhost',
port: 8100, port: 8100,
@ -212,9 +207,4 @@ describe('Test listMetric', function () {
const resp = await listMetrics('buckets', ['test'], getTs(-1), getTs(1), true); const resp = await listMetrics('buckets', ['test'], getTs(-1), getTs(1), true);
assert.strictEqual(resp.statusCode, 403); assert.strictEqual(resp.statusCode, 403);
}); });
it('should use the current timestamp for "end" if it is not provided', async () => {
const resp = await listMetrics('buckets', ['test'], getTs(-1));
assert.strictEqual(resp.timeRange.length, 2);
});
}); });

View File

@ -43,19 +43,4 @@ describe('Test ingestMetric', () => {
err => err.code === 503 && err.ServiceUnavailable, err => err.code === 503 && err.ServiceUnavailable,
); );
}); });
it('should translate putDeleteMarkerObject to deleteObject', async () => {
const spy = sinon.spy(cacheClient, 'pushMetric');
const metric = new UtapiMetric({
operationId: 'putDeleteMarkerObject',
});
await ingestMetric(ctx, { body: [metric.getValue()] });
assert.strictEqual(ctx.results.statusCode, 200);
assert(spy.calledWith(
new UtapiMetric({
operationId: 'deleteObject',
timestamp: convertTimestamp(metric.timestamp),
}),
));
});
}); });

View File

@ -124,6 +124,7 @@ const eventTemplateToOperation = {
'getObjectRetention', 'getObjectRetention',
'getObjectTagging', 'getObjectTagging',
'headObject', 'headObject',
'putDeleteMarkerObject',
'putObjectAcl', 'putObjectAcl',
'putObjectLegalHold', 'putObjectLegalHold',
'putObjectRetention', 'putObjectRetention',