Skip to content

Commit

Permalink
mount points in DS projects (opendatahub-io#3315)
Browse files Browse the repository at this point in the history
  • Loading branch information
pnaik1 authored Oct 11, 2024
1 parent 873a266 commit dd41ed9
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 181 deletions.
10 changes: 10 additions & 0 deletions frontend/src/__mocks__/mockNotebookK8sResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ export const mockNotebookK8sResource = ({
mountPath: '/opt/app-root/src',
name,
},
{
mountPath: '/opt/app-root/src/root',
name: 'test-storage-1',
},
...additionalVolumeMounts,
],
workingDir: '/opt/app-root/src',
Expand Down Expand Up @@ -233,6 +237,12 @@ export const mockNotebookK8sResource = ({
claimName: name,
},
},
{
name: 'test-storage-1',
persistentVolumeClaim: {
claimName: 'test-storage-1',
},
},
{
name: 'oauth-config',
secret: {
Expand Down
20 changes: 18 additions & 2 deletions frontend/src/__tests__/cypress/cypress/pages/workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,24 @@ class NotebookRow extends TableRow {
return this;
}

toggleExpandableContent() {
this.find().findByRole('button', { name: 'Details' }).click();
shouldHaveClusterStorageTitle() {
this.findExpansion()
.findByTestId('notebook-storage-bar-title')
.should('have.text', 'Cluster storage');
return this;
}

shouldHaveMountPath(name: string) {
this.findExpansion().findByTestId('storage-mount-path').contains(name);
return this;
}

findExpansionButton() {
return this.find().findByTestId('notebook-table-expand-cell');
}

findExpansion() {
return this.find().siblings();
}

findAddStorageButton() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
editSpawnerPage,
notFoundSpawnerPage,
notebookConfirmModal,
storageModal,
workbenchPage,
} from '~/__tests__/cypress/cypress/pages/workbench';
import { verifyRelativeURL } from '~/__tests__/cypress/cypress/utils/url';
Expand Down Expand Up @@ -165,7 +164,10 @@ const initIntercepts = ({
),
);
cy.interceptK8sList(SecretModel, mockK8sResourceList([mockSecretK8sResource({})]));
cy.interceptK8sList(PVCModel, mockK8sResourceList([mockPVCK8sResource({})]));
cy.interceptK8sList(
PVCModel,
mockK8sResourceList([mockPVCK8sResource({ name: 'test-storage-1' })]),
);

cy.interceptK8s('POST', ConfigMapModel, mockConfigMap({})).as('createConfigMap');

Expand Down Expand Up @@ -327,7 +329,7 @@ describe('Workbench page', () => {
template: {
spec: {
volumes: [
{ name: 'test-storage', persistentVolumeClaim: { claimName: 'test-storage' } },
{ name: 'test-storage-1', persistentVolumeClaim: { claimName: 'test-storage-1' } },
],
},
},
Expand Down Expand Up @@ -454,13 +456,6 @@ describe('Workbench page', () => {
workbenchPage.findNotebookTableHeaderButton('Status').should(be.sortAscending);
workbenchPage.findNotebookTableHeaderButton('Status').click();
workbenchPage.findNotebookTableHeaderButton('Status').should(be.sortDescending);

//expandable table
notebookRow.toggleExpandableContent();
notebookRow.findAddStorageButton().click();
storageModal.selectExistingPersistentStorage('Test Storage');
storageModal.findMountField().fill('data');
storageModal.findSubmitButton().click();
});

it('Validate the notebook status when workbench is stopped and starting', () => {
Expand Down Expand Up @@ -650,6 +645,16 @@ describe('Workbench page', () => {
verifyRelativeURL('/projects/test-project?section=overview');
});

it('Expanded workbench table row', () => {
initIntercepts({});
workbenchPage.visit('test-project');
const notebookRow = workbenchPage.getNotebookRow('Test Notebook');
notebookRow.findExpansionButton().click();
notebookRow.findExpansion().should('be.visible');
notebookRow.shouldHaveClusterStorageTitle();
notebookRow.shouldHaveMountPath('/opt/app-root/src/root');
});

it('Delete Workbench', () => {
initIntercepts({});
workbenchPage.visit('test-project');
Expand Down
28 changes: 26 additions & 2 deletions frontend/src/api/k8s/__tests__/notebooks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -780,14 +780,26 @@ describe('removeNotebookPVC', () => {
path: '/spec/template/spec/volumes',
value: [
{ name: notebookName, persistentVolumeClaim: { claimName: notebookName } },
{
name: 'test-storage-1',
persistentVolumeClaim: {
claimName: 'test-storage-1',
},
},
{ name: 'oauth-config', secret: { secretName: 'workbench-oauth-config' } },
{ name: 'tls-certificates', secret: { secretName: 'workbench-tls' } },
],
},
{
op: 'replace',
path: '/spec/template/spec/containers/0/volumeMounts',
value: [{ mountPath: '/opt/app-root/src', name: notebookName }],
value: [
{ mountPath: '/opt/app-root/src', name: notebookName },
{
mountPath: '/opt/app-root/src/root',
name: 'test-storage-1',
},
],
},
],
queryOptions: { name: notebookName, ns: namespace, queryParams: {} },
Expand Down Expand Up @@ -853,14 +865,26 @@ describe('removeNotebookPVC', () => {
path: '/spec/template/spec/volumes',
value: [
{ name: notebookName, persistentVolumeClaim: { claimName: notebookName } },
{
name: 'test-storage-1',
persistentVolumeClaim: {
claimName: 'test-storage-1',
},
},
{ name: 'oauth-config', secret: { secretName: 'workbench-oauth-config' } },
{ name: 'tls-certificates', secret: { secretName: 'workbench-tls' } },
],
},
{
op: 'replace',
path: '/spec/template/spec/containers/0/volumeMounts',
value: [{ mountPath: '/opt/app-root/src', name: notebookName }],
value: [
{ mountPath: '/opt/app-root/src', name: notebookName },
{
mountPath: '/opt/app-root/src/root',
name: 'test-storage-1',
},
],
},
],
queryOptions: { name: notebookName, ns: namespace, queryParams: {} },
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/InlineTruncatedClipboardCopy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import * as React from 'react';
type Props = {
textToCopy: string;
testId?: string;
maxWidth?: number;
};

/** Hopefully PF will add some flexibility with ClipboardCopy
* in the future and this will not be necessary
* https://github.com/patternfly/patternfly-react/issues/10890
**/

const InlineTruncatedClipboardCopy: React.FC<Props> = ({ textToCopy, testId }) => (
const InlineTruncatedClipboardCopy: React.FC<Props> = ({ textToCopy, testId, maxWidth }) => (
<ClipboardCopy
variant="inline-compact"
style={{ display: 'inline-flex' }}
style={{ display: 'inline-flex', maxWidth }}
hoverTip="Copy"
clickTip="Copied"
onCopy={() => {
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/concepts/design/HeaderIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
interface HeaderIconProps {
size?: number;
padding?: number;
display?: string;
image?: string;
type: ProjectObjectType;
sectionType?: SectionType;
Expand All @@ -18,13 +19,14 @@ interface HeaderIconProps {
const HeaderIcon: React.FC<HeaderIconProps> = ({
size = 40,
padding = 2,
display = 'inline-block',
image,
type,
sectionType,
}) => (
<div
style={{
display: 'inline-block',
display,
width: size,
height: size,
padding,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/projects/notebook/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const getNotebookPVCMountPathMap = (
return innerAcc;
}

return { ...innerAcc, [claimName]: relativeMountPath(volumeMount.mountPath) };
return { ...innerAcc, [claimName]: volumeMount.mountPath || '/ ' };
}, {}),
}),
{},
Expand Down
112 changes: 0 additions & 112 deletions frontend/src/pages/projects/pvc/AddNotebookStorage.tsx

This file was deleted.

Loading

0 comments on commit dd41ed9

Please sign in to comment.