Skip to content

Commit

Permalink
[8.11] Fixes rendering service config keys test (elastic#167937) (ela…
Browse files Browse the repository at this point in the history
…stic#168143)

# Backport

This will backport the following commits from `main` to `8.11`:
- [Fixes rendering service config keys test
(elastic#167937)](elastic#167937)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"Jeramy
Soucy","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-10-05T17:59:19Z","message":"Fixes
rendering service config keys test (elastic#167937)\n\nCloses elastic#167142\r\nCloses
elastic#157126\r\n\r\n## Summary\r\n\r\nFortifies the rendering service tests
by introducing a retry loop to get\r\ninjected metadata after
navigation. The `kbn-injected-metadata` tag that\r\nwe're relying on in
this test gets removed some time after navigation\r\n(e.g. to
`.../render/core`). It appears that occasionally this test\r\nfails to
read the tag before it is removed.\r\n\r\nFlaky test
runner:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3363\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"335a751c00b2743d4e4adf53425f1fb45a54e883","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Security","release_note:skip","backport:all-open","v8.11.0","v8.12.0"],"number":167937,"url":"https://github.com/elastic/kibana/pull/167937","mergeCommit":{"message":"Fixes
rendering service config keys test (elastic#167937)\n\nCloses elastic#167142\r\nCloses
elastic#157126\r\n\r\n## Summary\r\n\r\nFortifies the rendering service tests
by introducing a retry loop to get\r\ninjected metadata after
navigation. The `kbn-injected-metadata` tag that\r\nwe're relying on in
this test gets removed some time after navigation\r\n(e.g. to
`.../render/core`). It appears that occasionally this test\r\nfails to
read the tag before it is removed.\r\n\r\nFlaky test
runner:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3363\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"335a751c00b2743d4e4adf53425f1fb45a54e883"}},"sourceBranch":"main","suggestedTargetBranches":["8.11"],"targetPullRequestStates":[{"branch":"8.11","label":"v8.11.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/167937","number":167937,"mergeCommit":{"message":"Fixes
rendering service config keys test (elastic#167937)\n\nCloses elastic#167142\r\nCloses
elastic#157126\r\n\r\n## Summary\r\n\r\nFortifies the rendering service tests
by introducing a retry loop to get\r\ninjected metadata after
navigation. The `kbn-injected-metadata` tag that\r\nwe're relying on in
this test gets removed some time after navigation\r\n(e.g. to
`.../render/core`). It appears that occasionally this test\r\nfails to
read the tag before it is removed.\r\n\r\nFlaky test
runner:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3363\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"335a751c00b2743d4e4adf53425f1fb45a54e883"}}]}]
BACKPORT-->

Co-authored-by: Jeramy Soucy <[email protected]>
  • Loading branch information
kibanamachine and jeramysoucy authored Oct 5, 2023
1 parent c65f469 commit de6dcb4
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions test/plugin_functional/test_suites/core_plugins/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
const deployment = getService('deployment');
const find = getService('find');
const testSubjects = getService('testSubjects');
const retry = getService('retry');

const navigateTo = async (path: string) =>
await browser.navigateTo(`${deployment.getHostPort()}${path}`);
Expand All @@ -47,7 +48,16 @@ export default function ({ getService }: PluginFunctionalProviderContext) {

const getInjectedMetadata = () =>
browser.execute(() => {
return JSON.parse(document.querySelector('kbn-injected-metadata')!.getAttribute('data')!);
const injectedMetadata = document.querySelector('kbn-injected-metadata');
// null/hasAttribute check and explicit error for better future troublehsooting
// (see https://github.com/elastic/kibana/issues/167142)
// The 'kbn-injected-metadata' tag that we're relying on here gets removed
// some time after navigation (e.g. to /render/core). It appears that
// occasionally this test fails to read the tag before it is removed.
if (!injectedMetadata?.hasAttribute('data')) {
throw new Error(`'kbn-injected-metadata.data' not found.`);
}
return JSON.parse(injectedMetadata.getAttribute('data')!);
});
const getUserSettings = () =>
browser.execute(() => {
Expand All @@ -61,11 +71,17 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
return window.__RENDERING_SESSION__;
});

// Failing: See https://github.com/elastic/kibana/issues/167142
describe.skip('rendering service', () => {
describe('rendering service', () => {
it('exposes plugin config settings to authenticated users', async () => {
await navigateTo('/render/core');
const injectedMetadata = await getInjectedMetadata();
// This retry loop to get the injectedMetadata is to overcome flakiness
// (see comment in getInjectedMetadata)
let injectedMetadata: Partial<{ uiPlugins: any }> = { uiPlugins: undefined };
await retry.waitFor('injectedMetadata', async () => {
await navigateTo('/render/core');
injectedMetadata = await getInjectedMetadata();
return !!injectedMetadata;
});

expect(injectedMetadata).to.not.be.empty();
expect(injectedMetadata.uiPlugins).to.not.be.empty();

Expand Down Expand Up @@ -317,12 +333,19 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
// abundantly clear when the test fails that (A) Kibana is exposing a new key, or (B) Kibana is no longer exposing a key.
const extra = _.difference(actualExposedConfigKeys, expectedExposedConfigKeys).sort();
const missing = _.difference(expectedExposedConfigKeys, actualExposedConfigKeys).sort();

expect({ extra, missing }).to.eql({ extra: [], missing: [] }, EXPOSED_CONFIG_SETTINGS_ERROR);
});

it('exposes plugin config settings to unauthenticated users', async () => {
await navigateTo('/render/core?isAnonymousPage=true');
const injectedMetadata = await getInjectedMetadata();
// This retry loop to get the injectedMetadata is to overcome flakiness
// (see comment in getInjectedMetadata)
let injectedMetadata: Partial<{ uiPlugins: any }> = { uiPlugins: undefined };
await retry.waitFor('injectedMetadata', async () => {
await navigateTo('/render/core?isAnonymousPage=true');
injectedMetadata = await getInjectedMetadata();
return !!injectedMetadata;
});
expect(injectedMetadata).to.not.be.empty();
expect(injectedMetadata.uiPlugins).to.not.be.empty();

Expand Down

0 comments on commit de6dcb4

Please sign in to comment.