Skip to content

Commit

Permalink
test: fix review change requests 1 - see body
Browse files Browse the repository at this point in the history
- Use JSON object instead of string in mocking of NIM images configmap
- Remove experiementalStudio cypres config param
- Add mock for NIM project

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 c480d4e commit baf470e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 34 deletions.
58 changes: 33 additions & 25 deletions frontend/src/__mocks__/mockNimResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import {
ConfigMapKind,
InferenceServiceKind,
PersistentVolumeClaimKind,
ProjectKind,
SecretKind,
ServingRuntimeKind,
TemplateKind,
} from '~/k8sTypes';
import { ServingRuntimeAPIProtocol, ServingRuntimePlatform } from '~/types';
import { mockProjectK8sResource } from '~/__mocks__/mockProjectK8sResource';
import { mockConfigMap } from './mockConfigMap';
import { mockServingRuntimeK8sResource } from './mockServingRuntimeK8sResource';
import { mockInferenceServiceK8sResource } from './mockInferenceServiceK8sResource';
Expand All @@ -19,31 +21,26 @@ export const mockNimImages = (): ConfigMapKind =>
name: 'nvidia-nim-images-data',
namespace: 'opendatahub',
data: {
alphafold2:
'{' +
' "name": "alphafold2",' +
' "displayName": "AlphaFold2",' +
' "shortDescription": "A widely used model for predicting the 3D structures of proteins from their amino acid sequences.",' +
' "namespace": "nim/deepmind",' +
' "tags": [' +
' "1.0.0"' +
' ],' +
' "latestTag": "1.0.0",' +
' "updatedDate": "2024-08-27T01:51:55.642Z"' +
' }',
'arctic-embed-l':
'{' +
' "name": "arctic-embed-l",' +
' "displayName": "Snowflake Arctic Embed Large Embedding",' +
' "shortDescription": "NVIDIA NIM for GPU accelerated Snowflake Arctic Embed Large Embedding inference",' +
' "namespace": "nim/snowflake",' +
' "tags": [' +
' "1.0.1",' +
' "1.0.0"' +
' ],' +
' "latestTag": "1.0.1",' +
' "updatedDate": "2024-07-27T00:38:40.927Z"' +
' }',
alphafold2: JSON.stringify({
name: 'alphafold2',
displayName: 'AlphaFold2',
shortDescription:
'A widely used model for predicting the 3D structures of proteins from their amino acid sequences.',
namespace: 'nim/deepmind',
tags: ['1.0.0'],
latestTag: '1.0.0',
updatedDate: '2024-08-27T01:51:55.642Z',
}),
'arctic-embed-l': JSON.stringify({
name: 'arctic-embed-l',
displayName: 'Snowflake Arctic Embed Large Embedding',
shortDescription:
'NVIDIA NIM for GPU accelerated Snowflake Arctic Embed Large Embedding inference',
namespace: 'nim/snowflake',
tags: ['1.0.1', '1.0.0'],
latestTag: '1.0.1',
updatedDate: '2024-07-27T00:38:40.927Z',
}),
},
});

Expand Down Expand Up @@ -124,6 +121,17 @@ export const mockNvidiaNimImagePullSecret = (): SecretKind => {
return secret;
};

export const mockNimProject = (hasAllModels: boolean): ProjectKind => {
const project = mockProjectK8sResource({
hasAnnotations: true,
enableModelMesh: hasAllModels ? undefined : false,
});
if (project.metadata.annotations != null) {
project.metadata.annotations['opendatahub.io/nim-support'] = 'true';
}
return project;
};

export const mockNimModelPVC = (): PersistentVolumeClaimKind => {
const pvc = mockPVCK8sResource({
name: 'nim-pvc',
Expand Down
1 change: 0 additions & 1 deletion frontend/src/__tests__/cypress/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { env, cypressEnv, BASE_URL } from '~/__tests__/cypress/cypress/utils/tes
const resultsDir = `${env.CY_RESULTS_DIR || 'results'}/${env.CY_MOCK ? 'mocked' : 'e2e'}`;

export default defineConfig({
experimentalStudio: false,
experimentalMemoryManagement: true,
// Use relative path as a workaround to https://github.com/cypress-io/cypress/issues/6406
reporter: '../../../node_modules/cypress-multi-reporters',
Expand Down
10 changes: 2 additions & 8 deletions frontend/src/__tests__/cypress/cypress/utils/nimUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
mockNimImages,
mockNimInferenceService,
mockNimModelPVC,
mockNimProject,
mockNimServingRuntime,
mockNimServingRuntimeTemplate,
mockNvidiaNimAccessSecret,
Expand Down Expand Up @@ -185,14 +186,7 @@ export const initInterceptsToEnableNim = ({ hasAllModels = false }: EnableNimCon
}),
);

const project = mockProjectK8sResource({
hasAnnotations: true,
enableModelMesh: hasAllModels ? undefined : false,
});
if (project.metadata.annotations != null) {
project.metadata.annotations['opendatahub.io/nim-support'] = 'true';
}
cy.interceptK8sList(ProjectModel, mockK8sResourceList([project]));
cy.interceptK8sList(ProjectModel, mockK8sResourceList([mockNimProject(hasAllModels)]));

const templateMock = mockNimServingRuntimeTemplate();
cy.interceptK8sList(TemplateModel, mockK8sResourceList([templateMock]));
Expand Down

0 comments on commit baf470e

Please sign in to comment.