Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] Unskip test #81574

Merged
merged 1 commit into from
Oct 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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