Skip to content

Commit b99823f

Browse files
authored
[Fleet] create test data stream data before test (#241410)
## Summary Closes #230292 It seems some other tests are impacting the agent data status test. Added test logs docs so the incoming data status is always true instead of being flaky. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ...
1 parent a6d386f commit b99823f

File tree

1 file changed

+50
-3
lines changed
  • x-pack/solutions/security/test/fleet_api_integration/apis/agents

1 file changed

+50
-3
lines changed

x-pack/solutions/security/test/fleet_api_integration/apis/agents/status.ts

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import expect from '@kbn/expect';
9-
9+
import { v4 as uuidv4 } from 'uuid';
1010
import { AGENTS_INDEX } from '@kbn/fleet-plugin/common';
1111
import type { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
1212
import { testUsers } from '../test_users';
@@ -355,6 +355,39 @@ export default function ({ getService }: FtrProviderContext) {
355355
.send({ force: true })
356356
.expect(200);
357357

358+
await es.create({
359+
refresh: 'wait_for',
360+
index: 'logs-system.system-default',
361+
id: uuidv4(),
362+
body: {
363+
agent: {
364+
id: 'agent1',
365+
},
366+
'@timestamp': new Date().toISOString(),
367+
data_stream: {
368+
dataset: 'system.system',
369+
namespace: 'default',
370+
type: 'logs',
371+
},
372+
},
373+
});
374+
await es.create({
375+
refresh: 'wait_for',
376+
index: 'logs-system.system-default',
377+
id: uuidv4(),
378+
body: {
379+
agent: {
380+
id: 'agent2',
381+
},
382+
'@timestamp': new Date().toISOString(),
383+
data_stream: {
384+
dataset: 'system.system',
385+
namespace: 'default',
386+
type: 'logs',
387+
},
388+
},
389+
});
390+
358391
const { body: apiResponse1 } = await supertest
359392
.get(`/api/fleet/agent_status/data?agentsIds=agent1&agentsIds=agent2`)
360393
.expect(200);
@@ -364,13 +397,27 @@ export default function ({ getService }: FtrProviderContext) {
364397
)
365398
.expect(200);
366399
expect(apiResponse1).to.eql({
367-
items: [{ agent1: { data: false } }, { agent2: { data: false } }],
400+
items: [{ agent1: { data: true } }, { agent2: { data: true } }],
368401
dataPreview: [],
369402
});
370403
expect(apiResponse2).to.eql({
371-
items: [{ agent1: { data: false } }, { agent2: { data: false } }],
404+
items: [{ agent1: { data: true } }, { agent2: { data: true } }],
372405
dataPreview: [],
373406
});
407+
408+
// clean up test data
409+
await es.deleteByQuery({
410+
index: 'logs-system.system-default',
411+
query: {
412+
bool: {
413+
filter: {
414+
terms: {
415+
'agent.id': ['agent1', 'agent2'],
416+
},
417+
},
418+
},
419+
},
420+
});
374421
});
375422
});
376423
}

0 commit comments

Comments
 (0)