Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress e2e Test - Verify Non Admin Can Serve And Query A Model Using The UI #3646

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
cacbfe5
Initial WIP version of resource creation test
antowaddle Nov 20, 2024
0fa2201
Experimental changes to poll the UI for updates
antowaddle Nov 21, 2024
af87ad1
Working version if resource is present
antowaddle Nov 21, 2024
0e9868a
increase card timeout and delete active wait
FedeAlonso Nov 21, 2024
429f086
Merge pull request #1 from FedeAlonso/fix/active_wait
antowaddle Nov 21, 2024
443e530
Added changes to find namespace from variables
antowaddle Nov 22, 2024
966917f
Final changes to read variables, cleaned up utils
antowaddle Nov 22, 2024
69db944
Merge branch 'main' into cypress-RHOAIENG-14368
antowaddle Nov 22, 2024
a9ecfa3
Small change to a comment
antowaddle Nov 22, 2024
6cd6a3e
Dummy change to trigger mocks
antowaddle Nov 22, 2024
fcc6d18
Merge branch 'opendatahub-io:main' into main
antowaddle Nov 22, 2024
c7d471a
Merge branch 'main' into cypress-RHOAIENG-14368
antowaddle Nov 22, 2024
7628316
Save changes on cypress-RHOAIENG-12649
antowaddle Nov 25, 2024
847ad11
Changed file directories and names as requested on a PR comment
antowaddle Nov 25, 2024
552a516
Merge branch 'main' into cypress-RHOAIENG-14368
antowaddle Nov 25, 2024
80cc894
Merge branch 'cypress-RHOAIENG-14368' of https://github.com/antowaddl…
antowaddle Nov 25, 2024
163ed94
Merge remote-tracking branch 'origin/main' into cypress-RHOAIENG-12649
antowaddle Nov 25, 2024
0f7eead
Saving changes to current branch
antowaddle Nov 25, 2024
48c7435
Additional directory/file name changes
antowaddle Nov 25, 2024
14a39de
Additional changes to save
antowaddle Nov 25, 2024
6a93ec2
Resolving timeout issue breaking mock tests, also resolved latest PR …
antowaddle Nov 25, 2024
31b9723
Further changes for this test
antowaddle Nov 25, 2024
f2b636d
Changes to revert the exist method appended to getCardView.
antowaddle Nov 25, 2024
a9feb1b
Fixed linting
antowaddle Nov 25, 2024
aa9430e
Linting fixes
antowaddle Nov 25, 2024
eddd7d8
Merge branch 'main' into cypress-RHOAIENG-12649Merge branch 'main' of…
antowaddle Nov 25, 2024
680a0ee
Final comments added
antowaddle Nov 25, 2024
b6bc5b3
Merge branch 'main' into cypress-RHOAIENG-12649
antowaddle Nov 26, 2024
781e952
Fixed merge conflict
antowaddle Nov 26, 2024
b05b676
Small change to page object name
antowaddle Nov 26, 2024
3681244
dummy commit
antowaddle Nov 26, 2024
fb11cc5
Removed RHOAI bug workaround
antowaddle Nov 26, 2024
e0b9cca
Removed comments
antowaddle Nov 26, 2024
06167d8
Last comment change
antowaddle Nov 26, 2024
ae51479
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Dec 9, 2024
dac0574
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Dec 10, 2024
2cd1f7e
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Dec 11, 2024
645dca1
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Dec 13, 2024
f044a29
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Dec 16, 2024
7aa9059
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Dec 16, 2024
ff28a5d
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Dec 18, 2024
bca2ef3
Merge branch 'main' of https://github.com/antowaddle/odh-dashboard
antowaddle Dec 18, 2024
45dd834
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Dec 31, 2024
bd20cdd
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Jan 2, 2025
d7afb9d
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Jan 6, 2025
290d114
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Jan 7, 2025
60d6e41
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Jan 9, 2025
a87272f
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Jan 10, 2025
7ee804b
Committing intermediate changes
antowaddle Jan 14, 2025
30832c1
Initial changes
antowaddle Jan 15, 2025
1927e12
Initial changes
antowaddle Jan 15, 2025
d9c513f
Messy working test
antowaddle Jan 16, 2025
77a4dde
Committing working test - not linted/cleaned up
antowaddle Jan 16, 2025
c7bd528
Committing working test with exception of status check on UI
antowaddle Jan 17, 2025
0cf19f3
Merge branch 'main' into cypress-RHOAIENG-17157
antowaddle Jan 17, 2025
8d65c21
Committing fully working test on RHOAI
antowaddle Jan 17, 2025
6c958e1
Linting fixes
antowaddle Jan 17, 2025
3ac15b1
Adding in description for bug relating to manifest links
antowaddle Jan 17, 2025
6283fa7
Actioning PR comments
antowaddle Jan 17, 2025
2d366fe
Merge branch 'main' into cypress-RHOAIENG-17157
antowaddle Jan 17, 2025
acecce9
Merge branch 'main' into cypress-RHOAIENG-17157
antowaddle Jan 17, 2025
dadf1dc
Merge branch 'main' into cypress-RHOAIENG-17157
antowaddle Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# testSingleModelContributorCreation.cy.ts Test Data #
projectSingleModelDisplayName: "Cypress Single Model Test Project"
projectSingleModelResourceName: "cypress-single-model-test-project"
singleModelName: "cypress-single-model"
modelFilePath: "flan-t5-small/flan-t5-small-caikit"
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
kind: Secret
apiVersion: v1
metadata:
name: aws-connection-ods-ci-wisdom
namespace: {{NAMESPACE}}
labels:
opendatahub.io/dashboard: 'true'
opendatahub.io/managed: 'true'
annotations:
opendatahub.io/connection-type: s3
openshift.io/display-name: ods-ci-wisdom
data:
AWS_ACCESS_KEY_ID: {{AWS_ACCESS_KEY_ID}}
AWS_DEFAULT_REGION: {{AWS_DEFAULT_REGION}}
AWS_S3_BUCKET: {{AWS_S3_BUCKET}}
AWS_S3_ENDPOINT: {{AWS_S3_ENDPOINT}}
AWS_SECRET_ACCESS_KEY: {{AWS_SECRET_ACCESS_KEY}}
type: Opaque
32 changes: 32 additions & 0 deletions frontend/src/__tests__/cypress/cypress/pages/modelServing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ class ModelServingGlobal {
return cy.findByTestId('empty-state-action-button');
}

