-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…5873) # Backport This will backport the following commits from `main` to `8.x`: - [[Fleet] Add cypress test against space awareness (#195372)](#195372) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Nicolas Chaulet","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-11T07:19:21Z","message":"[Fleet] Add cypress test against space awareness (#195372)","sha":"5b697499978170937d8c0280b0cf184ee84b57ab","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","v9.0.0","backport:prev-minor","v8.16.0"],"number":195372,"url":"https://github.com/elastic/kibana/pull/195372","mergeCommit":{"message":"[Fleet] Add cypress test against space awareness (#195372)","sha":"5b697499978170937d8c0280b0cf184ee84b57ab"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/195372","number":195372,"mergeCommit":{"message":"[Fleet] Add cypress test against space awareness (#195372)","sha":"5b697499978170937d8c0280b0cf184ee84b57ab"}},{"branch":"8.x","label":"v8.16.0","labelRegex":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
c04b25b
commit 89f85ab
Showing
18 changed files
with
303 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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 { defineCypressConfig } from '@kbn/cypress-config'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default defineCypressConfig({ | ||
defaultCommandTimeout: 60000, | ||
requestTimeout: 60000, | ||
responseTimeout: 60000, | ||
execTimeout: 120000, | ||
pageLoadTimeout: 120000, | ||
|
||
retries: { | ||
runMode: 2, | ||
}, | ||
|
||
env: { | ||
grepFilterSpecs: false, | ||
}, | ||
|
||
screenshotsFolder: '../../../target/kibana-fleet/cypress/screenshots', | ||
trashAssetsBeforeRuns: false, | ||
video: false, | ||
videosFolder: '../../../target/kibana-fleet/cypress/videos', | ||
viewportHeight: 900, | ||
viewportWidth: 1440, | ||
screenshotOnRunFailure: true, | ||
|
||
e2e: { | ||
baseUrl: 'http://localhost:5601', | ||
|
||
experimentalRunAllSpecs: true, | ||
experimentalMemoryManagement: true, | ||
numTestsKeptInMemory: 3, | ||
|
||
specPattern: './cypress/e2e/space_awareness/**/*.cy.ts', | ||
supportFile: './cypress/support/e2e.ts', | ||
|
||
setupNodeEvents(on, config) { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires, @kbn/imports/no_boundary_crossing | ||
return require('./cypress/plugins')(on, config); | ||
}, | ||
}, | ||
}); |
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
75 changes: 75 additions & 0 deletions
75
x-pack/plugins/fleet/cypress/e2e/space_awareness/policies.cy.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,75 @@ | ||
/* | ||
* 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 { | ||
ADD_AGENT_POLICY_BTN, | ||
AGENT_POLICIES_TABLE, | ||
AGENT_POLICY_CREATE_AGENT_POLICY_NAME_FIELD, | ||
AGENT_POLICY_DETAILS_PAGE, | ||
AGENT_POLICY_FLYOUT_CREATE_BUTTON, | ||
AGENT_POLICY_SYSTEM_MONITORING_CHECKBOX, | ||
} from '../../screens/fleet'; | ||
import { login } from '../../tasks/login'; | ||
import { createSpaces, enableSpaceAwareness } from '../../tasks/spaces'; | ||
import { cleanupAgentPolicies } from '../../tasks/cleanup'; | ||
|
||
describe('Space aware policies creation', { testIsolation: false }, () => { | ||
before(() => { | ||
enableSpaceAwareness(); | ||
createSpaces(); | ||
cleanupAgentPolicies(); | ||
cleanupAgentPolicies('test'); | ||
login(); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.intercept('GET', /\/api\/fleet\/agent_policies/).as('getAgentPolicies'); | ||
cy.intercept('GET', /\/internal\/fleet\/agent_policies_spaces/).as('getAgentPoliciesSpaces'); | ||
}); | ||
|
||
const POLICY_NAME = `Policy 1 space test`; | ||
const NO_AGENT_POLICIES = 'No agent policies'; | ||
it('should allow to create an agent policy in the test space', () => { | ||
cy.visit('/s/test/app/fleet/policies'); | ||
|
||
cy.getBySel(ADD_AGENT_POLICY_BTN).click(); | ||
cy.getBySel(AGENT_POLICY_CREATE_AGENT_POLICY_NAME_FIELD).type(POLICY_NAME); | ||
cy.getBySel(AGENT_POLICY_SYSTEM_MONITORING_CHECKBOX).uncheck(); | ||
|
||
cy.getBySel(AGENT_POLICY_FLYOUT_CREATE_BUTTON).click(); | ||
cy.getBySel(AGENT_POLICIES_TABLE).contains(POLICY_NAME); | ||
}); | ||
|
||
it('the created policy should not be visible in the default space', () => { | ||
cy.visit('/app/fleet/policies'); | ||
cy.wait('@getAgentPolicies'); | ||
cy.getBySel(AGENT_POLICIES_TABLE).contains(NO_AGENT_POLICIES); | ||
}); | ||
|
||
it('should allow to update that policy to belong to both test and default space', () => { | ||
cy.visit('/s/test/app/fleet/policies'); | ||
cy.getBySel(AGENT_POLICIES_TABLE).contains(POLICY_NAME).click(); | ||
|
||
cy.getBySel(AGENT_POLICY_DETAILS_PAGE.SETTINGS_TAB).click(); | ||
cy.wait('@getAgentPoliciesSpaces'); | ||
cy.getBySel(AGENT_POLICY_DETAILS_PAGE.SPACE_SELECTOR_COMBOBOX).click().type('default{enter}'); | ||
|
||
cy.getBySel(AGENT_POLICY_DETAILS_PAGE.SAVE_BUTTON).click(); | ||
}); | ||
|
||
it('the policy should be visible in the test space', () => { | ||
cy.visit('/s/test/app/fleet/policies'); | ||
cy.wait('@getAgentPolicies'); | ||
cy.getBySel(AGENT_POLICIES_TABLE).contains(POLICY_NAME); | ||
}); | ||
|
||
it('the policy should be visible in the default space', () => { | ||
cy.visit('/app/fleet/policies'); | ||
cy.wait('@getAgentPolicies'); | ||
cy.getBySel(AGENT_POLICIES_TABLE).contains(POLICY_NAME); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* 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 { request, internalRequest } from './common'; | ||
|
||
export function enableSpaceAwareness() { | ||
return internalRequest({ | ||
url: '/internal/fleet/enable_space_awareness', | ||
failOnStatusCode: false, | ||
method: 'POST', | ||
}); | ||
} | ||
|
||
export function createSpaces() { | ||
return request({ | ||
url: '/api/spaces/space', | ||
failOnStatusCode: false, | ||
method: 'POST', | ||
body: { | ||
id: 'test', | ||
name: 'Test', | ||
description: 'Test space', | ||
color: '#aabbcc', | ||
initials: 'TE', | ||
disabledFeatures: [], | ||
imageUrl: | ||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD4AAABACAYAAABC6cT1AAAGf0lEQVRoQ+3abYydRRUH8N882xYo0IqagEVjokQJKAiKBjXExC9G/aCkGowCIghCkRcrVSSKIu/FEiqgGL6gBIlAYrAqUTH6hZgQFVEMKlQFfItWoQWhZe8z5uzMLdvbfbkLxb13d+fbvfe588x/zpn/+Z9zJpmnI81T3BaAzzfLL1h8weLzZAcWXH2eGHo7zAWLL1h8nuzAjFw9G1N6Kzq8HnuM36MR8iibF3Fv4q+7cv8yDV6K13bYq2furSP8Ag8ncr/vnSnwRViJT2GfCV7yL1yHGxLb+l3EdM9lluNEnIC9xz+f2ZL4Er6Z2DrdXN3fZwp8CU7OfDHxggle8lTLbQ1nJ/7Z7yKmey5zYGZt4h2IzR8/trRc2PDlxJPTzfVcgJ+CC0wMPOa9F6cm7up3EVM9V9386MxliVdM8GwAv6hh/awCz/w7lY25OtF5ruBz4ZLP42NYNrDAFbC3YPWuILnMAfgq3oaRQQYea/stViV+sgssvjKzLvGySeaaNVfP4d7Btokgvxj/bblgpueuF1hmWcyTCmfE3J3M1lTcv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pJamvlPKgWNKFft1AAcKotXoFEbD7kaoSoQPVKB35+5KHF0lai/rJo+up87jWEE/qqqwY+qrL21LWLm95lPJ16ppKw31XC3PXYPJauPEx7B6BHCgrSizRs18qiaRp8tlN3ueCTYPHH9RNaunjI8Z7wLYpT3jZSCYXQ8e9vTsRE/q+no3XMKeObgGtaintbb/AvXj4JDkNw/5hrwYPfIvlZFUbLn7G5q+eQIN09Vnho6cqvnM/Lt99RixH49wO8K0ZL41WTWHoQzvsNVkOheZqKhEGpsp3SzB+BBtZAYve7uOR9tuTaaB6l0XScdYfEQPpkTUyHEGP+XqyDBzu+NBCITUjNWHynkrbWKOuWFn1xKzqsyx0bdvS78odp0+N503Zao0uCsWuSIDku8/7EO60b41vN5+Ses9BKlTdvd8bhp9EBvJjWJAIn/vxwHe6b3tSk6JFPV4nq85oAOrx555v/x/rh3E6Lo+bnuNS4uB4Cuq0ZfvO8X1rM6q/+vnjLVqZq7v83onttc2oYF4HPJmv1gWbB4P7s0l55ZsPhcsmY/WBYs3s8uzaVn5q3F/wf70mRuBCtbjQAAAABJRU5ErkJggg==', | ||
}, | ||
}).then((response: any) => { | ||
if (response.status !== 200 && response.status !== 409) { | ||
throw new Error(`Failed to create space test`); | ||
} | ||
}); | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* 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 { FtrConfigProviderContext } from '@kbn/test'; | ||
|
||
import { FleetCypressCliTestRunner } from './runner'; | ||
|
||
export default async function ({ readConfigFile }: FtrConfigProviderContext) { | ||
const cypressConfig = await readConfigFile(require.resolve('./config.space_awareness.ts')); | ||
return { | ||
...cypressConfig.getAll(), | ||
|
||
testRunner: FleetCypressCliTestRunner, | ||
}; | ||
} |
Oops, something went wrong.