Skip to content

Commit

Permalink
Merge pull request #1823 from lucferbux/issue-1785
Browse files Browse the repository at this point in the history
Fix issue displaying error in Inference Service
  • Loading branch information
openshift-merge-robot authored Sep 20, 2023
2 parents 4b2dac9 + 3351661 commit caf5caf
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
22 changes: 22 additions & 0 deletions frontend/src/__mocks__/mockInferenceServiceK8sResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@ type MockResourceConfigType = {
secretName?: string;
};

export const mockInferenceServicek8sError = () => ({
kind: 'Status',
apiVersion: 'v1',
metadata: {},
status: 'Failure',
message:
'InferenceService.serving.kserve.io "trigger-error" is invalid: [metadata.name: Invalid value: "trigger-error": is invalid, metadata.labels: Invalid value: "trigger-error": must have proper format]',
reason: 'Invalid',
details: {
name: 'trigger-error',
group: 'serving.kserve.io',
kind: 'InferenceService',
causes: [
{
reason: 'FieldValueInvalid',
message: 'Invalid value: "trigger-error": must have proper format',
field: 'metadata.name',
},
],
},
});

export const mockInferenceServiceK8sResource = ({
name = 'test-inference-service',
namespace = 'test-project',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,46 @@ test('Create model', async ({ page }) => {
await page.getByLabel('Path').fill('test-model/');
await expect(await page.getByRole('button', { name: 'Deploy' })).toBeEnabled();
});

test('Create model error', async ({ page }) => {
await page.goto(
'./iframe.html?args=&id=tests-integration-pages-modelserving-modelservingglobal--deploy-model&viewMode=story',
);

// wait for page to load
await page.waitForSelector('text=Deploy model');

// test that you can not submit on empty
await expect(await page.getByRole('button', { name: 'Deploy' })).toBeDisabled();

// test filling in minimum required fields
await page.locator('#existing-project-selection').click();
await page.getByRole('option', { name: 'Test Project' }).click();
await page.getByLabel('Model Name *').fill('trigger-error');
await page.locator('#inference-service-model-selection').click();
await page.getByRole('option', { name: 'ovms' }).click();
await expect(page.getByText('Model framework (name - version)')).toBeTruthy();
await page.locator('#inference-service-framework-selection').click();
await page.getByRole('option', { name: 'onnx - 1' }).click();
await expect(await page.getByRole('button', { name: 'Deploy' })).toBeDisabled();
await page
.getByRole('group', { name: 'Model location' })
.getByRole('button', { name: 'Options menu' })
.click();
await page.getByRole('option', { name: 'Test Secret' }).click();
await page.getByLabel('Path').fill('test-model/');
await expect(await page.getByRole('button', { name: 'Deploy' })).toBeEnabled();
await page.getByLabel('Path').fill('test-model/');
await expect(await page.getByRole('button', { name: 'Deploy' })).toBeEnabled();

// Submit and check the invalid error message
await page.getByRole('button', { name: 'Deploy' }).click();
await page.waitForSelector('text=Error creating model server');

// Close the modal
await page.getByRole('button', { name: 'Cancel' }).click();

// Check that the error message is gone
await page.getByRole('button', { name: 'Deploy model' }).click();
expect(await page.isVisible('text=Error creating model server')).toBeFalsy();
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { Route, Routes } from 'react-router-dom';
import { mockK8sResourceList } from '~/__mocks__/mockK8sResourceList';
import { mockProjectK8sResource } from '~/__mocks__/mockProjectK8sResource';
import { mockServingRuntimeK8sResource } from '~/__mocks__/mockServingRuntimeK8sResource';
import { mockInferenceServiceK8sResource } from '~/__mocks__/mockInferenceServiceK8sResource';
import {
mockInferenceServiceK8sResource,
mockInferenceServicek8sError,
} from '~/__mocks__/mockInferenceServiceK8sResource';
import { mockSecretK8sResource } from '~/__mocks__/mockSecretK8sResource';
import ModelServingContextProvider from '~/pages/modelServing/ModelServingContext';
import ModelServingGlobal from '~/pages/modelServing/screens/global/ModelServingGlobal';
Expand Down Expand Up @@ -38,6 +41,15 @@ export default {
rest.get('/api/k8s/apis/project.openshift.io/v1/projects', (req, res, ctx) =>
res(ctx.json(mockK8sResourceList([mockProjectK8sResource({})]))),
),
rest.post(
'api/k8s/apis/serving.kserve.io/v1beta1/namespaces/test-project/inferenceservices/test',
(req, res, ctx) => res(ctx.json(mockInferenceServiceK8sResource({}))),
),
rest.post(
'api/k8s/apis/serving.kserve.io/v1beta1/namespaces/test-project/inferenceservices/trigger-error',
(req, res, ctx) =>
res(ctx.status(422, 'Unprocessable Entity'), ctx.json(mockInferenceServicek8sError())),
),
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const ManageInferenceServiceModal: React.FC<ManageInferenceServiceModalProps> =

const onBeforeClose = (submitted: boolean) => {
onClose(submitted);
setError(undefined);
setActionInProgress(false);
resetData();
};
Expand Down

0 comments on commit caf5caf

Please sign in to comment.