Skip to content

Commit

Permalink
fixed integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic committed Nov 9, 2022
1 parent 3cfaf2e commit d622ed3
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions x-pack/test/fleet_api_integration/apis/agents/uploads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import expect from '@kbn/expect';

import { AGENT_ACTIONS_INDEX, AGENT_ACTIONS_RESULTS_INDEX } from '@kbn/fleet-plugin/common';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
import { setupFleetAndAgents } from './services';
import { skipIfNoDockerRegistry } from '../../helpers';
Expand All @@ -17,25 +17,45 @@ export default function (providerContext: FtrProviderContext) {
const supertest = getService('supertest');
const esClient = getService('es');

const ES_INDEX_OPTIONS = { headers: { 'X-elastic-product-origin': 'fleet' } };

describe('fleet_uploads', () => {
skipIfNoDockerRegistry(providerContext);
setupFleetAndAgents(providerContext);
beforeEach(async () => {

before(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server');
await getService('supertest').post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').send();

await esClient.create({
index: '.fleet-actions',
id: 'action1',
index: AGENT_ACTIONS_INDEX,
id: new Date().toISOString(),
refresh: true,
body: {
type: 'REQUEST_DIAGNOSTICS',
action_id: 'action1',
agents: ['agent1'],
'@timestamp': '2022-10-07T12:00:00.000Z',
'@timestamp': '2022-10-07T11:00:00.000Z',
},
});

await esClient.create(
{
index: AGENT_ACTIONS_RESULTS_INDEX,
id: new Date().toISOString(),
refresh: true,
body: {
action_id: 'action1',
agent_id: 'agent1',
'@timestamp': '2022-10-07T12:00:00.000Z',
data: {
file_id: 'file1',
},
},
},
ES_INDEX_OPTIONS
);

await esClient.update({
index: '.fleet-agent-files',
id: 'file1',
Expand All @@ -59,7 +79,7 @@ export default function (providerContext: FtrProviderContext) {
},
});
});
afterEach(async () => {
after(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server');
});

Expand Down

0 comments on commit d622ed3

Please sign in to comment.