Skip to content

Commit

Permalink
Merge pull request #2473 from uidoyen/RHOAIENG-2150
Browse files Browse the repository at this point in the history
Unit Test Case for k8s/notebooks
  • Loading branch information
openshift-merge-bot[bot] authored Apr 11, 2024
2 parents 4fbe0f6 + ff2cac3 commit 4ab9c17
Show file tree
Hide file tree
Showing 5 changed files with 1,041 additions and 19 deletions.
4 changes: 3 additions & 1 deletion frontend/src/__mocks__/mockNotebookK8sResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type MockResourceConfigType = {
envFromName?: string;
resources?: ContainerResources;
opts?: RecursivePartial<NotebookKind>;
uid?: string;
};

export const mockNotebookK8sResource = ({
Expand All @@ -25,6 +26,7 @@ export const mockNotebookK8sResource = ({
description = '',
resources = DEFAULT_NOTEBOOK_SIZES[0].resources,
opts = {},
uid = genUID('notebook'),
}: MockResourceConfigType): NotebookKind =>
_.merge(
{
Expand Down Expand Up @@ -54,7 +56,7 @@ export const mockNotebookK8sResource = ({
name,
namespace,
resourceVersion: '4800689',
uid: genUID('notebook'),
uid,
},
spec: {
template: {
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/__mocks__/mockRoleBindingK8sResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type MockResourceConfigType = {
namespace?: string;
subjects?: RoleBindingSubject[];
roleRefName?: string;
uid?: string;
};

export const mockRoleBindingK8sResource = ({
Expand All @@ -20,13 +21,14 @@ export const mockRoleBindingK8sResource = ({
},
],
roleRefName = 'view',
uid = genUID('rolebinding'),
}: MockResourceConfigType): RoleBindingKind => ({
kind: 'RoleBinding',
apiVersion: 'rbac.authorization.k8s.io/v1',
metadata: {
name,
namespace,
uid: genUID('rolebinding'),
uid,
creationTimestamp: '2023-02-14T21:43:59Z',
labels: {
[KnownLabels.DASHBOARD_RESOURCE]: 'true',
Expand Down
76 changes: 76 additions & 0 deletions frontend/src/__mocks__/mockStartNotebookData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { ImageStreamKind } from '~/k8sTypes';
import { StartNotebookData } from '~/pages/projects/types';

type MockResourceConfigType = {
volumeName?: string;
};
export const mockStartNotebookData = ({
volumeName = 'test-volume',
}: MockResourceConfigType): StartNotebookData => ({
projectName: 'test-project',
notebookName: 'test-notebook',
description: '',
image: {
imageStream: {
metadata: {
name: 'sample-image-stream',
},
status: {
dockerImageRepository: 'docker.io/sample-repo',
},
} as ImageStreamKind,
imageVersion: {
name: 'v1.0.0',
},
},
notebookSize: {
name: 'small',
resources: {
requests: {
memory: '2Gi',
cpu: '500m',
},
limits: {
memory: '2Gi',
cpu: '500m',
},
},
},
acceleratorProfile: {
acceleratorProfile: undefined,
acceleratorProfiles: [],
initialAcceleratorProfile: undefined,
count: 0,
useExisting: false,
},
volumes: [
{
name: volumeName,
persistentVolumeClaim: {
claimName: volumeName,
},
},
],
volumeMounts: [
{
mountPath: '/opt/app-root/src/data',
name: volumeName,
},
],
existingTolerations: [
{
key: 'key1',
value: 'value1',
},
],
existingResources: {
limits: {
cpu: '1',
memory: '1Gi',
},
requests: {
cpu: '500m',
memory: '512Mi',
},
},
});
Loading

0 comments on commit 4ab9c17

Please sign in to comment.