Skip to content

Commit

Permalink
test: rewrite test cases nim enablement
Browse files Browse the repository at this point in the history
Signed-off-by: Tomer Figenblat <[email protected]>
  • Loading branch information
TomerFi committed Oct 9, 2024
1 parent 1cafc5d commit cb01605
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class NIMDeployModal extends Modal {
findNimModelReplicasPlusButton() {
return this.find().find('button[aria-label="Plus"]').eq(1);
}

shouldDisplayError(msg: string): void {
this.find().should('contain.text', msg);
}
}

export const nimDeployModal = new NIMDeployModal();
6 changes: 5 additions & 1 deletion frontend/src/__tests__/cypress/cypress/pages/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class ProjectDetails {
return this.findDataConnectionTable().find('thead').findByRole('button', { name });
}

private findModelServingPlatform(name: string) {
findModelServingPlatform(name: string) {
return this.findComponent('model-server').findByTestId(`${name}-serving-platform-card`);
}

Expand Down Expand Up @@ -357,6 +357,10 @@ class ProjectDetailsOverviewTab extends ProjectDetails {
.contains(name)
.parents('.odh-type-bordered-card .model-server');
}

findModelServingPlatform(name: string) {
return cy.findByTestId(`${name}-platform-card`);
}
}

class KserveTableRow extends TableRow {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ import {
projectDetails,
projectDetailsOverviewTab,
} from '~/__tests__/cypress/cypress/pages/projects';
import { nimDeployModal } from '~/__tests__/cypress/cypress/pages/nimModelDialog';
import { nimDeployModal } from '~/__tests__/cypress/cypress/pages/components/NIMDeployModal';
import {
findNimModelDeployButton,
findNimModelServingPlatformCard,
initInterceptorsValidatingNimEnablement,
initInterceptsForDeleteModel,
initInterceptsToDeployModel,
initInterceptsToEnableNim,
modalDialogTitle,
validateNvidiaNimModel,
} from '~/__tests__/cypress/cypress/utils/nimUtils';
import { deleteModal } from '~/__tests__/cypress/cypress/pages/components/DeleteModal';

Expand Down Expand Up @@ -152,19 +150,25 @@ describe('NIM Model Serving', () => {
.get('dd')
.should('have.text', 'NVIDIA NIM');
});

it('should be blocked if failed to fetch NIM model list', () => {
initInterceptsToEnableNim({});
projectDetailsOverviewTab.visit('test-project');
cy.findByTestId('model-serving-platform-button').click();
nimDeployModal.shouldDisplayError(
'There was a problem fetching the NIM models. Please try again later.',
);
nimDeployModal.findSubmitButton().should('be.disabled');
});
});

