Skip to content

Commit 287e9c7

Browse files
[9.2] [Fleet] create test data stream data before test (#241410) (#241467)
# Backport This will backport the following commits from `main` to `9.2`: - [[Fleet] create test data stream data before test (#241410)](#241410) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Julia Bardi","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-10-31T15:02:21Z","message":"[Fleet] create test data stream data before test (#241410)\n\n## Summary\n\nCloses https://github.com/elastic/kibana/issues/230292\n\nIt seems some other tests are impacting the agent data status test. \nAdded test logs docs so the incoming data status is always true instead\nof being flaky.\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n- [ ] This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [ ] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.\n\n### Identify risks\n\nDoes this PR introduce any risks? For example, consider risks like hard\nto test bugs, performance regression, potential of data loss.\n\nDescribe the risk, its severity, and mitigation for each identified\nrisk. Invite stakeholders and evaluate how to proceed before merging.\n\n- [ ] [See some risk\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)\n- [ ] ...","sha":"b99823fe806b8aba7f3511e0a644a7511a589ef6","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:version","v9.3.0","v9.2.1"],"title":"[Fleet] create test data stream data before test","number":241410,"url":"https://github.com/elastic/kibana/pull/241410","mergeCommit":{"message":"[Fleet] create test data stream data before test (#241410)\n\n## Summary\n\nCloses https://github.com/elastic/kibana/issues/230292\n\nIt seems some other tests are impacting the agent data status test. \nAdded test logs docs so the incoming data status is always true instead\nof being flaky.\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n- [ ] This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [ ] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.\n\n### Identify risks\n\nDoes this PR introduce any risks? For example, consider risks like hard\nto test bugs, performance regression, potential of data loss.\n\nDescribe the risk, its severity, and mitigation for each identified\nrisk. Invite stakeholders and evaluate how to proceed before merging.\n\n- [ ] [See some risk\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)\n- [ ] ...","sha":"b99823fe806b8aba7f3511e0a644a7511a589ef6"}},"sourceBranch":"main","suggestedTargetBranches":["9.2"],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/241410","number":241410,"mergeCommit":{"message":"[Fleet] create test data stream data before test (#241410)\n\n## Summary\n\nCloses https://github.com/elastic/kibana/issues/230292\n\nIt seems some other tests are impacting the agent data status test. \nAdded test logs docs so the incoming data status is always true instead\nof being flaky.\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n- [ ] This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [ ] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.\n\n### Identify risks\n\nDoes this PR introduce any risks? For example, consider risks like hard\nto test bugs, performance regression, potential of data loss.\n\nDescribe the risk, its severity, and mitigation for each identified\nrisk. Invite stakeholders and evaluate how to proceed before merging.\n\n- [ ] [See some risk\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)\n- [ ] ...","sha":"b99823fe806b8aba7f3511e0a644a7511a589ef6"}},{"branch":"9.2","label":"v9.2.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Julia Bardi <[email protected]>
1 parent e095c3d commit 287e9c7

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)