Skip to content

Commit e254046

Browse files
authored
[EDR Workflows] Fix Osquery cypress MKI (elastic#270088)
## Summary Aims to fix failing Osquery cypress tests on MKI, by fetching latest agent version on serverless environments. MKI run successful ✅ - https://buildkite.com/elastic/kibana-serverless-security-solution-quality-gate-defend-workflows/builds/4753/canvas?jid=019e444e-2276-4695-b78f-9ae1ebe8b75a&tab=output#019e444e-2276-4695-b78f-9ae1ebe8b75a/L414 ``` info [cy.parallel(svl).onBeforeHook] Setting up Agent --   | │ info [cy.parallel(svl).onBeforeHook] Image: docker.elastic.co/elastic-agent/elastic-agent:9.4.1   | │ info [cy.parallel(svl).onBeforeHook] Fleet Server: https://a324a2da063041458889f234f35077b4.fleet.eu-west-1.aws.qa.elastic.cloud:443   | │ info [cy.parallel(svl).onBeforeHook] Agent container started with id 4ca9b9de0191438d0b38af38ef9963ee0a3ad873fcec75095a32ff98cf127fd1   | info [cy.parallel(svl).onBeforeHook] Waiting for host [vp8avshr0n01] to enroll with fleet   | info [cy.parallel(svl).onBeforeHook] Setting up Agent   | │ info [cy.parallel(svl).onBeforeHook] Image: docker.elastic.co/elastic-agent/elastic-agent:9.4.1   | │ info [cy.parallel(svl).onBeforeHook] Fleet Server: https://a324a2da063041458889f234f35077b4.fleet.eu-west-1.aws.qa.elastic.cloud:443   | │ info [cy.parallel(svl).onBeforeHook] Agent container started with id 8619cbd859ad93e6350c35ef3487621ef7409dc16248ba113aa4bee3056d4c5c   | info [cy.parallel(svl).onBeforeHook] Waiting for host [myvojsd7thgj] to enroll with fleet ``` > [!note] > Optionally can be backported to `v9.4.x`, in case this backport PR is merged: > - elastic#269876 > > Not a must, as MKI tests run on `main` only, but still cleaner. ### 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 40b7de6 commit e254046

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

  • x-pack/solutions/security/test/osquery_cypress

x-pack/solutions/security/test/osquery_cypress/utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import type {
1515
import type { ToolingLog } from '@kbn/tooling-log';
1616
import chalk from 'chalk';
1717
import { getAgentVersionMatchingCurrentStack } from '@kbn/security-solution-plugin/scripts/endpoint/common/fleet_services';
18+
import { fetchFleetLatestAvailableAgentVersion } from '@kbn/security-solution-plugin/common/endpoint/utils/fetch_fleet_version';
19+
import { isServerlessKibanaFlavor } from '@kbn/security-solution-plugin/common/endpoint/utils/kibana_status';
1820

1921
export const DEFAULT_HEADERS = Object.freeze({
2022
'x-elastic-internal-product': 'security-solution',
@@ -132,6 +134,11 @@ export const getLatestAvailableAgentVersion = async (
132134
kbnClient: KbnClient,
133135
log: ToolingLog
134136
): Promise<string> => {
137+
const isServerless = await isServerlessKibanaFlavor(kbnClient);
138+
if (isServerless) {
139+
return fetchFleetLatestAvailableAgentVersion(kbnClient);
140+
}
141+
135142
return getAgentVersionMatchingCurrentStack(kbnClient, log);
136143
};
137144

0 commit comments

Comments
 (0)