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.
[EDR Workflows] Initialize agent with latest fleet supported version (e…
…lastic#189174) This PR introduces a call to `/agents/available_versions` to fetch the latest available agent version in Serverless environment. This version is then used to create agents throughout our tests.
- Loading branch information
1 parent
40d1a91
commit 4106cac
Showing
27 changed files
with
210 additions
and
113 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
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
30 changes: 30 additions & 0 deletions
30
x-pack/plugins/security_solution/common/endpoint/utils/fetch_fleet_version.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,30 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* Fetches the latest version of the Elastic Agent available for download | ||
* @param kbnClient | ||
*/ | ||
import type { KbnClient } from '@kbn/test'; | ||
import { AGENT_API_ROUTES } from '@kbn/fleet-plugin/common'; | ||
import type { GetAvailableVersionsResponse } from '@kbn/fleet-plugin/common/types'; | ||
import { catchAxiosErrorFormatAndThrow } from '../format_axios_error'; | ||
|
||
export const fetchFleetLatestAvailableAgentVersion = async ( | ||
kbnClient: KbnClient | ||
): Promise<string> => { | ||
return kbnClient | ||
.request<GetAvailableVersionsResponse>({ | ||
method: 'GET', | ||
path: AGENT_API_ROUTES.AVAILABLE_VERSIONS_PATTERN, | ||
headers: { | ||
'elastic-api-version': '2023-10-31', | ||
}, | ||
}) | ||
.then((response) => response.data.items[0]) | ||
.catch(catchAxiosErrorFormatAndThrow); | ||
}; |
37 changes: 37 additions & 0 deletions
37
x-pack/plugins/security_solution/common/endpoint/utils/kibana_status.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,37 @@ | ||
/* | ||
* 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 { KbnClient } from '@kbn/test'; | ||
import type { Client } from '@elastic/elasticsearch'; | ||
import type { StatusResponse } from '@kbn/core-status-common-internal'; | ||
import { catchAxiosErrorFormatAndThrow } from '../format_axios_error'; | ||
|
||
export const fetchKibanaStatus = async (kbnClient: KbnClient): Promise<StatusResponse> => { | ||
return (await kbnClient.status.get().catch(catchAxiosErrorFormatAndThrow)) as StatusResponse; | ||
}; | ||
/** | ||
* Checks to see if Kibana/ES is running in serverless mode | ||
* @param client | ||
*/ | ||
export const isServerlessKibanaFlavor = async (client: KbnClient | Client): Promise<boolean> => { | ||
if (client instanceof KbnClient) { | ||
const kbnStatus = await fetchKibanaStatus(client); | ||
|
||
// If we don't have status for plugins, then error | ||
// the Status API will always return something (its an open API), but if auth was successful, | ||
// it will also return more data. | ||
if (!kbnStatus?.status?.plugins) { | ||
throw new Error( | ||
`Unable to retrieve Kibana plugins status (likely an auth issue with the username being used for kibana)` | ||
); | ||
} | ||
|
||
return kbnStatus.status.plugins?.serverless?.level === 'available'; | ||
} else { | ||
return (await client.info()).version.build_flavor === 'serverless'; | ||
} | ||
}; |
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
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
Oops, something went wrong.