From 6274ccbd56f3192347d872ea4c1b6064c3e82093 Mon Sep 17 00:00:00 2001 From: Julia Bardi <90178898+juliaElastic@users.noreply.github.com> Date: Fri, 31 Oct 2025 08:45:09 +0100 Subject: [PATCH] [Fleet] fix fleet_list_agent tests (#241289) ## Summary Closes https://github.com/elastic/kibana/issues/170690 ### 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) - [ ] ... (cherry picked from commit 991b518c5536d75a3df34603a109f79b31670163) --- .../fleet_api_integration/apis/agents/list.ts | 15 +-------------- .../test/fleet_api_integration/config.agent.ts | 13 ++++++++++++- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/x-pack/platform/test/fleet_api_integration/apis/agents/list.ts b/x-pack/platform/test/fleet_api_integration/apis/agents/list.ts index 401e38d03a400..390755a3a601b 100644 --- a/x-pack/platform/test/fleet_api_integration/apis/agents/list.ts +++ b/x-pack/platform/test/fleet_api_integration/apis/agents/list.ts @@ -19,8 +19,7 @@ export default function ({ getService }: FtrProviderContext) { const mockAgentlessApiService = setupMockServer(); let elasticAgentpkgVersion: string; - // FLAKY: https://github.com/elastic/kibana/issues/170690 - describe.skip('fleet_list_agent', () => { + describe('fleet_list_agent', () => { let mockApiServer: http.Server; before(async () => { @@ -316,18 +315,6 @@ export default function ({ getService }: FtrProviderContext) { }); it('should not return agentless agents when showAgentless=false', async () => { - // Set up default Fleet Server host, needed during agentless agent creation - await supertest - .post(`/api/fleet/fleet_server_hosts`) - .set('kbn-xsrf', 'xxxx') - .send({ - id: 'fleet-default-fleet-server-host', - name: 'Default', - is_default: true, - host_urls: ['https://test.com:8080', 'https://test.com:8081'], - }) - .expect(200); - // Create an agentless agent policy const { body: policyRes } = await supertest .post('/api/fleet/agent_policies') diff --git a/x-pack/platform/test/fleet_api_integration/config.agent.ts b/x-pack/platform/test/fleet_api_integration/config.agent.ts index cfc4b3d73f255..e61dbe47c87f2 100644 --- a/x-pack/platform/test/fleet_api_integration/config.agent.ts +++ b/x-pack/platform/test/fleet_api_integration/config.agent.ts @@ -9,12 +9,23 @@ import { FtrConfigProviderContext } from '@kbn/test'; export default async function ({ readConfigFile }: FtrConfigProviderContext) { const baseFleetApiConfig = await readConfigFile(require.resolve('./config.base.ts')); + const baseConfig = baseFleetApiConfig.getAll(); return { - ...baseFleetApiConfig.getAll(), + ...baseConfig, testFiles: [require.resolve('./apis/agents')], junit: { reportName: 'X-Pack Fleet Agent API Integration Tests', }, + kbnTestServer: { + ...baseConfig.kbnTestServer, + serverArgs: [ + ...baseConfig.kbnTestServer.serverArgs, + // Add cloud configuration specifically for agent tests (needed for agentless functionality in ESS) + `--xpack.cloud.id="ftr_fake_cloud_id:aGVsbG8uY29tOjQ0MyRFUzEyM2FiYyRrYm4xMjNhYmM="`, + `--xpack.cloud.base_url="https://cloud.elastic.co"`, + `--xpack.cloud.deployment_url="/deployments/deploymentId"`, + ], + }, }; }