-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1969 from DaoDaoNoCode/upstream-issue-1912
Adapt custom serving runtimes to KServe
- Loading branch information
Showing
19 changed files
with
427 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
frontend/src/__tests__/integration/pages/customServingRuntimes/CustomServingRuntimes.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test('Custom serving runtimes', async ({ page }) => { | ||
await page.goto( | ||
'./iframe.html?args=&id=tests-integration-pages-customservingruntimes-customservingruntimes--default&viewMode=story', | ||
); | ||
// wait for page to load | ||
await page.waitForSelector('text=Serving runtimes'); | ||
|
||
// check the platform setting labels in the header | ||
await expect(page.getByText('Single model serving enabled')).toBeVisible(); | ||
await expect(page.getByText('Multi-model serving enabled')).toBeHidden(); | ||
|
||
// check the platform labels in the table row | ||
await expect(page.locator('#template-1').getByLabel('Label group category')).toHaveText( | ||
'Single modelMulti-model', | ||
); | ||
await expect(page.locator('#template-2').getByLabel('Label group category')).toHaveText( | ||
'Multi-model', | ||
); | ||
await expect(page.locator('#template-3').getByLabel('Label group category')).toHaveText( | ||
'Single modelMulti-model', | ||
); | ||
}); |
73 changes: 73 additions & 0 deletions
73
...d/src/__tests__/integration/pages/customServingRuntimes/CustomServingRuntimes.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import React from 'react'; | ||
|
||
import { StoryFn, Meta, StoryObj } from '@storybook/react'; | ||
import { rest } from 'msw'; | ||
import { within } from '@storybook/testing-library'; | ||
import { Route, Routes } from 'react-router-dom'; | ||
import { mockK8sResourceList } from '~/__mocks__/mockK8sResourceList'; | ||
import CustomServingRuntimeView from '~/pages/modelServing/customServingRuntimes/CustomServingRuntimeView'; | ||
import { mockServingRuntimeTemplateK8sResource } from '~/__mocks__/mockServingRuntimeTemplateK8sResource'; | ||
import CustomServingRuntimeContextProvider from '~/pages/modelServing/customServingRuntimes/CustomServingRuntimeContext'; | ||
import { mockStatus } from '~/__mocks__/mockStatus'; | ||
import { mockProjectK8sResource } from '~/__mocks__/mockProjectK8sResource'; | ||
import useDetectUser from '~/utilities/useDetectUser'; | ||
import { mockDashboardConfig } from '~/__mocks__/mockDashboardConfig'; | ||
import { ServingRuntimePlatform } from '~/types'; | ||
|
||
export default { | ||
component: CustomServingRuntimeView, | ||
parameters: { | ||
msw: { | ||
handlers: [ | ||
rest.get('/api/status', (req, res, ctx) => res(ctx.json(mockStatus()))), | ||
rest.get('/api/templates/opendatahub', (req, res, ctx) => | ||
res( | ||
ctx.json( | ||
mockK8sResourceList([ | ||
mockServingRuntimeTemplateK8sResource({ | ||
platforms: [ServingRuntimePlatform.SINGLE, ServingRuntimePlatform.MULTI], | ||
}), | ||
mockServingRuntimeTemplateK8sResource({ | ||
name: 'template-2', | ||
displayName: 'Multi-model Serving Runtime', | ||
platforms: [ServingRuntimePlatform.MULTI], | ||
}), | ||
mockServingRuntimeTemplateK8sResource({ | ||
name: 'template-3', | ||
displayName: 'Serving Runtime with No Annotations', | ||
}), | ||
]), | ||
), | ||
), | ||
), | ||
rest.get('/api/k8s/apis/project.openshift.io/v1/projects', (req, res, ctx) => | ||
res(ctx.json(mockK8sResourceList([mockProjectK8sResource({})]))), | ||
), | ||
rest.get('/api/dashboardConfig/opendatahub/odh-dashboard-config', (req, res, ctx) => | ||
res(ctx.json(mockDashboardConfig({}))), | ||
), | ||
], | ||
}, | ||
}, | ||
} as Meta<typeof CustomServingRuntimeView>; | ||
|
||
const Template: StoryFn<typeof CustomServingRuntimeView> = (args) => { | ||
useDetectUser(); | ||
return ( | ||
<Routes> | ||
<Route path="/" element={<CustomServingRuntimeContextProvider />}> | ||
<Route index element={<CustomServingRuntimeView {...args} />} /> | ||
</Route> | ||
</Routes> | ||
); | ||
}; | ||
|
||
export const Default: StoryObj = { | ||
render: Template, | ||
|
||
play: async ({ canvasElement }) => { | ||
// load page and wait until settled | ||
const canvas = within(canvasElement); | ||
await canvas.findByText('Serving runtimes', undefined, { timeout: 5000 }); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.