Skip to content

Commit

Permalink
add improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ConorOM1 committed Dec 12, 2024
1 parent 1341fee commit 20ef620
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# testLaunchStandaloneNotebook.cy.ts Test Data #
codeserverImageName: "code-server-notebook:2024.1"
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import yaml from 'js-yaml';
import { HTPASSWD_CLUSTER_ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers';
import { projectListPage } from '~/__tests__/cypress/cypress/pages/projects';
import { notebookServer } from '~/__tests__/cypress/cypress/pages/notebookServer';
import type { NotebookImageData } from '~/__tests__/cypress/cypress/types';
import {
waitForPodReady,
deleteNotebook,
} from '~/__tests__/cypress/cypress/utils/oc_commands/baseCommands';

describe('Verify a Jupyter Notebook can be launched directly from the Data Science Project List View', () => {
let testData: NotebookImageData;

before(() => {
// Check if a notebook is running and delete if it is
deleteNotebook('jupyter-nb');
return cy
.fixture('e2e/dataScienceProjects/testNotebookCreation.yaml', 'utf8')
.then((yamlContent: string) => {
testData = yaml.load(yamlContent) as NotebookImageData;
// Check if a notebook is running and delete if it is
deleteNotebook('jupyter-nb');
});
});

it('Verify User Can Access Jupyter Launcher From DS Project Page', () => {
Expand All @@ -28,11 +37,11 @@ describe('Verify a Jupyter Notebook can be launched directly from the Data Scien

// Select the versions dropdown
cy.step('Select the code server versions dropdown');
notebookServer.findVersionsDropdown('code-server-notebook:2024.1').click();
notebookServer.findVersionsDropdown(testData.codeserverImageName).click();

// Select a image version
cy.step('Select an image version');
notebookServer.findNotebookVersion('code-server-notebook:2024.1').click();
// Select an image version
cy.step('Select the codeserver image version');
notebookServer.findNotebookVersion(testData.codeserverImageName).click();

// Verify that 'Start Server button' is enabled
cy.step('Check Start server button is enabled');
Expand All @@ -44,11 +53,11 @@ describe('Verify a Jupyter Notebook can be launched directly from the Data Scien

// Verify that the server is running
cy.step('Verify the Jupyter Notebook pod is ready');
waitForPodReady('jupyter-nb', '1000s');

waitForPodReady('jupyter-nb', '300s');
// Expand the log
cy.step('Expand the Event log');
notebookServer.findEventlog().should('be.visible').click();
notebookServer.findEventlog().should('be.visible').click();

// Wait for the success alert
cy.step('Waits for the Success alert');
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/__tests__/cypress/cypress/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ export type DataScienceProjectData = {
projectContributorResourceName: string;
};

export type NotebookImageData = {
codeserverImageName: string;
};

export type NimServingResponse = {
body: {
body: ConfigMapKind | SecretKind;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const waitForPodReady = (
const ocCommand = `oc get pods ${namespaceFlag} --no-headers | awk '$2 ~ /^${podNameContains}/ {print $1, $2}' | xargs -tn2 oc wait --for=condition=Ready pod --timeout=${timeout} -n`;
cy.log(`Executing: ${ocCommand}`);

return cy.exec(ocCommand, { failOnNonZeroExit: false }).then((result: CommandLineResult) => {
return cy.exec(ocCommand, { failOnNonZeroExit: false, timeout: 300000 }).then((result: CommandLineResult) => {
if (result.code !== 0) {
throw new Error(`Pod readiness check failed: ${result.stderr}`);
}
Expand All @@ -93,6 +93,10 @@ export const deleteNotebook = (
if (result.code !== 0) {
throw new Error(`Command failed with code ${result.stderr}`);
}
cy.log(`Notebook deletion: ${result.stdout}`);
if (result.stdout.trim() === '') {
cy.log('No notebooks found');
} else {
cy.log(`Notebook deletion: ${result.stdout}`);
}
});
};

0 comments on commit 20ef620

Please sign in to comment.