Skip to content

Commit

Permalink
retry users integration test (#96772) (#96932)
Browse files Browse the repository at this point in the history
  • Loading branch information
angorayc authored Apr 13, 2021
1 parent c844b07 commit 2b4ff4a
Showing 1 changed file with 39 additions and 36 deletions.
75 changes: 39 additions & 36 deletions x-pack/test/api_integration/apis/security_solution/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const TO = '3000-01-01T00:00:00.000Z';
const IP = '0.0.0.0';

export default function ({ getService }: FtrProviderContext) {
const retry = getService('retry');
const esArchiver = getService('esArchiver');
const supertest = getService('supertest');
describe('Users', () => {
Expand All @@ -28,42 +29,44 @@ export default function ({ getService }: FtrProviderContext) {
after(() => esArchiver.unload('auditbeat/users'));

it('Ensure data is returned from auditbeat', async () => {
const { body: users } = await supertest
.post('/internal/search/securitySolutionSearchStrategy/')
.set('kbn-xsrf', 'true')
.send({
factoryQueryType: NetworkQueries.users,
sourceId: 'default',
timerange: {
interval: '12h',
to: TO,
from: FROM,
},
defaultIndex: ['auditbeat-users'],
docValueFields: [],
ip: IP,
flowTarget: FlowTarget.destination,
sort: { field: NetworkUsersFields.name, direction: Direction.asc },
pagination: {
activePage: 0,
cursorStart: 0,
fakePossibleCount: 30,
querySize: 10,
},
inspect: false,
/* We need a very long timeout to avoid returning just partial data.
** https://github.com/elastic/kibana/blob/master/x-pack/test/api_integration/apis/search/search.ts#L18
*/
wait_for_completion_timeout: '10s',
})
.expect(200);
expect(users.edges.length).to.be(1);
expect(users.totalCount).to.be(1);
expect(users.edges[0].node.user!.id).to.eql(['0']);
expect(users.edges[0].node.user!.name).to.be('root');
expect(users.edges[0].node.user!.groupId).to.eql(['0']);
expect(users.edges[0].node.user!.groupName).to.eql(['root']);
expect(users.edges[0].node.user!.count).to.be(1);
await retry.try(async () => {
const { body: users } = await supertest
.post('/internal/search/securitySolutionSearchStrategy/')
.set('kbn-xsrf', 'true')
.send({
factoryQueryType: NetworkQueries.users,
sourceId: 'default',
timerange: {
interval: '12h',
to: TO,
from: FROM,
},
defaultIndex: ['auditbeat-users'],
docValueFields: [],
ip: IP,
flowTarget: FlowTarget.destination,
sort: { field: NetworkUsersFields.name, direction: Direction.asc },
pagination: {
activePage: 0,
cursorStart: 0,
fakePossibleCount: 30,
querySize: 10,
},
inspect: false,
/* We need a very long timeout to avoid returning just partial data.
** https://github.com/elastic/kibana/blob/master/x-pack/test/api_integration/apis/search/search.ts#L18
*/
wait_for_completion_timeout: '10s',
})
.expect(200);
expect(users.edges.length).to.be(1);
expect(users.totalCount).to.be(1);
expect(users.edges[0].node.user!.id).to.eql(['0']);
expect(users.edges[0].node.user!.name).to.be('root');
expect(users.edges[0].node.user!.groupId).to.eql(['0']);
expect(users.edges[0].node.user!.groupName).to.eql(['root']);
expect(users.edges[0].node.user!.count).to.be(1);
});
});
});
});
Expand Down

0 comments on commit 2b4ff4a

Please sign in to comment.