forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fleet] Add retry logic to serverless API check (elastic#176808)
## Summary Closes elastic#176352 Closes elastic#176399 elastic#175315 added the possibility to configure new Fleet Server hosts in serverless, with the constraint that the host URL must match the default URL. The API integration tests written to test this have been flaky, due to failure retrieving the default Fleet Server host or default Elasticsearch output from saved objects. This PR adds retry in the tests. Note: I have tried adding retry logic in the API handlers but kept hitting test flakiness. This fix has been tested using the Flaky Test Runner Pipeline, with 48/49 test runs for observability and security project types: 🟢 https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5218 🟢 https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5222 🟢 https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5225 ### Checklist - [x] [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 - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed
- Loading branch information
1 parent
eb708f5
commit 83e64be
Showing
7 changed files
with
114 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
x-pack/test_serverless/api_integration/test_suites/common/fleet/default_setup.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { FtrProviderContext } from '../../../ftr_provider_context'; | ||
|
||
const defaultFleetServerHostId = 'default-fleet-server'; | ||
const defaultFleetServerHostUrl = 'https://localhost:8220'; | ||
const defaultElasticsearchOutputId = 'es-default-output'; | ||
const defaultElasticsearchOutputHostUrl = 'https://localhost:9200'; | ||
|
||
export async function expectDefaultFleetServer({ getService }: FtrProviderContext) { | ||
const supertest = getService('supertest'); | ||
const retry = getService('retry'); | ||
|
||
await retry.waitForWithTimeout('get default fleet server', 30_000, async () => { | ||
const { body, status } = await supertest.get( | ||
`/api/fleet/fleet_server_hosts/${defaultFleetServerHostId}` | ||
); | ||
if (status === 200 && body.item.host_urls.includes(defaultFleetServerHostUrl)) { | ||
return true; | ||
} else { | ||
throw new Error(`Expected default Fleet Server id ${defaultFleetServerHostId} to exist`); | ||
} | ||
}); | ||
} | ||
|
||
export async function expectDefaultElasticsearchOutput({ getService }: FtrProviderContext) { | ||
const supertest = getService('supertest'); | ||
const retry = getService('retry'); | ||
|
||
await retry.waitForWithTimeout('get default Elasticsearch output', 30_000, async () => { | ||
const { body, status } = await supertest.get( | ||
`/api/fleet/outputs/${defaultElasticsearchOutputId}` | ||
); | ||
if (status === 200 && body.item.hosts.includes(defaultElasticsearchOutputHostUrl)) { | ||
return true; | ||
} else { | ||
throw new Error( | ||
`Expected default Elasticsearch output id ${defaultElasticsearchOutputId} to exist` | ||
); | ||
} | ||
}); | ||
} | ||
|
||
export const kbnServerArgs = [ | ||
'--xpack.cloud.serverless.project_id=ftr_fake_project_id', | ||
`--xpack.fleet.fleetServerHosts=[${JSON.stringify({ | ||
id: defaultFleetServerHostId, | ||
name: 'Default Fleet Server', | ||
is_default: true, | ||
host_urls: [defaultFleetServerHostUrl], | ||
})}]`, | ||
`--xpack.fleet.outputs=[${JSON.stringify({ | ||
id: defaultElasticsearchOutputId, | ||
name: 'Default Output', | ||
type: 'elasticsearch', | ||
is_default: true, | ||
is_default_monitoring: true, | ||
hosts: [defaultElasticsearchOutputHostUrl], | ||
})}]`, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters