Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.17] [Index Management FTR] Improve delete indices test (#200941) #201318

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions x-pack/test/functional/page_objects/index_management_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,33 @@ export function IndexManagementPageProvider({ getService }: FtrProviderContext)
},

async expectIndexIsDeleted(indexName: string) {
const table = await find.byCssSelector('table');
const rows = await table.findAllByTestSubject('indexTableRow');
const indexNames: string[] = await Promise.all(
rows.map(async (row) => {
return await (await row.findByTestSubject('indexTableIndexNameLink')).getVisibleText();
})
);
expect(indexNames.includes(indexName)).to.be(false);
try {
const table = await find.byCssSelector('table');
const rows = await table.findAllByTestSubject('indexTableRow');

const indexNames = await Promise.all(
rows.map(async (row) => {
try {
return await (
await row.findByTestSubject('indexTableIndexNameLink')
).getVisibleText();
} catch (error) {
// If the current row is stale, it has already been removed
if (error.name === 'StaleElementReferenceError') return undefined;
throw error; // Rethrow unexpected errors
}
})
).then((names) => names.filter((name) => name !== undefined));

expect(indexNames.includes(indexName)).to.be(false);
} catch (error) {
if (error.name === 'StaleElementReferenceError') {
// If the table itself is stale, it means all rows have been removed
return; // Pass the test since the table is gone
} else {
throw error; // Rethrow unexpected errors
}
}
},
async manageIndex(indexName: string) {
const id = `checkboxSelectIndex-${indexName}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const esDeleteAllIndices = getService('esDeleteAllIndices');
const testIndexName = `index-ftr-test-${Math.random()}`;
const es = getService('es');
const retry = getService('retry');

describe('Indices', function () {
this.tags(['skipSvlSearch']);
Expand Down Expand Up @@ -73,7 +74,9 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});
it('can delete index', async () => {
await pageObjects.indexManagement.confirmDeleteModalIsVisible();
await pageObjects.indexManagement.expectIndexIsDeleted(testIndexName);
await retry.try(async () => {
await pageObjects.indexManagement.expectIndexIsDeleted(testIndexName);
});
});
});
});
Expand Down