Skip to content

Commit a492a5c

Browse files
maximpnclaude
andcommitted
[Security Solution][Cypress] Fix flaky related integrations test by awaiting package installation before creating agent policy
Wait for each package to reach 'installed' status before calling the Fleet agent policies API, and increase the agent policy creation timeout from 30s to 60s. Previously the bulk install was fired and the agent policy request followed immediately; Fleet was still processing large packages (aws, system) in the background, causing the agent policy POST to time out under CI load. Closes #259831 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent cdedd22 commit a492a5c

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)