describe('Enabling NIM', () => {
describe('When NIM feature is enabled', () => {
it("should allow deploying NIM from a Project's Overview tab when the only platform", () => {
initInterceptsToEnableNim({});
const componentName = 'overview';
projectDetails.visitSection('test-project', componentName);
const overviewComponent = projectDetails.findComponent(componentName);
overviewComponent.should('exist');
const deployModelButton = overviewComponent.findByTestId('model-serving-platform-button');
deployModelButton.should('exist');
validateNvidiaNimModel(deployModelButton);
projectDetailsOverviewTab.visit('test-project');
cy.findByTestId('model-serving-platform-button').click();
nimDeployModal.shouldBeOpen();
});

it("should allow deploying NIM from a Project's Overview tab when multiple platforms exist", () => {
Expand All @@ -173,48 +177,19 @@ describe('NIM Model Serving', () => {
disableModelMesh: false,
disableNIMModelServing: false,
});
projectDetails.visitSection('test-project', 'overview');

projectDetails
.findComponent('overview')
.findByTestId('single-serving-platform-card')
.findByTestId('model-serving-platform-button')
.should('exist');
projectDetails
.findComponent('overview')
.findByTestId('multi-serving-platform-card')
projectDetailsOverviewTab.visit('test-project');
projectDetailsOverviewTab
.findModelServingPlatform('nvidia-nim')
.findByTestId('model-serving-platform-button')
.should('exist');

projectDetails
.findComponent('overview')
.findByTestId('nvidia-nim-platform-card')
.should('contain', 'NVIDIA NIM model serving platform')
.and('contain', 'Models are deployed using NVIDIA NIM microservices.');

validateNvidiaNimModel(
projectDetails
.findComponent('overview')
.findByTestId('nvidia-nim-platform-card')
.findByTestId('model-serving-platform-button'),
);
.click();
nimDeployModal.shouldBeOpen();
});

it("should allow deploying NIM from a Project's Models tab when the only platform", () => {
initInterceptsToEnableNim({});
projectDetails.visitSection('test-project', 'model-server');
projectDetails.shouldBeEmptyState('Models', 'model-server', true);
projectDetails.findServingPlatformLabel().should('exist');

cy.contains('Start by adding a model server');
cy.contains(
'Model servers are used to deploy models and to allow apps to send requests to your models. Configuring a model server includes specifying the number of replicas being deployed, the server size, the token authentication, the serving runtime, and how the project that the model server belongs to is accessed.',
);

const deployButton = projectDetails
.findComponent('model-server')
.findByTestId('deploy-button');
validateNvidiaNimModel(deployButton);
cy.get('button').contains('Deploy model').click(); // TODO button has testid?
nimDeployModal.shouldBeOpen();
});

it("should allow deploying NIM from a Project's Models tab when multiple platforms exist", () => {
Expand All @@ -223,62 +198,45 @@ describe('NIM Model Serving', () => {
disableModelMesh: false,
disableNIMModelServing: false,
});

projectDetails.visitSection('test-project', 'model-server');
projectDetails.shouldBeEmptyState('Models', 'model-server', true);
projectDetails.findServingPlatformLabel().should('not.exist');

projectDetails.findSingleModelDeployButton().should('exist');
projectDetails.findMultiModelButton().should('exist');

findNimModelServingPlatformCard()
.should('contain', 'Models are deployed using NVIDIA NIM microservices.')
.and('contain', 'NVIDIA NIM model serving platform');

validateNvidiaNimModel(findNimModelDeployButton());
});

it('should display an error when failed to fetch NIM model list', () => {
initInterceptsToEnableNim({});
const componentName = 'overview';
projectDetails.visitSection('test-project', componentName);
const overviewComponent = projectDetails.findComponent(componentName);
overviewComponent.should('exist');
const deployModelButton = overviewComponent.findByTestId('model-serving-platform-button');
deployModelButton.should('exist');
deployModelButton.click();
cy.contains('There was a problem fetching the NIM models. Please try again later.');
projectDetails
.findModelServingPlatform('nvidia-nim-model')
.findByTestId('nim-serving-deploy-button')
.click();
nimDeployModal.shouldBeOpen();
});
});

describe('When NIM feature is disabled', () => {
it("should NOT allow deploying NIM from a Project's Overview tab when the only platform", () => {
initInterceptorsValidatingNimEnablement({
disableKServe: true,
disableModelMesh: true,
disableNIMModelServing: true,
});
projectDetailsOverviewTab.visit('test-project');
cy.findByTestId('model-serving-platform-button').should('not.exist');
});

it("should NOT allow deploying NIM from a Project's Overview tab when multiple platforms exist", () => {
initInterceptorsValidatingNimEnablement({
disableKServe: false,
disableModelMesh: false,
disableNIMModelServing: true,
});
projectDetailsOverviewTab.visit('test-project');
projectDetailsOverviewTab.findModelServingPlatform('nvidia-nim').should('not.exist');
cy.findByTestId('model-serving-platform-button').should('not.exist');
});

projectDetails.visitSection('test-project', 'overview');

projectDetails
.findComponent('overview')
.findByTestId('single-serving-platform-card')
.findByTestId('model-serving-platform-button')
.should('exist');
projectDetails
.findComponent('overview')
.findByTestId('multi-serving-platform-card')
.findByTestId('model-serving-platform-button')
.should('exist');

projectDetails
.findComponent('overview')
.find('[data-testid="nvidia-nim-platform-card"]')
.should('not.exist');

cy.contains('NVIDIA NIM model serving platform').should('not.exist');
cy.contains('Models are deployed using NVIDIA NIM microservices.').should('not.exist');
it("should NOT allow deploying NIM from a Project's Models tab when the only platform", () => {
initInterceptorsValidatingNimEnablement({
disableKServe: true,
disableModelMesh: true,
disableNIMModelServing: true,
});
projectDetails.visitSection('test-project', 'model-server');
cy.get('button').contains('Deploy model').should('not.exist'); // TODO button has testid?
});

it("should NOT allow deploying NIM to a Project's Models tab when multiple platforms exist", () => {
Expand All @@ -288,20 +246,13 @@ describe('NIM Model Serving', () => {
disableNIMModelServing: true,
});
projectDetails.visitSection('test-project', 'model-server');
projectDetails.shouldBeEmptyState('Models', 'model-server', true);
projectDetails.findServingPlatformLabel().should('not.exist');

projectDetails.findSingleModelDeployButton().should('exist');
projectDetails.findMultiModelButton().should('exist');

findNimModelServingPlatformCard().should('not.exist');
cy.contains('NVIDIA NIM model serving platform').should('not.exist');
cy.contains('Models are deployed using NVIDIA NIM microservices.').should('not.exist');
projectDetails.findModelServingPlatform('nvidia-nim-model').should('not.exist');
cy.findByTestId('nim-serving-deploy-button').should('not.exist');
});
});

describe('When missing the Template', () => {
it("should NOT allow deploying NIM from a Project's Overview tab when multiple platforms exist", () => {
describe('When the Template is missing', () => {
it("should NOT allow deploying NIM from a Project's Overview tab when the only platform", () => {
initInterceptorsValidatingNimEnablement(
{
disableKServe: false,
Expand All @@ -310,27 +261,36 @@ describe('NIM Model Serving', () => {
},
true,
);
projectDetailsOverviewTab.visit('test-project');
cy.findByTestId('model-serving-platform-button').should('not.exist');
});

projectDetails.visitSection('test-project', 'overview');

projectDetails
.findComponent('overview')
.findByTestId('single-serving-platform-card')
.findByTestId('model-serving-platform-button')
.should('exist');
projectDetails
.findComponent('overview')
.findByTestId('multi-serving-platform-card')
.findByTestId('model-serving-platform-button')
.should('exist');

projectDetails
.findComponent('overview')
.find('[data-testid="nvidia-nim-platform-card"]')
.should('not.exist');
it("should NOT allow deploying NIM from a Project's Overview tab when multiple platforms exist", () => {
initInterceptorsValidatingNimEnablement(
{
disableKServe: false,
disableModelMesh: false,
disableNIMModelServing: false,
},
true,
);
projectDetailsOverviewTab.visit('test-project');
projectDetailsOverviewTab.findModelServingPlatform('nvidia-nim').should('not.exist');
cy.findByTestId('model-serving-platform-button').should('not.exist');
});

cy.contains('NVIDIA NIM model serving platform').should('not.exist');
cy.contains('Models are deployed using NVIDIA NIM microservices.').should('not.exist');
it("should NOT allow deploying NIM from a Project's Models tab when the only platform", () => {
initInterceptorsValidatingNimEnablement(
{
disableKServe: false,
disableModelMesh: false,
disableNIMModelServing: false,
},
true,
);
projectDetails.visitSection('test-project', 'model-server');
cy.get('button').contains('Deploy model').click(); // TODO button has testid?
nimDeployModal.shouldBeOpen(false);
});

it("should NOT allow deploying NIM to a Project's Models tab when multiple platforms exist", () => {
Expand All @@ -343,15 +303,8 @@ describe('NIM Model Serving', () => {
true,
);
projectDetails.visitSection('test-project', 'model-server');
projectDetails.shouldBeEmptyState('Models', 'model-server', true);
projectDetails.findServingPlatformLabel().should('not.exist');

projectDetails.findSingleModelDeployButton().should('exist');
projectDetails.findMultiModelButton().should('exist');

findNimModelServingPlatformCard().should('not.exist');
cy.contains('NVIDIA NIM model serving platform').should('not.exist');
cy.contains('Models are deployed using NVIDIA NIM microservices.').should('not.exist');
projectDetails.findModelServingPlatform('nvidia-nim-model').should('not.exist');
cy.findByTestId('nim-serving-deploy-button').should('not.exist');
});
});
});
Expand Down
24 changes: 0 additions & 24 deletions frontend/src/__tests__/cypress/cypress/utils/nimUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,6 @@ export function findNimModelServingPlatformCard(): Cypress.Chainable<JQuery> {

export const modalDialogTitle = 'Deploy model with NVIDIA NIM';

export function validateNvidiaNimModel(
deployButtonElement: Cypress.Chainable<JQuery<HTMLElement>>,
): void {
deployButtonElement.click();
cy.contains(modalDialogTitle);
cy.contains('Configure properties for deploying your model using an NVIDIA NIM.');

//find the form label Project with value as the Test Project
cy.contains('label', 'Project').parent().next().find('p').should('have.text', 'Test Project');

//close the model window
cy.get('div[role="dialog"]').get('button[aria-label="Close"]').click();

// now the nvidia nim window should not be visible.
cy.contains(modalDialogTitle).should('not.exist');

deployButtonElement.click();
//validate model submit button is disabled without entering form data
cy.findByTestId('modal-submit-button').should('be.disabled');
//validate nim modal cancel button
cy.findByTestId('modal-cancel-button').click();
cy.contains(modalDialogTitle).should('not.exist');
}

/* ###################################################
###### Interception Initialization Utilities ######
################################################### */
Expand Down

0 comments on commit cb01605

Please sign in to comment.