Skip to content

Commit

Permalink
[APM] Unskip test
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv committed Oct 24, 2020
1 parent 26cfda6 commit 3e594e3
Showing 1 changed file with 37 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
'user.username,user.id,host.ip,user_agent.name,kubernetes.pod.uuid,url.domain,container.id,service.node.name';

// Failing: See https://github.com/elastic/kibana/issues/81264
describe.skip('Slow durations', () => {
describe('Slow durations', () => {
const url = format({
pathname: `/api/apm/correlations/slow_durations`,
query: { start, end, durationPercentile, fieldNames },
Expand All @@ -40,21 +40,21 @@ export default function ApiTest({ getService }: FtrProviderContext) {
});
});

describe('with default scoring', () => {
let response: PromiseReturnType<typeof supertest.get>;
before(async () => {
await esArchiver.load(archiveName);
response = await supertest.get(url);
});

describe('when data is loaded', () => {
before(() => esArchiver.load(archiveName));
after(() => esArchiver.unload(archiveName));

it('returns successfully', () => {
expect(response.status).to.eql(200);
});
describe('making request with default args', () => {
let response: PromiseReturnType<typeof supertest.get>;
before(async () => {
response = await supertest.get(url);

it('returns successfully', () => {
expect(response.status).to.eql(200);
});

it('returns fields in response', () => {
expectSnapshot(Object.keys(response.body.response)).toMatchInline(`
it('returns fields in response', () => {
expectSnapshot(Object.keys(response.body.response)).toMatchInline(`
Array [
"service.node.name",
"host.ip",
Expand All @@ -64,14 +64,14 @@ export default function ApiTest({ getService }: FtrProviderContext) {
"url.domain",
]
`);
});
});

it('returns cardinality for each field', () => {
const cardinalitys = Object.values(response.body.response).map(
(field: any) => field.cardinality
);
it('returns cardinality for each field', () => {
const cardinalitys = Object.values(response.body.response).map(
(field: any) => field.cardinality
);

expectSnapshot(cardinalitys).toMatchInline(`
expectSnapshot(cardinalitys).toMatchInline(`
Array [
5,
6,
Expand All @@ -81,58 +81,35 @@ export default function ApiTest({ getService }: FtrProviderContext) {
4,
]
`);
});
});

it('returns buckets', () => {
const { buckets } = response.body.response['user.id'].value;
expectSnapshot(buckets[0]).toMatchInline(`
it('returns buckets', () => {
const { buckets } = response.body.response['user.id'].value;
expectSnapshot(buckets[0]).toMatchInline(`
Object {
"bg_count": 32,
"doc_count": 6,
"key": "2",
"score": 0.1875,
}
`);
});
});
});
});

describe('with different scoring', () => {
before(async () => esArchiver.load(archiveName));
after(() => esArchiver.unload(archiveName));

it(`returns buckets for each score`, async () => {
const promises = ['percentage', 'jlh', 'chi_square', 'gnd'].map(async (scoring) => {
const response = await supertest.get(
format({
pathname: `/api/apm/correlations/slow_durations`,
query: { start, end, durationPercentile, fieldNames, scoring },
})
);

return { name: scoring, value: response.body.response['user.id'].value.buckets[0].score };
describe('making a request for each "scoring"', () => {
['percentage', 'jlh', 'chi_square', 'gnd'].map(async (scoring) => {
it(`returns response for scoring "${scoring}"`, async () => {
const response = await supertest.get(
format({
pathname: `/api/apm/correlations/slow_durations`,
query: { start, end, durationPercentile, fieldNames, scoring },
})
);

expect(response.status).to.be(200);
});
});

const res = await Promise.all(promises);
expectSnapshot(res).toMatchInline(`
Array [
Object {
"name": "percentage",
"value": 0.1875,
},
Object {
"name": "jlh",
"value": 3.33506905769659,
},
Object {
"name": "chi_square",
"value": 219.192006524483,
},
Object {
"name": "gnd",
"value": 0.671406580688819,
},
]
`);
});
});
});
Expand Down

0 comments on commit 3e594e3

Please sign in to comment.