From baf470e6a1464026e9fceed3d08ea4c163b8cdac Mon Sep 17 00:00:00 2001 From: Tomer Figenblat Date: Mon, 7 Oct 2024 09:49:20 -0400 Subject: [PATCH] test: fix review change requests 1 - see body - 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 Co-authored-by: lokeshrangineni Signed-off-by: Tomer Figenblat --- frontend/src/__mocks__/mockNimResource.ts | 58 +++++++++++-------- .../src/__tests__/cypress/cypress.config.ts | 1 - .../cypress/cypress/utils/nimUtils.ts | 10 +--- 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/frontend/src/__mocks__/mockNimResource.ts b/frontend/src/__mocks__/mockNimResource.ts index 92d3163f5c..baa2fa0f90 100644 --- a/frontend/src/__mocks__/mockNimResource.ts +++ b/frontend/src/__mocks__/mockNimResource.ts @@ -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'; @@ -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', + }), }, }); @@ -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', diff --git a/frontend/src/__tests__/cypress/cypress.config.ts b/frontend/src/__tests__/cypress/cypress.config.ts index b27f0b6eaa..cb1bcf733e 100644 --- a/frontend/src/__tests__/cypress/cypress.config.ts +++ b/frontend/src/__tests__/cypress/cypress.config.ts @@ -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', diff --git a/frontend/src/__tests__/cypress/cypress/utils/nimUtils.ts b/frontend/src/__tests__/cypress/cypress/utils/nimUtils.ts index 6fc37ba538..9073b9de7d 100644 --- a/frontend/src/__tests__/cypress/cypress/utils/nimUtils.ts +++ b/frontend/src/__tests__/cypress/cypress/utils/nimUtils.ts @@ -21,6 +21,7 @@ import { mockNimImages, mockNimInferenceService, mockNimModelPVC, + mockNimProject, mockNimServingRuntime, mockNimServingRuntimeTemplate, mockNvidiaNimAccessSecret, @@ -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]));