Skip to content

Commit 6e66218

Browse files
ConorOM1antowaddle
andauthored
add catalog smoke test (opendatahub-io#5513)
Co-authored-by: Anthony Coughlin <33689325+antowaddle@users.noreply.github.com>
1 parent ed435f6 commit 6e66218

3 files changed

Lines changed: 138 additions & 0 deletions

File tree

frontend/src/__tests__/cypress/cypress/pages/modelCatalog/modelCatalog.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ class ModelCatalog {
8787
findModelCatalogNotFoundState() {
8888
return cy.findByTestId('not-found-page');
8989
}
90+
91+
findModelCards() {
92+
return cy.get('body').then(($body) => {
93+
return $body.find('[data-testid="model-catalog-card"]').length > 0;
94+
});
95+
}
9096
}
9197

9298
export const modelCatalog = new ModelCatalog();
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import {
2+
HTPASSWD_CLUSTER_ADMIN_USER,
3+
LDAP_CONTRIBUTOR_USER,
4+
} from '#~/__tests__/cypress/cypress/utils/e2eUsers';
5+
import { modelCatalog } from '#~/__tests__/cypress/cypress/pages/modelCatalog/modelCatalog';
6+
import { verifyModelCatalogBackend } from '#~/__tests__/cypress/cypress/utils/oc_commands/modelCatalog';
7+
8+
describe('Verifies that Model Catalog is available for different users', () => {
9+
before(() => {
10+
cy.step('Verifies that Model Catalog pods, Services and ConfigMaps are available');
11+
verifyModelCatalogBackend();
12+
});
13+
14+
it(
15+
'Verifies that Model Catalog is available for an admin user',
16+
{ tags: ['@Smoke', '@SmokeSet1', '@Dashboard', '@ModelCatalog'] },
17+
() => {
18+
cy.step('Login as admin user');
19+
cy.visitWithLogin('/', HTPASSWD_CLUSTER_ADMIN_USER);
20+
21+
cy.step('Navigate to Model Catalog');
22+
modelCatalog.navigate();
23+
24+
cy.step('Check if Model Catalog content is displayed');
25+
modelCatalog.findModelCards().should('exist');
26+
},
27+
);
28+
29+
it(
30+
'Verifies that Model Catalog is available for a regular user',
31+
{ tags: ['@Smoke', '@SmokeSet1', '@Dashboard', '@ModelCatalog'] },
32+
() => {
33+
cy.step('Login as LDAP user');
34+
cy.visitWithLogin('/', LDAP_CONTRIBUTOR_USER);
35+
36+
cy.step('Navigate to Model Catalog');
37+
modelCatalog.navigate();
38+
39+
cy.step('Check if Model Catalog content is displayed');
40+
modelCatalog.findModelCards().should('exist');
41+
},
42+
);
43+
});
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import type { CommandLineResult } from '#~/__tests__/cypress/cypress/types';
2+
import { execWithOutput } from './baseCommands';
3+
import { getModelRegistryNamespace } from './modelRegistry';
4+
5+
/**
6+
* Verify that the model-catalog-sources ConfigMap exists in the model registry namespace.
7+
* @returns A Cypress chainable that resolves with the command result.
8+
*/
9+
export const verifyModelCatalogSourcesConfigMap = (): Cypress.Chainable<CommandLineResult> => {
10+
const namespace = getModelRegistryNamespace();
11+
const command = `oc get configmap model-catalog-sources -n ${namespace}`;
12+
cy.log(`Verifying model-catalog-sources ConfigMap: ${command}`);
13+
14+
return execWithOutput(command, 30).then((result: CommandLineResult) => {
15+
if (result.code !== 0) {
16+
cy.log(`ERROR: model-catalog-sources ConfigMap not found in ${namespace}`);
17+
cy.log(`stdout: ${result.stdout}`);
18+
cy.log(`stderr: ${result.stderr}`);
19+
throw new Error(
20+
`model-catalog-sources ConfigMap not found in ${namespace}: ${result.stderr}`,
21+
);
22+
}
23+
cy.log(`✓ model-catalog-sources ConfigMap exists in ${namespace}`);
24+
return cy.wrap(result);
25+
});
26+
};
27+
28+
/**
29+
* Verify that the model-catalog deployment exists and is available in the model registry namespace.
30+
* @returns A Cypress chainable that resolves with the command result.
31+
*/
32+
export const verifyModelCatalogDeployment = (): Cypress.Chainable<CommandLineResult> => {
33+
const namespace = getModelRegistryNamespace();
34+
const command = `oc get deployment model-catalog -n ${namespace}`;
35+
cy.log(`Verifying model-catalog deployment: ${command}`);
36+
37+
return execWithOutput(command, 30).then((result: CommandLineResult) => {
38+
if (result.code !== 0) {
39+
cy.log(`ERROR: model-catalog deployment not found in ${namespace}`);
40+
cy.log(`stdout: ${result.stdout}`);
41+
cy.log(`stderr: ${result.stderr}`);
42+
throw new Error(`model-catalog deployment not found in ${namespace}: ${result.stderr}`);
43+
}
44+
cy.log(`✓ model-catalog deployment exists in ${namespace}`);
45+
return cy.wrap(result);
46+
});
47+
};
48+
49+
/**
50+
* Verify that the model-catalog service exists in the model registry namespace.
51+
* @returns A Cypress chainable that resolves with the command result.
52+
*/
53+
export const verifyModelCatalogService = (): Cypress.Chainable<CommandLineResult> => {
54+
const namespace = getModelRegistryNamespace();
55+
const command = `oc get service model-catalog -n ${namespace}`;
56+
cy.log(`Verifying model-catalog service: ${command}`);
57+
58+
return execWithOutput(command, 30).then((result: CommandLineResult) => {
59+
if (result.code !== 0) {
60+
cy.log(`ERROR: model-catalog service not found in ${namespace}`);
61+
cy.log(`stdout: ${result.stdout}`);
62+
cy.log(`stderr: ${result.stderr}`);
63+
throw new Error(`model-catalog service not found in ${namespace}: ${result.stderr}`);
64+
}
65+
cy.log(`✓ model-catalog service exists in ${namespace}`);
66+
return cy.wrap(result);
67+
});
68+
};
69+
70+
/**
71+
* Comprehensive verification of Model Catalog backend resources.
72+
* This checks deployment, ConfigMap, and service in the model registry namespace.
73+
* @returns A Cypress chainable that performs all verifications.
74+
*/
75+
export const verifyModelCatalogBackend = (): Cypress.Chainable<CommandLineResult> => {
76+
const modelRegistryNamespace = getModelRegistryNamespace();
77+
78+
cy.step(`Verifying Model Catalog backend resources`);
79+
cy.log(`Model Registry namespace: ${modelRegistryNamespace}`);
80+
81+
// Check deployment (most critical - the actual backend server)
82+
verifyModelCatalogDeployment();
83+
84+
// Check required ConfigMap (contains model definitions)
85+
verifyModelCatalogSourcesConfigMap();
86+
87+
// Check service (routes traffic to deployment)
88+
return verifyModelCatalogService();
89+
};

0 commit comments

Comments
 (0)