Skip to content

Commit

Permalink
[7.17] [esArchiver] Do not perform SO migration on cleanup (#163302) (#…
Browse files Browse the repository at this point in the history
…165566)

# Backport

This will backport the following commits from `main` to `7.17`:
- [[esArchiver] Do not perform SO migration on cleanup
(#163302)](#163302)

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

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

<!--BACKPORT [{"author":{"name":"Gerard
Soldevila","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-09-01T10:41:20Z","message":"[esArchiver]
Do not perform SO migration on cleanup (#163302)\n\n##
Summary\r\n\r\nAttempt at fixing
https://github.com/elastic/kibana/issues/127545\r\n\r\nThe failing tests
use `esArchiver` to cleanup Saved Object indices\r\nbetween
tests.\r\nStrangely, the cleanup method calls the migration logic to
update the SO\r\nindices.\r\n\r\nIn this particular source of flakiness,
a test fails during the\r\nmigration (problem is tracked
by\r\nhttps://github.com//issues/163289).\r\n\r\nPerforming
a migration as part of the cleanup does not make too much\r\nsense (at
least in this test suite), so the goal of this PR is to\r\nsimplify the
cleanup operation, getting rid of the call
to\r\n`migrateSavedObjectIndices`.\r\n\r\n50 runs flaky test
runner\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2850\r\n✅","sha":"f8303ec7cf57aa8787331ada397dfa853de969c9","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","Team:Core","Team:Operations","release_note:skip","test-failure-flaky","backport:all-open","v8.10.0","v8.11.0"],"number":163302,"url":"https://github.com/elastic/kibana/pull/163302","mergeCommit":{"message":"[esArchiver]
Do not perform SO migration on cleanup (#163302)\n\n##
Summary\r\n\r\nAttempt at fixing
https://github.com/elastic/kibana/issues/127545\r\n\r\nThe failing tests
use `esArchiver` to cleanup Saved Object indices\r\nbetween
tests.\r\nStrangely, the cleanup method calls the migration logic to
update the SO\r\nindices.\r\n\r\nIn this particular source of flakiness,
a test fails during the\r\nmigration (problem is tracked
by\r\nhttps://github.com//issues/163289).\r\n\r\nPerforming
a migration as part of the cleanup does not make too much\r\nsense (at
least in this test suite), so the goal of this PR is to\r\nsimplify the
cleanup operation, getting rid of the call
to\r\n`migrateSavedObjectIndices`.\r\n\r\n50 runs flaky test
runner\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2850\r\n✅","sha":"f8303ec7cf57aa8787331ada397dfa853de969c9"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"8.10","label":"v8.10.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/165451","number":165451,"state":"MERGED","mergeCommit":{"sha":"8ea7cee5003c3bfb550da9ab1fab8e9bfe820250","message":"[8.10]
[esArchiver] Do not perform SO migration on cleanup (#163302)
(#165451)\n\n# Backport\n\nThis will backport the following commits from
`main` to `8.10`:\n- [[esArchiver] Do not perform SO migration on
cleanup\n(#163302)](https://github.com/elastic/kibana/pull/163302)\n\n<!---
Backport version: 8.9.7 -->\n\n### Questions ?\nPlease refer to the
[Backport
tool\ndocumentation](https://github.com/sqren/backport)\n\n<!--BACKPORT
[{\"author\":{\"name\":\"Gerard\nSoldevila\",\"email\":\"[email protected]\"},\"sourceCommit\":{\"committedDate\":\"2023-09-01T10:41:20Z\",\"message\":\"[esArchiver]\nDo
not perform SO migration on cleanup
(#163302)\\n\\n##\nSummary\\r\\n\\r\\nAttempt at
fixing\nhttps://github.com//issues/127545\\r\\n\\r\\nThe
failing tests\nuse `esArchiver` to cleanup Saved Object
indices\\r\\nbetween\ntests.\\r\\nStrangely, the cleanup method calls
the migration logic to\nupdate the SO\\r\\nindices.\\r\\n\\r\\nIn this
particular source of flakiness,\na test fails during the\\r\\nmigration
(problem is
tracked\nby\\r\\nhttps://github.com//issues/163289).\\r\\n\\r\\nPerforming\na
migration as part of the cleanup does not make too much\\r\\nsense
(at\nleast in this test suite), so the goal of this PR is
to\\r\\nsimplify the\ncleanup operation, getting rid of the
call\nto\\r\\n`migrateSavedObjectIndices`.\\r\\n\\r\\n50 runs flaky
test\nrunner\\r\\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2850\\r\\n✅\",\"sha\":\"f8303ec7cf57aa8787331ada397dfa853de969c9\",\"branchLabelMapping\":{\"^v8.11.0$\":\"main\",\"^v(\\\\d+).(\\\\d+).\\\\d+$\":\"$1.$2\"}},\"sourcePullRequest\":{\"labels\":[\"bug\",\"Team:Core\",\"Team:Operations\",\"release_note:skip\",\"test-failure-flaky\",\"backport:all-open\",\"v8.11.0\"],\"number\":163302,\"url\":\"https://github.com/elastic/kibana/pull/163302\",\"mergeCommit\":{\"message\":\"[esArchiver]\nDo
not perform SO migration on cleanup
(#163302)\\n\\n##\nSummary\\r\\n\\r\\nAttempt at
fixing\nhttps://github.com//issues/127545\\r\\n\\r\\nThe
failing tests\nuse `esArchiver` to cleanup Saved Object
indices\\r\\nbetween\ntests.\\r\\nStrangely, the cleanup method calls
the migration logic to\nupdate the SO\\r\\nindices.\\r\\n\\r\\nIn this
particular source of flakiness,\na test fails during the\\r\\nmigration
(problem is
tracked\nby\\r\\nhttps://github.com//issues/163289).\\r\\n\\r\\nPerforming\na
migration as part of the cleanup does not make too much\\r\\nsense
(at\nleast in this test suite), so the goal of this PR is
to\\r\\nsimplify the\ncleanup operation, getting rid of the
call\nto\\r\\n`migrateSavedObjectIndices`.\\r\\n\\r\\n50 runs flaky
test\nrunner\\r\\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2850\\r\\n✅\",\"sha\":\"f8303ec7cf57aa8787331ada397dfa853de969c9\"}},\"sourceBranch\":\"main\",\"suggestedTargetBranches\":[],\"targetPullRequestStates\":[{\"branch\":\"main\",\"label\":\"v8.11.0\",\"labelRegex\":\"^v8.11.0$\",\"isSourceBranch\":true,\"state\":\"MERGED\",\"url\":\"https://github.com/elastic/kibana/pull/163302\",\"number\":163302,\"mergeCommit\":{\"message\":\"[esArchiver]\nDo
not perform SO migration on cleanup
(#163302)\\n\\n##\nSummary\\r\\n\\r\\nAttempt at
fixing\nhttps://github.com//issues/127545\\r\\n\\r\\nThe
failing tests\nuse `esArchiver` to cleanup Saved Object
indices\\r\\nbetween\ntests.\\r\\nStrangely, the cleanup method calls
the migration logic to\nupdate the SO\\r\\nindices.\\r\\n\\r\\nIn this
particular source of flakiness,\na test fails during the\\r\\nmigration
(problem is
tracked\nby\\r\\nhttps://github.com//issues/163289).\\r\\n\\r\\nPerforming\na
migration as part of the cleanup does not make too much\\r\\nsense
(at\nleast in this test suite), so the goal of this PR is
to\\r\\nsimplify the\ncleanup operation, getting rid of the
call\nto\\r\\n`migrateSavedObjectIndices`.\\r\\n\\r\\n50 runs flaky
test\nrunner\\r\\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2850\\r\\n✅\",\"sha\":\"f8303ec7cf57aa8787331ada397dfa853de969c9\"}}]}]\nBACKPORT-->\n\nCo-authored-by:
Gerard Soldevila
<[email protected]>"}},{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/163302","number":163302,"mergeCommit":{"message":"[esArchiver]
Do not perform SO migration on cleanup (#163302)\n\n##
Summary\r\n\r\nAttempt at fixing
https://github.com/elastic/kibana/issues/127545\r\n\r\nThe failing tests
use `esArchiver` to cleanup Saved Object indices\r\nbetween
tests.\r\nStrangely, the cleanup method calls the migration logic to
update the SO\r\nindices.\r\n\r\nIn this particular source of flakiness,
a test fails during the\r\nmigration (problem is tracked
by\r\nhttps://github.com//issues/163289).\r\n\r\nPerforming
a migration as part of the cleanup does not make too much\r\nsense (at
least in this test suite), so the goal of this PR is to\r\nsimplify the
cleanup operation, getting rid of the call
to\r\n`migrateSavedObjectIndices`.\r\n\r\n50 runs flaky test
runner\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2850\r\n✅","sha":"f8303ec7cf57aa8787331ada397dfa853de969c9"}}]}]
BACKPORT-->
  • Loading branch information
gsoldevila authored Sep 25, 2023
1 parent f402856 commit 757e867
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 25 deletions.
12 changes: 5 additions & 7 deletions packages/kbn-es-archiver/src/actions/empty_kibana_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,22 @@
*/

import type { KibanaClient } from '@elastic/elasticsearch/api/kibana';
import { ToolingLog } from '@kbn/dev-utils';
import { KbnClient } from '@kbn/test';
import type { ToolingLog } from '@kbn/dev-utils';

import { migrateSavedObjectIndex, createStats, cleanSavedObjectIndices } from '../lib';
import { createStats, cleanSavedObjectIndices } from '../lib';
import { ALL_SAVED_OBJECT_INDICES } from '../lib/indices/constants';

export async function emptyKibanaIndexAction({
client,
log,
kbnClient,
}: {
client: KibanaClient;
log: ToolingLog;
kbnClient: KbnClient;
}) {
const stats = createStats('emptyKibanaIndex', log);

await cleanSavedObjectIndices({ client, stats, log });
await migrateSavedObjectIndex({ kbnClient });
stats.createdIndex('.kibana');
await client.indices.refresh({ index: ALL_SAVED_OBJECT_INDICES });

return stats.toJSON();
}
4 changes: 1 addition & 3 deletions packages/kbn-es-archiver/src/es_archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,12 @@ export class EsArchiver {
}

/**
* Delete any Kibana indices, and initialize the Kibana index as Kibana would do
* on startup.
* Cleanup saved object indices, preserving the space:default saved object.
*/
async emptyKibanaIndex() {
return await emptyKibanaIndexAction({
client: this.client,
log: this.log,
kbnClient: this.kbnClient,
});
}

Expand Down
10 changes: 6 additions & 4 deletions packages/kbn-es-archiver/src/lib/indices/kibana_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import { inspect } from 'util';

import type { KibanaClient } from '@elastic/elasticsearch/api/kibana';
import type { estypes } from '@elastic/elasticsearch';
import { ToolingLog } from '@kbn/dev-utils';
import { KbnClient } from '@kbn/test';
import { Stats } from '../stats';
import type { ToolingLog } from '@kbn/dev-utils';
import type { KbnClient } from '@kbn/test';
import { kibanaPackageJson } from '@kbn/utils';
import type { Stats } from '../stats';
import { deleteIndex } from './delete_index';
import { ES_CLIENT_HEADERS } from '../../client_headers';
import {
Expand Down Expand Up @@ -123,7 +124,8 @@ export async function cleanSavedObjectIndices({
bool: {
must_not: {
ids: {
values: ['space:default'],
// preserve the default space and the default config
values: ['space:default', `config:${kibanaPackageJson.version}`],
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion test/common/services/kibana_server/extend_es_archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function extendEsArchiver({ esArchiver, kibanaServer, retry, defaults }:
ES_ARCHIVER_LOAD_METHODS.forEach((method) => {
const originalMethod = esArchiver[method];

esArchiver[method] = async (...args: unknown[]) => {
esArchiver[method] = async (...args: any[]) => {
// esArchiver methods return a stats object, with information about the indexes created
const stats = await originalMethod.apply(esArchiver, args as any);

Expand Down
3 changes: 2 additions & 1 deletion test/functional/page_objects/home_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export class HomePageObject extends FtrService {
}

async isWelcomeInterstitialDisplayed() {
return await this.testSubjects.isDisplayed('homeWelcomeInterstitial');
await this.common.sleep(500); // give the interstitial enough time to fade in
return await this.testSubjects.isDisplayed('homeWelcomeInterstitial', 2000);
}

async getVisibileSolutions() {
Expand Down
5 changes: 5 additions & 0 deletions test/functional/services/common/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ class BrowserService extends FtrService {
return await this.driver.manage().window().getRect();
}

public async getWindowInnerSize(): Promise<{ height: number; width: number }> {
const JS_GET_INNER_WIDTH = 'return { width: window.innerWidth, height: window.innerHeight };';
return await this.driver.executeScript(JS_GET_INNER_WIDTH);
}

/**
* Sets the dimensions of a window.
* https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_Window.html
Expand Down
4 changes: 2 additions & 2 deletions test/functional/services/common/test_subjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ export class TestSubjects extends FtrService {
return await element.isEnabled();
}

public async isDisplayed(selector: string): Promise<boolean> {
public async isDisplayed(selector: string, timeout?: number): Promise<boolean> {
this.log.debug(`TestSubjects.isDisplayed(${selector})`);
const element = await this.find(selector);
const element = await this.find(selector, timeout);
return await element.isDisplayed();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide
before(async () => {
await esArchiver.emptyKibanaIndex();
await PageObjects.common.navigateToApp('foo');
await PageObjects.common.dismissBanner();
});

it('starts on home page', async () => {
Expand Down Expand Up @@ -125,7 +126,7 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide
expect(await testSubjects.exists('headerGlobalNav')).to.be(false);

const wrapperHeight = await getAppWrapperHeight();
const windowHeight = (await browser.getWindowSize()).height;
const windowHeight = (await browser.getWindowInnerSize()).height;
expect(wrapperHeight).to.eql(windowHeight);
});

Expand All @@ -135,7 +136,7 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide
expect(await testSubjects.exists('headerGlobalNav')).to.be(true);

const wrapperHeight = await getAppWrapperHeight();
const windowHeight = (await browser.getWindowSize()).height;
const windowHeight = (await browser.getWindowInnerSize()).height;
expect(wrapperHeight).to.be.below(windowHeight);
});
});
Expand Down
17 changes: 13 additions & 4 deletions x-pack/test/functional/apps/dashboard/_async_dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});

it('should launch sample flights data set dashboard', async () => {
await appMenu.clickLink('Dashboard');
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.loadSavedDashboard('[Flights] Global Flight Dashboard');
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.timePicker.setCommonlyUsedTime('sample_data range');
Expand All @@ -144,7 +144,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const hitCount = parseInt(await PageObjects.discover.getHitCount(), 10);
expect(hitCount).to.be.greaterThan(0);
});
await appMenu.clickLink('Dashboard');
await appMenu.clickLink('Dashboard', {
category: 'recentlyViewed',
closeCollapsibleNav: true,
});
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();
log.debug('Checking charts rendered');
Expand All @@ -157,7 +160,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const hitCount = parseInt(await PageObjects.discover.getHitCount(), 10);
expect(hitCount).to.be.greaterThan(0);
});
await appMenu.clickLink('Dashboard');
await appMenu.clickLink('Dashboard', {
category: 'recentlyViewed',
closeCollapsibleNav: true,
});
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();
log.debug('Checking charts rendered');
Expand All @@ -170,7 +176,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const hitCount = parseInt(await PageObjects.discover.getHitCount(), 10);
expect(hitCount).to.be.greaterThan(0);
});
await appMenu.clickLink('Dashboard');
await appMenu.clickLink('Dashboard', {
category: 'recentlyViewed',
closeCollapsibleNav: true,
});
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();
log.debug('Checking charts rendered');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
});

if (!saveToDashboard) {
await appsMenu.clickLink('Dashboard');
await appsMenu.clickLink('Dashboard', {
category: 'kibana',
closeCollapsibleNav: true,
});
}
} else {
await PageObjects.maps.clickSaveAndReturnButton();
Expand Down
3 changes: 3 additions & 0 deletions x-pack/test/functional/apps/discover/reporting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
};

const getReport = async () => {
// close any open notification toasts
await PageObjects.reporting.clearToastNotifications();

await PageObjects.reporting.openCsvReportingPanel();
await PageObjects.reporting.clickGenerateReportButton();

Expand Down

0 comments on commit 757e867

Please sign in to comment.