|
| 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