Skip to content

Commit a1316e6

Browse files
committed
edit test and checkInferenceServiceState
1 parent 6e737e7 commit a1316e6

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/models/testModelStopStart.cy.ts

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('A model can be stopped and started', () => {
3636
throw new Error('Project name is undefined or empty in the loaded fixture');
3737
}
3838
cy.log(`Loaded project name: ${projectName}`);
39-
// Create a Project for pipelines
39+
// Create a Project
4040
provisionProjectForModelServing(
4141
projectName,
4242
awsBucket,
@@ -47,7 +47,7 @@ describe('A model can be stopped and started', () => {
4747
});
4848

4949
after(() => {
50-
// Delete provisioned Project
50+
// Delete the Project
5151
deleteOpenShiftProject(projectName, { wait: false, ignoreNotFound: true });
5252
});
5353

@@ -58,7 +58,6 @@ describe('A model can be stopped and started', () => {
5858
},
5959
() => {
6060
cy.log('Model Name:', modelName);
61-
// Authentication and navigation
6261
cy.step(`Log into the application with ${HTPASSWD_CLUSTER_ADMIN_USER.USERNAME}`);
6362
cy.visitWithLogin('/', HTPASSWD_CLUSTER_ADMIN_USER);
6463

@@ -68,14 +67,13 @@ describe('A model can be stopped and started', () => {
6867
projectListPage.filterProjectByName(projectName);
6968
projectListPage.findProjectLink(projectName).click();
7069

71-
// Navigate to Model Serving tab and Deploy a Model
72-
cy.step('Navigate to Model Serving and click to Deploy a Model Server');
70+
// Navigate to Model Serving section and Deploy a Model
71+
cy.step('Navigate to Model Serving and click to Deploy a Model');
7372
projectDetails.findSectionTab('model-server').click();
7473
modelServingGlobal.findSingleServingModelButton().click();
7574
modelServingGlobal.findDeployModelButton().click();
7675

77-
// Launch a Single Serving Model and select the required entries
78-
cy.step('Launch a Single Serving Model using Openvino');
76+
cy.step('Launch a Model');
7977
inferenceServiceModal.findModelNameInput().type(testData.singleModelName);
8078
inferenceServiceModal.findServingRuntimeTemplateSearchSelector().click();
8179
inferenceServiceModal.findGlobalScopedTemplateOption('OpenVINO Model Server').click();
@@ -86,18 +84,14 @@ describe('A model can be stopped and started', () => {
8684
inferenceServiceModal.shouldBeOpen(false);
8785
modelServingSection.findModelServerName(testData.singleModelName);
8886

89-
//Verify the model created
90-
cy.step('Verify that the Model is created Successfully on the backend and frontend');
87+
//Verify the model created and is running
88+
cy.step('Verify that the Model is running');
9189
checkInferenceServiceState(testData.singleModelName, projectName, {
9290
checkReady: true,
9391
checkLatestDeploymentReady: true,
9492
});
95-
modelServingSection.findModelServerName(testData.singleModelName);
96-
97-
cy.reload();
98-
modelServingSection.findStatusTooltip().click({ force: true });
99-
cy.contains('Loaded', { timeout: 120000 }).should('be.visible');
10093

94+
//Stop the model with the modal
10195
cy.step('Stop the model');
10296
const kServeRow = modelServingSection.getKServeRow(testData.singleModelName);
10397
kServeRow.findStateActionToggle().should('have.text', 'Stop').click();
@@ -108,17 +102,19 @@ describe('A model can be stopped and started', () => {
108102
kServeRow.findConfirmStopModalCheckbox().should('be.checked');
109103
kServeRow.findConfirmStopModalButton().click();
110104

111-
modelServingSection.findStatusTooltip().click({ force: true });
112-
cy.contains('Unknown', { timeout: 120000 }).should('be.visible');
105+
//Verify the model is stopped
113106
checkInferenceServiceState(testData.singleModelName, projectName, {
114107
checkReady: false,
115108
checkLatestDeploymentReady: false,
109+
checkStopped: true,
110+
requireLoadedState: false,
116111
});
117112

118-
cy.step('Start the model');
113+
//Restart the model
114+
cy.step('Restart the model');
119115
kServeRow.findStateActionToggle().should('have.text', 'Start').click();
120-
modelServingSection.findStatusTooltip().click({ force: true });
121-
cy.contains('Loaded', { timeout: 120000 }).should('be.visible');
116+
117+
//Verify the model is running again
122118
checkInferenceServiceState(testData.singleModelName, projectName, {
123119
checkReady: true,
124120
checkLatestDeploymentReady: true,

frontend/src/__tests__/cypress/cypress/utils/oc_commands/modelServing.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ type ConditionCheck = {
7878
type ConditionCheckOptions = {
7979
checkLatestDeploymentReady?: boolean;
8080
checkReady?: boolean;
81+
checkStopped?: boolean;
82+
requireLoadedState?: boolean;
8183
};
8284

8385
/**
@@ -174,6 +176,15 @@ export const checkInferenceServiceState = (
174176
});
175177
}
176178

179+
if (options.checkStopped) {
180+
conditionChecks.push({
181+
type: 'Stopped',
182+
expectedStatus: 'True',
183+
check: (condition) => condition.type === 'Stopped' && condition.status === 'True',
184+
name: 'Service Stopped',
185+
});
186+
}
187+
177188
// If no condition checks are specified, skip condition validation
178189
const shouldValidateConditions = conditionChecks.length > 0;
179190

@@ -207,10 +218,12 @@ export const checkInferenceServiceState = (
207218
// If no condition checks were specified, only check model state
208219
const allConditionsPassed =
209220
!shouldValidateConditions || checkedConditions.every((check) => check.isPassed);
221+
// If the user does not want to check the loaded state, then we can return true if the conditions are passed
222+
const requireLoaded = options.requireLoadedState !== false;
210223

211-
if (isModelLoaded && allConditionsPassed) {
224+
if ((!requireLoaded || isModelLoaded) && allConditionsPassed) {
212225
cy.log(
213-
`✅ InferenceService ${serviceName} is in "Loaded" state and meets all conditions after ${attempts} attempts`,
226+
`✅ InferenceService ${serviceName} meets all conditions after ${attempts} attempts`,
214227
);
215228
return cy.wrap(result);
216229
}

0 commit comments

Comments
 (0)