Skip to content

Commit

Permalink
[8.x] [Search] [Onboarding] unskip FTR tests (#202818) (#203494)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.x`:
- [[Search] [Onboarding] unskip FTR tests
(#202818)](#202818)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Joe
McElroy","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-05T10:02:11Z","message":"[Search]
[Onboarding] unskip FTR tests (#202818)\n\n## Summary\r\n\r\nUpdates the
API Key specific tests to retry by deleting the api keys
and\r\nreloading and perform test again.\r\n\r\n\r\n###
Checklist\r\n\r\nCheck the PR satisfies following conditions.
\r\n\r\nReviewers should verify this PR satisfies this list as
well.\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] If a plugin
configuration key changed, check if it needs to be\r\nallowlisted in the
cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\r\nchanges have been approved by the breaking-change committee.
The\r\n`release_note:breaking` label should be applied in these
situations.\r\n- [x] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [ ] The PR description includes
the appropriate Release Notes section,\r\nand the correct
`release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"486bdbf3fe8482d88a5f33d9845378901509a454","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport
missing","v9.0.0","Team:Search","backport:prev-minor"],"number":202818,"url":"https://github.com/elastic/kibana/pull/202818","mergeCommit":{"message":"[Search]
[Onboarding] unskip FTR tests (#202818)\n\n## Summary\r\n\r\nUpdates the
API Key specific tests to retry by deleting the api keys
and\r\nreloading and perform test again.\r\n\r\n\r\n###
Checklist\r\n\r\nCheck the PR satisfies following conditions.
\r\n\r\nReviewers should verify this PR satisfies this list as
well.\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] If a plugin
configuration key changed, check if it needs to be\r\nallowlisted in the
cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\r\nchanges have been approved by the breaking-change committee.
The\r\n`release_note:breaking` label should be applied in these
situations.\r\n- [x] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [ ] The PR description includes
the appropriate Release Notes section,\r\nand the correct
`release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"486bdbf3fe8482d88a5f33d9845378901509a454"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202818","number":202818,"mergeCommit":{"message":"[Search]
[Onboarding] unskip FTR tests (#202818)\n\n## Summary\r\n\r\nUpdates the
API Key specific tests to retry by deleting the api keys
and\r\nreloading and perform test again.\r\n\r\n\r\n###
Checklist\r\n\r\nCheck the PR satisfies following conditions.
\r\n\r\nReviewers should verify this PR satisfies this list as
well.\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] If a plugin
configuration key changed, check if it needs to be\r\nallowlisted in the
cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\r\nchanges have been approved by the breaking-change committee.
The\r\n`release_note:breaking` label should be applied in these
situations.\r\n- [x] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [ ] The PR description includes
the appropriate Release Notes section,\r\nand the correct
`release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"486bdbf3fe8482d88a5f33d9845378901509a454"}}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
joemcelroy and kibanamachine authored Dec 9, 2024
1 parent 71bfa26 commit bf2a32b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
18 changes: 17 additions & 1 deletion x-pack/test_serverless/functional/page_objects/svl_api_keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import expect from '@kbn/expect';
import { SecurityApiKey } from '@elastic/elasticsearch/lib/api/types';
import { FtrProviderContext } from '../ftr_provider_context';

const APIKEY_MASK = '•'.repeat(60);
Expand All @@ -27,6 +28,10 @@ export function SvlApiKeysProvider({ getService, getPageObjects }: FtrProviderCo
await browser.clearSessionStorage();
},

async expectAPIKeyExists() {
await testSubjects.existOrFail('apiKeyFormAPIKey', { timeout: 1000 });
},

async expectAPIKeyAvailable() {
await testSubjects.existOrFail('apiKeyFormAPIKey');
await retry.try(async () => {
Expand Down Expand Up @@ -84,8 +89,19 @@ export function SvlApiKeysProvider({ getService, getPageObjects }: FtrProviderCo
},

async deleteAPIKeys() {
const filterInvalid = (key: SecurityApiKey) => !key.invalidated;

const { api_keys: apiKeys } = await es.security.getApiKey();
await es.security.invalidateApiKey({ ids: apiKeys.map((key) => key.id) });

const validKeys = apiKeys.filter(filterInvalid);

if (validKeys.length === 0) {
return;
}

await es.security.invalidateApiKey({
ids: validKeys.map((key) => key.id),
});
},

async expectCreateApiKeyAction() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const esDeleteAllIndices = getService('esDeleteAllIndices');
const es = getService('es');
const browser = getService('browser');
const retry = getService('retry');

const deleteAllTestIndices = async () => {
await esDeleteAllIndices(['search-*', 'test-*']);
Expand Down Expand Up @@ -95,7 +96,20 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
it('should show the api key in code view', async () => {
await pageObjects.svlSearchElasticsearchStartPage.expectToBeOnStartPage();
await pageObjects.svlSearchElasticsearchStartPage.clickCodeViewButton();
// sometimes the API key exists in the cluster and its lost in sessionStorage
// if fails we retry to delete the API key and refresh the browser
await retry.try(
async () => {
await pageObjects.svlApiKeys.expectAPIKeyExists();
},
async () => {
await pageObjects.svlApiKeys.deleteAPIKeys();
await browser.refresh();
await pageObjects.svlSearchElasticsearchStartPage.clickCodeViewButton();
}
);
await pageObjects.svlApiKeys.expectAPIKeyAvailable();

const apiKeyUI = await pageObjects.svlApiKeys.getAPIKeyFromUI();
const apiKeySession = await pageObjects.svlApiKeys.getAPIKeyFromSessionStorage();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const svlSearchNavigation = getService('svlSearchNavigation');
const es = getService('es');
const security = getService('security');
const browser = getService('browser');
const retry = getService('retry');

const esDeleteAllIndices = getService('esDeleteAllIndices');
const indexName = 'test-my-index';
Expand Down Expand Up @@ -89,6 +91,27 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await svlSearchNavigation.navigateToIndexDetailPage(indexName);
});

describe('API key details', () => {
it('should show api key', async () => {
await pageObjects.svlApiKeys.deleteAPIKeys();
await svlSearchNavigation.navigateToIndexDetailPage(indexName);
// sometimes the API key exists in the cluster and its lost in sessionStorage
// if fails we retry to delete the API key and refresh the browser
await retry.try(
async () => {
await pageObjects.svlApiKeys.expectAPIKeyExists();
},
async () => {
await pageObjects.svlApiKeys.deleteAPIKeys();
await browser.refresh();
}
);
await pageObjects.svlApiKeys.expectAPIKeyAvailable();
const apiKey = await pageObjects.svlApiKeys.getAPIKeyFromUI();
await pageObjects.svlSearchIndexDetailPage.expectAPIKeyToBeVisibleInCodeBlock(apiKey);
});
});

it('should show code examples for adding documents', async () => {
await pageObjects.svlSearchIndexDetailPage.expectAddDocumentCodeExamples();
await pageObjects.svlSearchIndexDetailPage.expectSelectedLanguage('python');
Expand Down

0 comments on commit bf2a32b

Please sign in to comment.