Skip to content

Commit 4aefe9c

Browse files
maximpnclaudeelasticmachine
authored
[Security Solution][Cypress] Fix flaky related integrations test caused by Fleet race condition (elastic#261128)
**Resolves: elastic#259831 **Resolves: elastic#239356 ## Summary Mitigates chances of `related_integrations.cy.ts` failure by reducing pressure on Kibana's Fleet plugin via adding extra waiting for integrations installation before adding agent policies. Generally this mitigates the risk of failure. ## Details Mitigates `related_integrations.cy.ts` flakiness reasons in the suite where `cy.request()` timed out waiting for `POST /api/fleet/agent_policies?sys_monitoring=true`. **Root cause**: `installIntegrations()` fired the bulk package install request and immediately followed with the agent policy creation request. The Fleet bulk install endpoint returns a response once the request is accepted, but processes package assets asynchronously. Under CI load, Fleet was still indexing large packages (`aws`, `system`) when the agent policy POST arrived, causing the API to become unresponsive and exceed the 30s default timeout. **Fix**: - Chain the agent policy creation inside `.then()` after the bulk install, polling `waitForPackageInstalled` for each package before proceeding. - Increase the agent policy creation timeout from 30s to 60s, as this endpoint is inherently slow with `?sys_monitoring=true`. ## Flaky test runner TBD Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent 18e2c4f commit 4aefe9c

1 file changed

Lines changed: 25 additions & 17 deletions

File tree

  • x-pack/solutions/security/test/security_solution_cypress/cypress/tasks/api_calls

x-pack/solutions/security/test/security_solution_cypress/cypress/tasks/api_calls/integrations.ts

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,33 @@ export function installIntegrations({
5656
packages,
5757
force: true,
5858
},
59-
});
59+
})
60+
.then(() => {
61+
// Wait for each package to reach 'installed' status before proceeding
62+
packages.forEach(({ name }) => waitForPackageInstalled(name));
63+
})
64+
.then(() =>
65+
rootRequest<CreateAgentPolicyResponse>({
66+
method: 'POST',
67+
url: `${AGENT_POLICY_API_ROUTES.CREATE_PATTERN}?sys_monitoring=true`,
68+
body: agentPolicy,
69+
// Fleet Agent Policies API is known to be slow.
70+
// Set 1 minute timeout, default is 30 seconds.
71+
timeout: 60000,
72+
})
73+
)
74+
.then((response) => {
75+
const packagePolicyWithAgentPolicyId: PackagePolicy = {
76+
...packagePolicy,
77+
policy_id: response.body.item.id,
78+
};
6079

61-
// Install agent and package policies
62-
rootRequest<CreateAgentPolicyResponse>({
63-
method: 'POST',
64-
url: `${AGENT_POLICY_API_ROUTES.CREATE_PATTERN}?sys_monitoring=true`,
65-
body: agentPolicy,
66-
}).then((response) => {
67-
const packagePolicyWithAgentPolicyId: PackagePolicy = {
68-
...packagePolicy,
69-
policy_id: response.body.item.id,
70-
};
71-
72-
rootRequest({
73-
method: 'POST',
74-
url: PACKAGE_POLICY_API_ROUTES.CREATE_PATTERN,
75-
body: packagePolicyWithAgentPolicyId,
80+
rootRequest({
81+
method: 'POST',
82+
url: PACKAGE_POLICY_API_ROUTES.CREATE_PATTERN,
83+
body: packagePolicyWithAgentPolicyId,
84+
});
7685
});
77-
});
7886
}
7987

8088
/**

0 commit comments

Comments
 (0)