Skip to content

Commit

Permalink
Move sorting to test
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv committed Jul 5, 2020
1 parent 048d75a commit ac668d1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { sortBy } from 'lodash';
import { joinByKey } from '../../../../common/utils/join_by_key';
import { PromiseReturnType } from '../../../../typings/common';
import {
Expand Down Expand Up @@ -52,6 +51,5 @@ export async function getServicesItems(setup: ServicesItemsSetup) {
...environments,
];

const items = joinByKey(allMetrics, 'serviceName');
return sortBy(items, ['serviceName']);
return joinByKey(allMetrics, 'serviceName');
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { sortBy } from 'lodash';
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../common/ftr_provider_context';

Expand Down Expand Up @@ -36,38 +37,39 @@ export default function ApiTest({ getService }: FtrProviderContext) {
const response = await supertest.get(
`/api/apm/services?start=${start}&end=${end}&uiFilters=${uiFilters}`
);
// sort services to mitigate unstable sort order
const services = sortBy(response.body.items, ['serviceName']);

expect(response.status).to.be(200);
expect(response.body).to.eql({
items: [
{
serviceName: 'client',
agentName: 'rum-js',
transactionsPerMinute: 2,
errorsPerMinute: 2.75,
avgResponseTime: 116375,
environments: [],
},
{
serviceName: 'opbeans-java',
agentName: 'java',
transactionsPerMinute: 30.75,
errorsPerMinute: 4.5,
avgResponseTime: 25636.349593495936,
environments: ['production'],
},
{
serviceName: 'opbeans-node',
agentName: 'nodejs',
transactionsPerMinute: 31,
errorsPerMinute: 3.75,
avgResponseTime: 38682.52419354839,
environments: ['production'],
},
],
hasHistoricalData: true,
hasLegacyData: false,
});
expect(services).to.eql([
{
serviceName: 'client',
agentName: 'rum-js',
transactionsPerMinute: 2,
errorsPerMinute: 2.75,
avgResponseTime: 116375,
environments: [],
},
{
serviceName: 'opbeans-java',
agentName: 'java',
transactionsPerMinute: 30.75,
errorsPerMinute: 4.5,
avgResponseTime: 25636.349593495936,
environments: ['production'],
},
{
serviceName: 'opbeans-node',
agentName: 'nodejs',
transactionsPerMinute: 31,
errorsPerMinute: 3.75,
avgResponseTime: 38682.52419354839,
environments: ['production'],
},
]);

expect(response.body.hasHistoricalData).to.be(true);
expect(response.body.hasLegacyData).to.be(false);
});
});
});
Expand Down

0 comments on commit ac668d1

Please sign in to comment.