Compare commits
No commits in common. "900ff95f595a40e5e9ee6a2e1d2d23a585405ec9" and "11868de36722816462b7d94fb958c173d54cdecd" have entirely different histories.
900ff95f59
...
11868de367
|
@ -99,9 +99,6 @@ const constants = {
|
|||
migrationOpTranslationMap: {
|
||||
listBucketMultipartUploads: 'listMultipartUploads',
|
||||
},
|
||||
ingestionOpTranslationMap: {
|
||||
putDeleteMarkerObject: 'deleteObject',
|
||||
},
|
||||
expirationChunkDuration: 900000000, // 15 minutes in microseconds
|
||||
};
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ const errors = require('../../../errors');
|
|||
const { UtapiMetric } = require('../../../models');
|
||||
const { client: cacheClient } = require('../../../cache');
|
||||
const { convertTimestamp } = require('../../../utils');
|
||||
const { ingestionOpTranslationMap } = require('../../../constants');
|
||||
|
||||
async function ingestMetric(ctx, params) {
|
||||
let metrics;
|
||||
|
@ -10,7 +9,6 @@ async function ingestMetric(ctx, params) {
|
|||
metrics = params.body.map(m => new UtapiMetric({
|
||||
...m,
|
||||
timestamp: convertTimestamp(m.timestamp),
|
||||
operationId: ingestionOpTranslationMap[m.operationId] || m.operationId,
|
||||
}));
|
||||
} catch (error) {
|
||||
throw errors.InvalidRequest;
|
||||
|
|
|
@ -76,8 +76,10 @@ function errorMiddleware(err, req, res, next) {
|
|||
}
|
||||
|
||||
res.status(code).send({
|
||||
code: code.toString(),
|
||||
message,
|
||||
error: {
|
||||
code: code.toString(),
|
||||
message,
|
||||
},
|
||||
});
|
||||
responseLoggerMiddleware(req, res);
|
||||
}
|
||||
|
|
|
@ -30,15 +30,10 @@ const emptyOperationsResponse = Object.values(operationToResponse)
|
|||
|
||||
async function listMetrics(level, resources, start, end, force403 = false) {
|
||||
const body = {
|
||||
timeRange: [start, end],
|
||||
[level]: resources,
|
||||
};
|
||||
|
||||
if (end !== undefined) {
|
||||
body.timeRange = [start, end];
|
||||
} else {
|
||||
body.timeRange = [start];
|
||||
}
|
||||
|
||||
const headers = {
|
||||
host: 'localhost',
|
||||
port: 8100,
|
||||
|
@ -212,9 +207,4 @@ describe('Test listMetric', function () {
|
|||
const resp = await listMetrics('buckets', ['test'], getTs(-1), getTs(1), true);
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -43,19 +43,4 @@ describe('Test ingestMetric', () => {
|
|||
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),
|
||||
}),
|
||||
));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -124,6 +124,7 @@ const eventTemplateToOperation = {
|
|||
'getObjectRetention',
|
||||
'getObjectTagging',
|
||||
'headObject',
|
||||
'putDeleteMarkerObject',
|
||||
'putObjectAcl',
|
||||
'putObjectLegalHold',
|
||||
'putObjectRetention',
|
||||
|
|
Loading…
Reference in New Issue