Skip to content

Commit

Permalink
test: fix review change requests 2 - see body
Browse files Browse the repository at this point in the history
- Add nim-serving interception to odh intercept type safety mechanism
- Add accelerators interception to odh intercept type safety mechanism

Co-authored-by: Daniele Martinoli <[email protected]>
Co-authored-by: lokeshrangineni <[email protected]>
Signed-off-by: Tomer Figenblat <[email protected]>
  • Loading branch information
3 people committed Oct 7, 2024
1 parent baf470e commit 7da5544
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 19 deletions.
5 changes: 5 additions & 0 deletions frontend/src/__mocks__/mockNimResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from '~/k8sTypes';
import { ServingRuntimeAPIProtocol, ServingRuntimePlatform } from '~/types';
import { mockProjectK8sResource } from '~/__mocks__/mockProjectK8sResource';
import { NimServingResponse } from '~/__tests__/cypress/cypress/types';
import { mockConfigMap } from './mockConfigMap';
import { mockServingRuntimeK8sResource } from './mockServingRuntimeK8sResource';
import { mockInferenceServiceK8sResource } from './mockInferenceServiceK8sResource';
Expand Down Expand Up @@ -138,3 +139,7 @@ export const mockNimModelPVC = (): PersistentVolumeClaimKind => {
});
return pvc;
};

export const mockNimServingResource = (
resource: ConfigMapKind | SecretKind,
): NimServingResponse => ({ body: { body: resource } });
24 changes: 19 additions & 5 deletions frontend/src/__tests__/cypress/cypress/support/commands/odh.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { K8sResourceListResult, K8sStatus } from '@openshift/dynamic-plugin-sdk-utils';
import { K8sResourceCommon, K8sResourceListResult, K8sStatus } from '@openshift/dynamic-plugin-sdk-utils';
import type { GenericStaticResponse, RouteHandlerController } from 'cypress/types/net-stubbing';
import type { BaseMetricCreationResponse, BaseMetricListResponse } from '~/api';
import type {
Expand All @@ -9,7 +9,7 @@ import type {
RegisteredModel,
RegisteredModelList,
} from '~/concepts/modelRegistry/types';
import type {
import {
DashboardConfigKind,
DataScienceClusterInitializationKindStatus,
DataScienceClusterKindStatus,
Expand All @@ -19,16 +19,16 @@ import type {
TemplateKind,
NotebookKind,
ModelRegistryKind,
ConsoleLinkKind,
ConsoleLinkKind, RoleBindingSubject, RoleBindingRoleRef, ConfigMapKind, SecretKind,
} from '~/k8sTypes';

import type { StartNotebookData } from '~/pages/projects/types';
import type { AllowedUser } from '~/pages/notebookController/screens/admin/types';
import type { GroupsConfig } from '~/pages/groupSettings/groupTypes';
import type { StatusResponse } from '~/redux/types';
import type {
import {
BYONImage,
ClusterSettingsType,
ClusterSettingsType, DetectedAccelerators,
ImageInfo,
OdhApplication,
OdhDocument,
Expand All @@ -54,6 +54,7 @@ import type { GrpcResponse } from '~/__mocks__/mlmd/utils';
import type { BuildMockPipelinveVersionsType } from '~/__mocks__';
import type { ArtifactStorage } from '~/concepts/pipelines/types';
import type { ConnectionTypeConfigMap } from '~/concepts/connectionTypes/types';
import { NimServingResponse } from '~/__tests__/cypress/cypress/types';

type SuccessErrorResponse = {
success: boolean;
Expand Down Expand Up @@ -637,6 +638,19 @@ declare global {
((
type: 'POST /api/modelRegistryRoleBindings',
response: OdhResponse<RoleBindingKind>,
) => Cypress.Chainable<null>) &
((
type: 'GET /api/accelerators',
response: OdhResponse<DetectedAccelerators>,
) => Cypress.Chainable<null>) &
((
type: 'GET /api/nim-serving/:resource',
options: {
path: {
resource: 'nvidia-nim-images-data' | 'nvidia-nim-access' | 'nvidia-nim-image-pull';
};
},
response: OdhResponse<NimServingResponse>,
) => Cypress.Chainable<null>);
}
}
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/__tests__/cypress/cypress/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { RouteMatcher } from 'cypress/types/net-stubbing';
import { ConfigMapKind, SecretKind } from '~/k8sTypes';

export type Snapshot = {
method: string;
Expand Down Expand Up @@ -71,3 +72,9 @@ export type TestConfig = {
OCP_ADMIN_USER: UserAuthConfig;
S3: AWSS3Buckets;
};

export type NimServingResponse = {
body: {
body: ConfigMapKind | SecretKind;
};
};
32 changes: 18 additions & 14 deletions frontend/src/__tests__/cypress/cypress/utils/nimUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
mockNimImages,
mockNimInferenceService,
mockNimModelPVC,
mockNimProject,
mockNimProject, mockNimServingResource,
mockNimServingRuntime,
mockNimServingRuntimeTemplate,
mockNvidiaNimAccessSecret,
Expand Down Expand Up @@ -197,7 +197,7 @@ export const initInterceptsToEnableNim = ({ hasAllModels = false }: EnableNimCon
mockK8sResourceList([mockAcceleratorProfile({ namespace: 'opendatahub' })]),
);

cy.intercept('GET', '/api/accelerators', {
cy.interceptOdh('GET /api/accelerators', {
configured: true,
available: { 'nvidia.com/gpu': 1 },
total: { 'nvidia.com/gpu': 1 },
Expand All @@ -213,20 +213,24 @@ export const initInterceptsToDeployModel = (nimInferenceService: InferenceServic

cy.interceptK8s('POST', ServingRuntimeModel, mockNimServingRuntime()).as('createServingRuntime');

// NOTES: `body` field is needed!
cy.intercept(
{ method: 'GET', pathname: '/api/nim-serving/nvidia-nim-images-data' },
{
body: { body: mockNimImages() },
},
cy.interceptOdh(
`GET /api/nim-serving/:resource`,
{ path: { resource: 'nvidia-nim-images-data' } },
mockNimServingResource(mockNimImages()),
);

cy.interceptOdh(
`GET /api/nim-serving/:resource`,
{ path: { resource: 'nvidia-nim-access' } },
mockNimServingResource(mockNvidiaNimAccessSecret()),
);
cy.intercept(
{ method: 'GET', pathname: '/api/nim-serving/nvidia-nim-access' },
{ body: { body: mockNvidiaNimAccessSecret() } },

cy.interceptOdh(
`GET /api/nim-serving/:resource`,
{ path: { resource: 'nvidia-nim-image-pull' } },
mockNimServingResource(mockNvidiaNimImagePullSecret()),
);
cy.intercept('GET', 'api/nim-serving/nvidia-nim-image-pull', {
body: { body: mockNvidiaNimImagePullSecret() },
});

cy.interceptK8s('POST', PVCModel, mockNimModelPVC());
};

Expand Down

0 comments on commit 7da5544

Please sign in to comment.