findSingleServingModelButton() {
return cy.findByTestId('single-serving-select-button');
}

private findModelsTable() {
// TODO be more precise
return cy.findByTestId('inference-service-table');
Expand All @@ -65,6 +69,10 @@ class ModelServingGlobal {
return this.findModelsTable().findByTestId(`metrics-link-${name}`);
}

findStatusTooltip() {
return cy.findByTestId('status-tooltip');
}

findEmptyResults() {
return cy.findByTestId('dashboard-empty-table-state');
}
Expand Down Expand Up @@ -97,6 +105,18 @@ class InferenceServiceModal extends Modal {
return this.find().findByTestId('inference-service-model-selection');
}

findServingRuntimeTemplate() {
return this.find().findByTestId('serving-runtime-template-selection');
}

findCalkitStandaloneServingRuntime() {
return this.find().findByTestId('caikit-standalone-runtime');
}

findCalkitTGISServingRuntime() {
return this.find().findByTestId('caikit-tgis-runtime');
}

findModelFrameworkSelect() {
return this.find().findByTestId('inference-service-framework-selection');
}
Expand Down Expand Up @@ -184,6 +204,10 @@ class InferenceServiceModal extends Modal {
findServingRuntimeEnvVarsValue(value: string) {
return this.find().findByTestId(`serving-runtime-environment-variables-input-value ${value}`);
}

findCreatedModel(name: string) {
return this.find().findByTestId(`metrics-link-${name}`);
}
}

class ServingRuntimeModal extends Modal {
Expand Down Expand Up @@ -402,6 +426,14 @@ class ModelServingSection {
return this.find().findByTestId('serving-runtime-table');
}

findModelServerName(name: string) {
return this.find().findByTestId(`metrics-link-${name}`);
}

findStatusTooltip() {
return this.find().findByTestId('status-tooltip');
}

findKServeTableHeaderButton(name: string) {
return this.findKServeTable().find('thead').findByRole('button', { name });
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as yaml from 'js-yaml';
import { isUrlExcluded } from '~/__tests__/cypress/cypress/utils/urlExtractor';

describe('Verify that all the URLs referenced in the Manifest directory are operational', () => {
describe('[Known Bug: RHOAIENG-9235] Verify that all the URLs referenced in the Manifest directory are operational', () => {
let excludedSubstrings: string[];

// Setup: Load test data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ const projectName = 'test-dsp-custom-pip-prj';
const dspaSecretName = 'test-custom-pip-dspa-secret';
const testPipelineIrisName = 'test-iris-pipeline';
const testRunName = 'test-pipelines-run';
const awsBucket = 'BUCKET_2' as const;

describe('An admin user can import and run a pipeline', { testIsolation: false }, () => {
before(() => {
provisionProjectForPipelines(projectName, dspaSecretName);
provisionProjectForPipelines(projectName, dspaSecretName, awsBucket);
//Create Pipelines ConfigMap With Custom Pip Index Url And Trusted Host
createOpenShiftConfigMap('ds-pipeline-custom-env-vars', projectName, {
// The following lines should be snake case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ const projectName = 'test-pipelines-prj';
const dspaSecretName = 'dashboard-dspa-secret';
const testPipelineName = 'test-pipelines-pipeline';
const testRunName = 'test-pipelines-run';
const awsBucket = 'BUCKET_3' as const;

describe('An admin user can import and run a pipeline', { testIsolation: false }, () => {
before(() => {
// Create a Project for pipelines
provisionProjectForPipelines(projectName, dspaSecretName);
provisionProjectForPipelines(projectName, dspaSecretName, awsBucket);
});

after(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import type { DataScienceProjectData } from '~/__tests__/cypress/cypress/types';
import {
addUserToProject,
deleteOpenShiftProject,
} from '~/__tests__/cypress/cypress/utils/oc_commands/project';
import { loadDSPFixture } from '~/__tests__/cypress/cypress/utils/dataLoader';
import { LDAP_CONTRIBUTOR_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers';
import { projectListPage, projectDetails } from '~/__tests__/cypress/cypress/pages/projects';
import {
modelServingGlobal,
inferenceServiceModal,
modelServingSection,
} from '~/__tests__/cypress/cypress/pages/modelServing';
import {
checkInferenceServiceState,
provisionProjectForModelServing,
} from '~/__tests__/cypress/cypress/utils/oc_commands/modelServing';

let testData: DataScienceProjectData;
let projectName: string;
let contributor: string;
let modelName: string;
let modelFilePath: string;
const awsBucket = 'BUCKET_3' as const;

describe('Verify Model Creation and Validation using the UI', () => {
before(() => {
Cypress.on('uncaught:exception', (err) => {
if (err.message.includes('Error: secrets "ds-pipeline-config" already exists')) {
return false;
}
return true;
});
// Setup: Load test data and ensure clean state
return loadDSPFixture('e2e/dataScienceProjects/testSingleModelContributorCreation.yaml').then(
(fixtureData: DataScienceProjectData) => {
testData = fixtureData;
projectName = testData.projectSingleModelResourceName;
contributor = LDAP_CONTRIBUTOR_USER.USERNAME;
modelName = testData.singleModelName;
modelFilePath = testData.modelFilePath;

if (!projectName) {
throw new Error('Project name is undefined or empty in the loaded fixture');
}
cy.log(`Loaded project name: ${projectName}`);
// Create a Project for pipelines
provisionProjectForModelServing(
projectName,
awsBucket,
'resources/yaml/data_connection_model_serving.yaml',
);
addUserToProject(projectName, contributor, 'edit');
},
);
});
after(() => {
// Delete provisioned Project - 5 min timeout to accomadate increased time to delete a project with a model
deleteOpenShiftProject(projectName, { timeout: 300000 });
});

it(
'Verify that a Non Admin can Serve and Query a Model using the UI',
{ tags: ['@Smoke', '@SmokeSet2', '@ODS-2552', '@Dashboard'] },
() => {
cy.log('Model Name:', modelName);
// Authentication and navigation
cy.step(`Log into the application with ${LDAP_CONTRIBUTOR_USER.USERNAME}`);
cy.visitWithLogin('/', LDAP_CONTRIBUTOR_USER);

// Project navigation, add user and provide contributor permissions
cy.step(
`Navigate to the Project list tab and search for ${testData.projectSingleModelResourceName}`,
);
projectListPage.navigate();
projectListPage.filterProjectByName(testData.projectSingleModelResourceName);
projectListPage.findProjectLink(testData.projectSingleModelResourceName).click();

// Navigate to Model Serving tab and Deploy a Single Model
cy.step('Navigate to Model Serving and click to Deploy a Single Model');
projectDetails.findSectionTab('model-server').click();
modelServingGlobal.findSingleServingModelButton().click();
modelServingGlobal.findDeployModelButton().click();

// Launch a Single Serving Model and select the required entries
cy.step('Launch a Single Serving Model using Caikit TGIS ServingRuntime for KServe');
inferenceServiceModal.findModelNameInput().type(testData.singleModelName);
inferenceServiceModal.findServingRuntimeTemplate().click();
inferenceServiceModal.findCalkitTGISServingRuntime().click();

inferenceServiceModal.findLocationPathInput().type(modelFilePath);
inferenceServiceModal.findSubmitButton().click();

//Verify the model created
cy.step('Verify that the Model is created Successfully on the backend and frontend');
checkInferenceServiceState(testData.singleModelName);
modelServingSection.findModelServerName(testData.singleModelName);
// Note reload is required as status tooltip was not found due to a stale element
cy.reload();
modelServingSection.findStatusTooltip().click({ force: true });
cy.contains('Loaded', { timeout: 120000 }).should('be.visible');
},
);
});
5 changes: 5 additions & 0 deletions frontend/src/__tests__/cypress/cypress/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type AWSS3Buckets = {
AWS_ACCESS_KEY_ID: string;
AWS_SECRET_ACCESS_KEY: string;
BUCKET_2: AWSS3BucketDetails;
BUCKET_3: AWSS3BucketDetails;
};

export type DataConnectionReplacements = {
Expand Down Expand Up @@ -118,6 +119,10 @@ export type DataScienceProjectData = {
projectEditDescription: string;
projectEditResourceName: string;
projectEditUpdatedName: string;
projectSingleModelDisplayName: string;
projectSingleModelResourceName: string;
singleModelName: string;
modelFilePath: string;
};

export type NotebookImageData = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const createDataConnection = (
): Cypress.Chainable<CommandLineResult> => {
return cy.fixture(yamlFilePath).then((yamlContent) => {
const modifiedYamlContent = replacePlaceholdersInYaml(yamlContent, dataConnectionReplacements);

cy.log(`Yaml:${modifiedYamlContent}`);
return applyOpenShiftYaml(modifiedYamlContent);
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/* eslint-disable cypress/no-unnecessary-waiting */
import { createDataConnection } from '~/__tests__/cypress/cypress/utils/oc_commands/dataConnection';
import { AWS_BUCKETS } from '~/__tests__/cypress/cypress/utils/s3Buckets';
import type { DataConnectionReplacements } from '~/__tests__/cypress/cypress/types';
import { createCleanProject } from '~/__tests__/cypress/cypress/utils/projectChecker';

/**
* Provision (using oc) a Project in order to make it usable with model seving
* (creates a Data Connection also)
*
* @param projectName Project Name
* @param bucketKey AWS Bucket
* @param customDataConnectionYamlPath DC Yaml Value
*/
export const provisionProjectForModelServing = (
projectName: string,
bucketKey: 'BUCKET_2' | 'BUCKET_3',
customDataConnectionYamlPath?: string,
): void => {
cy.log(`Provisioning project with bucket key: ${bucketKey}`);

const bucketConfig = AWS_BUCKETS[bucketKey];

// Provision a Project
createCleanProject(projectName);

// Create a pipeline-compatible Data Connection
const dataConnectionReplacements: DataConnectionReplacements = {
NAMESPACE: projectName,
AWS_ACCESS_KEY_ID: Buffer.from(AWS_BUCKETS.AWS_ACCESS_KEY_ID).toString('base64'),
AWS_DEFAULT_REGION: Buffer.from(bucketConfig.REGION).toString('base64'),
AWS_S3_BUCKET: Buffer.from(bucketConfig.NAME).toString('base64'),
AWS_S3_ENDPOINT: Buffer.from(bucketConfig.ENDPOINT).toString('base64'),
AWS_SECRET_ACCESS_KEY: Buffer.from(AWS_BUCKETS.AWS_SECRET_ACCESS_KEY).toString('base64'),
};
createDataConnection(dataConnectionReplacements, customDataConnectionYamlPath);
};

/**
* Check InferenceService active model state
*
*
* @param serviceName InferenceService name
* @returns Result Object of the operation
*/
export const checkInferenceServiceState = (
serviceName: string,
): Cypress.Chainable<Cypress.Exec> => {
const ocCommand = `oc get inferenceService ${serviceName} -o json | grep activeModelState`;
const maxAttempts = 60; // 5 minutes / 5 seconds = 60 attempts
let attempts = 0;

const checkState = (): Cypress.Chainable<Cypress.Exec> => {
return cy.exec(ocCommand, { failOnNonZeroExit: false }).then((result) => {
attempts++;

// Use cy.log for both Cypress logging and console output
cy.log(`🧐 Attempt ${attempts}: Checking InferenceService state
Command: ${ocCommand}
Output: ${result.stdout}`);

if (result.stdout.includes('"activeModelState": "Loaded"')) {
cy.log(
`✅ InferenceService ${serviceName} is in "Loaded" state after ${attempts} attempts`,
);
return cy.wrap(result);
}
if (attempts >= maxAttempts) {
const errorMessage = `❌ InferenceService ${serviceName} did not reach "Loaded" state within 5 minutes`;
cy.log(errorMessage);
throw new Error(errorMessage);
} else {
return cy.wait(5000).then(() => checkState());
}
});
};

return checkState();
};
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,21 @@ export const createOpenShiftProject = (
*/
export const deleteOpenShiftProject = (
projectName: string,
options: { timeout?: number } = {},
): Cypress.Chainable<CommandLineResult> => {
const { timeout } = options;
const ocCommand = `oc delete project ${projectName}`;
return cy.exec(ocCommand, { failOnNonZeroExit: false }).then((result) => {
if (result.code !== 0) {
cy.log(`ERROR deleting ${projectName} Project
return cy
.exec(ocCommand, { failOnNonZeroExit: false, ...(timeout && { timeout }) })
.then((result) => {
if (result.code !== 0) {
cy.log(`ERROR deleting ${projectName} Project
stdout: ${result.stdout}
stderr: ${result.stderr}`);
throw new Error(`Command failed with code ${result.code}`);
}
return result;
});
throw new Error(`Command failed with code ${result.code}`);
}
return result;
});
};

/**
Expand Down
Loading
Loading