Skip to content

Commit b27cca2

Browse files
authored
[Cloud Security] fix integration and FTR tests (elastic#218702)
## Summary This PR fixes the flakiness of the following integration and FTR tests: - elastic#191923 - elastic#217399 - elastic#215748 ### Checklist Reviewers should verify this PR satisfies this list as well. - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed
1 parent f4c7cd9 commit b27cca2

3 files changed

Lines changed: 47 additions & 24 deletions

File tree

x-pack/test/api_integration/apis/cloud_security_posture/status/status_not_deployed_not_installed.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,23 @@ export default function (providerContext: FtrProviderContext) {
1919
describe('GET /internal/cloud_security_posture/status', () => {
2020
let agentPolicyId: string;
2121

22+
const savedObjectsTypes = [
23+
'ingest-agent-policies',
24+
'fleet-agent-policies',
25+
'ingest-package-policies',
26+
'fleet-package-policies',
27+
'cloud-security-posture-settings',
28+
];
29+
2230
describe('STATUS = NOT-DEPLOYED and STATUS = NOT-INSTALLED TEST', () => {
23-
beforeEach(async () => {
24-
await kibanaServer.savedObjects.cleanStandardList();
31+
before(async () => {
2532
await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server');
33+
});
34+
35+
beforeEach(async () => {
36+
await kibanaServer.savedObjects.clean({
37+
types: savedObjectsTypes,
38+
});
2639

2740
const { body: agentPolicyResponse } = await supertest
2841
.post(`/api/fleet/agent_policies`)
@@ -37,9 +50,15 @@ export default function (providerContext: FtrProviderContext) {
3750
});
3851

3952
afterEach(async () => {
40-
await kibanaServer.savedObjects.cleanStandardList();
53+
await kibanaServer.savedObjects.clean({
54+
types: savedObjectsTypes,
55+
});
56+
});
57+
58+
after(async () => {
4159
await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server');
4260
});
61+
4362
it(`Should return not-deployed when installed kspm, no findings on either indices and no healthy agents`, async () => {
4463
await createPackagePolicy(
4564
supertest,

x-pack/test/cloud_security_posture_api/routes/benchmarks.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ export default function (providerContext: FtrProviderContext) {
7777
orchestrator: {
7878
cluster: { id: 'Upper case cluster id' },
7979
},
80+
data_stream: {
81+
dataset: 'cloud_security_posture.findings',
82+
},
8083
});
8184

82-
// Failing: See https://github.com/elastic/kibana/issues/217399
83-
describe.skip('GET /internal/cloud_security_posture/benchmarks', () => {
85+
describe('GET /internal/cloud_security_posture/benchmarks', () => {
8486
describe('Get Benchmark API', async () => {
8587
beforeEach(async () => {
8688
await findingsIndex.deleteAll();

x-pack/test/cloud_security_posture_functional/pages/cis_integrations/cspm/cis_integration_aws.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,17 @@ export default function (providerContext: FtrProviderContext) {
6060
await cisIntegration.clickOptionButton(CIS_AWS_OPTION_TEST_ID);
6161
await cisIntegration.inputUniqueIntegrationName();
6262
await cisIntegration.clickSaveButton();
63-
await pageObjects.header.waitUntilLoadingHasFinished();
64-
expect((await cisIntegrationAws.getPostInstallCloudFormationModal()) !== undefined).to.be(
65-
true
66-
);
67-
await pageObjects.header.waitUntilLoadingHasFinished();
68-
expect(
69-
(await cisIntegration.getUrlOnPostInstallModal()) ===
70-
'https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-whatis-howdoesitwork.html'
71-
);
63+
await retry.tryForTime(saveIntegrationPolicyTimeout, async () => {
64+
await cisIntegration.waitUntilLaunchCloudFormationButtonAppears();
65+
expect((await cisIntegrationAws.getPostInstallCloudFormationModal()) !== undefined).to.be(
66+
true
67+
);
68+
await pageObjects.header.waitUntilLoadingHasFinished();
69+
expect(
70+
(await cisIntegration.getUrlOnPostInstallModal()) ===
71+
'https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-whatis-howdoesitwork.html'
72+
);
73+
});
7274
});
7375
it('On Add Agent modal there should be modal that has Cloud Formation details as well as button that redirects user to Cloud formation page on AWS upon clicking them ', async () => {
7476
await cisIntegration.navigateToIntegrationCspList();
@@ -92,12 +94,12 @@ export default function (providerContext: FtrProviderContext) {
9294
await cisIntegration.fillInTextField(ROLE_ARN_TEST_ID, roleArn);
9395
await cisIntegration.inputUniqueIntegrationName();
9496
await cisIntegration.clickSaveButton();
95-
await pageObjects.header.waitUntilLoadingHasFinished();
9697

9798
/*
9899
* sometimes it takes a while to save the integration so added timeout to wait for post install modal
99100
*/
100-
await retry.try(async () => {
101+
await retry.tryForTime(saveIntegrationPolicyTimeout, async () => {
102+
await cisIntegration.waitUntilLaunchCloudFormationButtonAppears();
101103
const modal = await cisIntegration.getPostInstallModal();
102104
if (!modal) {
103105
logger.debug('Post install modal not found');
@@ -130,7 +132,7 @@ export default function (providerContext: FtrProviderContext) {
130132
await cisIntegration.inputUniqueIntegrationName();
131133
await cisIntegration.clickSaveButton();
132134
await retry.tryForTime(saveIntegrationPolicyTimeout, async () => {
133-
await pageObjects.header.waitUntilLoadingHasFinished();
135+
await cisIntegration.waitUntilLaunchCloudFormationButtonAppears();
134136
expect((await cisIntegration.getPostInstallModal()) !== undefined).to.be(true);
135137
await cisIntegration.navigateToIntegrationCspList();
136138
expect(
@@ -165,7 +167,7 @@ export default function (providerContext: FtrProviderContext) {
165167
await cisIntegration.inputUniqueIntegrationName();
166168
await cisIntegration.clickSaveButton();
167169
await retry.tryForTime(saveIntegrationPolicyTimeout, async () => {
168-
await pageObjects.header.waitUntilLoadingHasFinished();
170+
await cisIntegration.waitUntilLaunchCloudFormationButtonAppears();
169171
expect((await cisIntegration.getPostInstallModal()) !== undefined).to.be(true);
170172
await cisIntegration.navigateToIntegrationCspList();
171173
await cisIntegration.clickFirstElementOnIntegrationTable();
@@ -199,7 +201,7 @@ export default function (providerContext: FtrProviderContext) {
199201
await cisIntegration.inputUniqueIntegrationName();
200202
await cisIntegration.clickSaveButton();
201203
await retry.tryForTime(saveIntegrationPolicyTimeout, async () => {
202-
await pageObjects.header.waitUntilLoadingHasFinished();
204+
await cisIntegration.waitUntilLaunchCloudFormationButtonAppears();
203205
expect((await cisIntegration.getPostInstallModal()) !== undefined).to.be(true);
204206
await cisIntegration.navigateToIntegrationCspList();
205207
await cisIntegration.clickFirstElementOnIntegrationTable();
@@ -222,7 +224,7 @@ export default function (providerContext: FtrProviderContext) {
222224
await cisIntegration.inputUniqueIntegrationName();
223225
await cisIntegration.clickSaveButton();
224226
await retry.tryForTime(saveIntegrationPolicyTimeout, async () => {
225-
await pageObjects.header.waitUntilLoadingHasFinished();
227+
await cisIntegration.waitUntilLaunchCloudFormationButtonAppears();
226228
expect(
227229
(await cisIntegration.getUrlOnPostInstallModal()) ===
228230
'https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-whatis-howdoesitwork.html'
@@ -241,7 +243,7 @@ export default function (providerContext: FtrProviderContext) {
241243
await cisIntegration.inputUniqueIntegrationName();
242244
await cisIntegration.clickSaveButton();
243245
await retry.tryForTime(saveIntegrationPolicyTimeout, async () => {
244-
await pageObjects.header.waitUntilLoadingHasFinished();
246+
await cisIntegration.waitUntilLaunchCloudFormationButtonAppears();
245247
expect((await cisIntegration.getPostInstallModal()) !== undefined).to.be(true);
246248
await cisIntegration.navigateToIntegrationCspList();
247249
expect(
@@ -270,7 +272,7 @@ export default function (providerContext: FtrProviderContext) {
270272
await cisIntegration.inputUniqueIntegrationName();
271273
await cisIntegration.clickSaveButton();
272274
await retry.tryForTime(saveIntegrationPolicyTimeout, async () => {
273-
await pageObjects.header.waitUntilLoadingHasFinished();
275+
await cisIntegration.waitUntilLaunchCloudFormationButtonAppears();
274276
expect((await cisIntegration.getPostInstallModal()) !== undefined).to.be(true);
275277
await cisIntegration.navigateToIntegrationCspList();
276278
expect(
@@ -306,7 +308,7 @@ export default function (providerContext: FtrProviderContext) {
306308
await cisIntegration.inputUniqueIntegrationName();
307309
await cisIntegration.clickSaveButton();
308310
await retry.tryForTime(saveIntegrationPolicyTimeout, async () => {
309-
await pageObjects.header.waitUntilLoadingHasFinished();
311+
await cisIntegration.waitUntilLaunchCloudFormationButtonAppears();
310312
expect((await cisIntegration.getPostInstallModal()) !== undefined).to.be(true);
311313
await cisIntegration.navigateToIntegrationCspList();
312314
await cisIntegration.clickFirstElementOnIntegrationTable();
@@ -341,7 +343,7 @@ export default function (providerContext: FtrProviderContext) {
341343
await cisIntegration.inputUniqueIntegrationName();
342344
await cisIntegration.clickSaveButton();
343345
await retry.tryForTime(saveIntegrationPolicyTimeout, async () => {
344-
await pageObjects.header.waitUntilLoadingHasFinished();
346+
await cisIntegration.waitUntilLaunchCloudFormationButtonAppears();
345347
expect((await cisIntegration.getPostInstallModal()) !== undefined).to.be(true);
346348
await cisIntegration.navigateToIntegrationCspList();
347349
await cisIntegration.clickFirstElementOnIntegrationTable();

0 commit comments

Comments
 (0)