Skip to content

Commit

Permalink
fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Liza K committed Feb 3, 2021
1 parent dbfd580 commit c53310a
Showing 1 changed file with 0 additions and 114 deletions.
114 changes: 0 additions & 114 deletions x-pack/test/api_integration/apis/search/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,119 +292,5 @@ export default function ({ getService }: FtrProviderContext) {
getSessionSecondTime.body.attributes.touched
);
});

it('should sync search ids into not persisted session', async () => {
const sessionId = `my-session-${Math.random()}`;

// run search
const searchRes1 = await supertest
.post(`/internal/search/ese`)
.set('kbn-xsrf', 'foo')
.send({
sessionId,
params: {
body: {
query: {
term: {
agent: '1',
},
},
},
wait_for_completion_timeout: '1ms',
},
})
.expect(200);

const { id: id1 } = searchRes1.body;

// run search
const searchRes2 = await supertest
.post(`/internal/search/ese`)
.set('kbn-xsrf', 'foo')
.send({
sessionId,
params: {
body: {
query: {
match_all: {},
},
},
wait_for_completion_timeout: '1ms',
},
})
.expect(200);

const { id: id2 } = searchRes2.body;

const resp = await supertest
.get(`/internal/session/${sessionId}`)
.set('kbn-xsrf', 'foo')
.expect(200);

const { appId, name, touched, created, persisted, idMapping } = resp.body.attributes;
expect(persisted).to.be(false);
expect(name).to.be(undefined);
expect(appId).to.be(undefined);
expect(touched).not.to.be(undefined);
expect(created).not.to.be(undefined);

const idMappings = Object.values(idMapping).map((value: any) => value.id);
expect(idMappings).to.contain(id1);
expect(idMappings).to.contain(id2);
});

it('touched time updates when you poll on an search', async () => {
const sessionId = `my-session-${Math.random()}`;

// run search
const searchRes1 = await supertest
.post(`/internal/search/ese`)
.set('kbn-xsrf', 'foo')
.send({
sessionId,
params: {
body: {
query: {
term: {
agent: '1',
},
},
},
wait_for_completion_timeout: '1ms',
},
})
.expect(200);

const { id: id1 } = searchRes1.body;

// it might take the session a moment to be created
await new Promise((resolve) => setTimeout(resolve, 1000));

const getSessionFirstTime = await supertest
.get(`/internal/session/${sessionId}`)
.set('kbn-xsrf', 'foo')
.expect(200);

// poll on search
await supertest
.post(`/internal/search/ese/${id1}`)
.set('kbn-xsrf', 'foo')
.send({
sessionId,
})
.expect(200);

const getSessionSecondTime = await supertest
.get(`/internal/session/${sessionId}`)
.set('kbn-xsrf', 'foo')
.expect(200);

expect(getSessionFirstTime.body.attributes.sessionId).to.be.equal(
getSessionSecondTime.body.attributes.sessionId
);
expect(getSessionFirstTime.body.attributes.touched).to.be.lessThan(
getSessionSecondTime.body.attributes.touched
);
});
});
}

0 comments on commit c53310a

Please sign in to comment.