Skip to content

Commit

Permalink
[8.x] Support incoming Preconfigured Endpoints (elastic#203473) (elas…
Browse files Browse the repository at this point in the history
…tic#203690)

# Backport

This will backport the following commits from `main` to `8.x`:
- [Support incoming Preconfigured Endpoints
(elastic#203473)](elastic#203473)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Samiul
Monir","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-10T21:09:31Z","message":"Support
incoming Preconfigured Endpoints (elastic#203473)\n\n##
Summary\r\n\r\nCurrently, the FTR tests are written to expect only two
preconfigured\r\nendpoints. However, there might be more incoming, and
this PR\r\ngeneralizes these tests so they do not depend on the number
of\r\npreconfigured endpoints in the future.\r\n\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- [X] 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-
[X] [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\r\n---------\r\n\r\nCo-authored-by: Elastic Machine
<[email protected]>","sha":"a5c9ed7bb8652807e11ab6eac2979b61fa239b2c","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Search","ci:build-serverless-image","backport:version","v8.18.0"],"title":"Support
incoming Preconfigured
Endpoints","number":203473,"url":"https://github.com/elastic/kibana/pull/203473","mergeCommit":{"message":"Support
incoming Preconfigured Endpoints (elastic#203473)\n\n##
Summary\r\n\r\nCurrently, the FTR tests are written to expect only two
preconfigured\r\nendpoints. However, there might be more incoming, and
this PR\r\ngeneralizes these tests so they do not depend on the number
of\r\npreconfigured endpoints in the future.\r\n\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- [X] 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-
[X] [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\r\n---------\r\n\r\nCo-authored-by: Elastic Machine
<[email protected]>","sha":"a5c9ed7bb8652807e11ab6eac2979b61fa239b2c"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203473","number":203473,"mergeCommit":{"message":"Support
incoming Preconfigured Endpoints (elastic#203473)\n\n##
Summary\r\n\r\nCurrently, the FTR tests are written to expect only two
preconfigured\r\nendpoints. However, there might be more incoming, and
this PR\r\ngeneralizes these tests so they do not depend on the number
of\r\npreconfigured endpoints in the future.\r\n\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- [X] 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-
[X] [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\r\n---------\r\n\r\nCo-authored-by: Elastic Machine
<[email protected]>","sha":"a5c9ed7bb8652807e11ab6eac2979b61fa239b2c"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Samiul Monir <[email protected]>
  • Loading branch information
kibanamachine and Samiul-TheSoccerFan authored Dec 10, 2024
1 parent 96c4fe3 commit 2bedac7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ describe('Delete Action', () => {
it('renders', () => {
render(<Wrapper item={mockItem} />);

expect(screen.getByTestId('inferenceUIDeleteAction')).toBeEnabled();
expect(screen.getByTestId(/inferenceUIDeleteAction/)).toBeEnabled();
});

it('disable the delete action for preconfigured endpoint', () => {
const preconfiguredMockItem = { ...mockItem, endpoint: '.multilingual-e5-small-elasticsearch' };
render(<Wrapper item={preconfiguredMockItem} />);

expect(screen.getByTestId('inferenceUIDeleteAction')).toBeDisabled();
expect(screen.getByTestId(/inferenceUIDeleteAction/)).toBeDisabled();
});

it('loads confirm delete modal', () => {
render(<Wrapper item={mockItem} />);

fireEvent.click(screen.getByTestId('inferenceUIDeleteAction'));
fireEvent.click(screen.getByTestId(/inferenceUIDeleteAction/));
expect(screen.getByTestId('deleteModalForInferenceUI')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@ export const DeleteAction: React.FC<DeleteActionProps> = ({ selectedEndpoint })
});
};

const isPreconfigured = isEndpointPreconfigured(selectedEndpoint.endpoint);
const testSubj = `inferenceUIDeleteAction-${isPreconfigured ? 'preconfigured' : 'user-defined'}`;

return (
<>
<EuiButtonIcon
aria-label={i18n.translate('xpack.searchInferenceEndpoints.actions.deleteEndpoint', {
defaultMessage: 'Delete inference endpoint {selectedEndpointName}',
values: { selectedEndpointName: selectedEndpoint.endpoint },
})}
data-test-subj="inferenceUIDeleteAction"
disabled={isEndpointPreconfigured(selectedEndpoint.endpoint)}
data-test-subj={testSubj}
disabled={isPreconfigured}
key="delete"
iconType="trash"
color="danger"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe('When the tabular page is loaded', () => {
it('should only disable delete action for preconfigured endpoints', () => {
render(<TabularPage inferenceEndpoints={inferenceEndpoints} />);

const deleteActions = screen.getAllByTestId('inferenceUIDeleteAction');
const deleteActions = screen.getAllByTestId(/inferenceUIDeleteAction/);

expect(deleteActions[0]).toBeDisabled();
expect(deleteActions[1]).toBeDisabled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,53 +27,29 @@ export function SvlSearchInferenceManagementPageProvider({ getService }: FtrProv

const table = await testSubjects.find('inferenceEndpointTable');
const rows = await table.findAllByClassName('euiTableRow');
expect(rows.length).to.equal(2);
// we need at least one (ELSER) otherwise index_mapping might experience some issues
expect(rows.length).to.greaterThan(1);

const elserEndpointCell = await rows[0].findByTestSubject('endpointCell');
const elserEndpointName = await elserEndpointCell.getVisibleText();
expect(elserEndpointName).to.contain('.elser-2-elasticsearch');
const texts = await Promise.all(rows.map((row) => row.getVisibleText()));
const hasElser2 = texts.some((text) => text.includes('.elser-2'));
const hasE5 = texts.some((text) => text.includes('.multilingual-e5'));

const elserProviderCell = await rows[0].findByTestSubject('providerCell');
const elserProviderName = await elserProviderCell.getVisibleText();
expect(elserProviderName).to.contain('Elasticsearch');
expect(elserProviderName).to.contain('.elser_model_2');

const elserTypeCell = await rows[0].findByTestSubject('typeCell');
const elserTypeName = await elserTypeCell.getVisibleText();
expect(elserTypeName).to.contain('sparse_embedding');

const e5EndpointCell = await rows[1].findByTestSubject('endpointCell');
const e5EndpointName = await e5EndpointCell.getVisibleText();
expect(e5EndpointName).to.contain('.multilingual-e5-small-elasticsearch');

const e5ProviderCell = await rows[1].findByTestSubject('providerCell');
const e5ProviderName = await e5ProviderCell.getVisibleText();
expect(e5ProviderName).to.contain('Elasticsearch');
expect(e5ProviderName).to.contain('.multilingual-e5-small');

const e5TypeCell = await rows[1].findByTestSubject('typeCell');
const e5TypeName = await e5TypeCell.getVisibleText();
expect(e5TypeName).to.contain('text_embedding');
expect(hasElser2).to.be(true);
expect(hasE5).to.be(true);
},

async expectPreconfiguredEndpointsCannotBeDeleted() {
const table = await testSubjects.find('inferenceEndpointTable');
const rows = await table.findAllByClassName('euiTableRow');

const elserDeleteAction = await rows[0].findByTestSubject('inferenceUIDeleteAction');
const e5DeleteAction = await rows[1].findByTestSubject('inferenceUIDeleteAction');

expect(await elserDeleteAction.isEnabled()).to.be(false);
expect(await e5DeleteAction.isEnabled()).to.be(false);
const preconfigureEndpoints = await testSubjects.findAll(
'inferenceUIDeleteAction-preconfigured'
);
for (const endpoint of preconfigureEndpoints) {
expect(await endpoint.isEnabled()).to.be(false);
}
},

async expectEndpointWithoutUsageTobeDelete() {
const table = await testSubjects.find('inferenceEndpointTable');
const rows = await table.findAllByClassName('euiTableRow');

const userCreatedEndpoint = await rows[2].findByTestSubject('inferenceUIDeleteAction');

await userCreatedEndpoint.click();
const userDefinedEdnpoint = await testSubjects.find('inferenceUIDeleteAction-user-defined');
await userDefinedEdnpoint.click();
await testSubjects.existOrFail('deleteModalForInferenceUI');
await testSubjects.existOrFail('deleteModalInferenceEndpointName');

Expand All @@ -83,12 +59,8 @@ export function SvlSearchInferenceManagementPageProvider({ getService }: FtrProv
},

async expectEndpointWithUsageTobeDelete() {
const table = await testSubjects.find('inferenceEndpointTable');
const rows = await table.findAllByClassName('euiTableRow');

const userCreatedEndpoint = await rows[2].findByTestSubject('inferenceUIDeleteAction');

await userCreatedEndpoint.click();
const userDefinedEdnpoint = await testSubjects.find('inferenceUIDeleteAction-user-defined');
await userDefinedEdnpoint.click();
await testSubjects.existOrFail('deleteModalForInferenceUI');
await testSubjects.existOrFail('deleteModalInferenceEndpointName');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await pageObjects.svlCommonPage.loginWithRole('developer');
});

after(async () => {
await ml.api.cleanMlIndices();
});

beforeEach(async () => {
await svlSearchNavigation.navigateToInferenceManagementPage();
});
Expand Down

0 comments on commit 2bedac7

Please sign in to comment.