-
Notifications
You must be signed in to change notification settings - Fork 178
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
test: Cypress - Verify users can create a workbench and connect an existent PersistentVolume #3511
Merged
openshift-merge-bot
merged 10 commits into
opendatahub-io:main
from
FedeAlonso:test/RHOAIENG-14370
Nov 26, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f898e33
test: Cypress - Verify users can create a workbench and connect an ex…
FedeAlonso aa5b878
Merge branch 'main' into test/RHOAIENG-14370
FedeAlonso 3783ce9
lint fixes
FedeAlonso d45577d
Merge branch 'main' into test/RHOAIENG-14370
FedeAlonso df5b07f
Merge branch 'main' into test/RHOAIENG-14370
FedeAlonso 5792daa
Add PVC size
FedeAlonso 74df072
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard into t…
FedeAlonso 634af62
PR Fixes
FedeAlonso bb3260f
Merge branch 'main' into test/RHOAIENG-14370
FedeAlonso 4b34981
Merge branch 'main' into test/RHOAIENG-14370
FedeAlonso File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
frontend/src/__tests__/cypress/cypress/fixtures/e2e/dataScienceProjects/testProjectWbPV.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# workbenches.cy.ts Test Data # | ||
NAMESPACE: 'dsp-wb-test' | ||
PVC_NAME: 'pvc-test-name' | ||
PVC_DISPLAY_NAME: 'pvc-test-display-name' | ||
PVC_SIZE: '10' |
22 changes: 22 additions & 0 deletions
22
frontend/src/__tests__/cypress/cypress/fixtures/resources/yaml/persistentVolumeClaim.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
kind: PersistentVolumeClaim | ||
apiVersion: v1 | ||
metadata: | ||
name: {{PVC_NAME}} | ||
namespace: {{NAMESPACE}} | ||
labels: | ||
opendatahub.io/dashboard: 'true' | ||
annotations: | ||
openshift.io/description: '' | ||
openshift.io/display-name: {{PVC_DISPLAY_NAME}} | ||
finalizers: | ||
- kubernetes.io/pvc-protection | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: {{PVC_SIZE}}Gi | ||
storageClassName: standard-csi | ||
volumeMode: Filesystem | ||
status: | ||
phase: Pending |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/workbenches/workbenches.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import type { PVCReplacements } from '~/__tests__/cypress/cypress/types'; | ||
import { projectDetails, projectListPage } from '~/__tests__/cypress/cypress/pages/projects'; | ||
import { workbenchPage, createSpawnerPage } from '~/__tests__/cypress/cypress/pages/workbench'; | ||
import { clusterStorage } from '~/__tests__/cypress/cypress/pages/clusterStorage'; | ||
import { HTPASSWD_CLUSTER_ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; | ||
import { loadPVCFixture } from '~/__tests__/cypress/cypress/utils/dataLoader'; | ||
import { createCleanProject } from '~/__tests__/cypress/cypress/utils/projectChecker'; | ||
import { deleteOpenShiftProject } from '~/__tests__/cypress/cypress/utils/oc_commands/project'; | ||
import { createPersistentVolumeClaim } from '~/__tests__/cypress/cypress/utils/oc_commands/presistentVolumeClaim'; | ||
|
||
describe('Workbench and PVSs tests', () => { | ||
// let testData: PVCReplacements; | ||
let projectName: string; | ||
let PVCName: string; | ||
let PVCDisplayName: string; | ||
let PVCSize: string; | ||
|
||
before(() => { | ||
return loadPVCFixture('e2e/dataScienceProjects/testProjectWbPV.yaml') | ||
.then((fixtureData: PVCReplacements) => { | ||
projectName = fixtureData.NAMESPACE; | ||
PVCName = fixtureData.PVC_NAME; | ||
PVCDisplayName = fixtureData.PVC_DISPLAY_NAME; | ||
PVCSize = fixtureData.PVC_SIZE; | ||
|
||
if (!projectName) { | ||
throw new Error('Project name is undefined or empty in the loaded fixture'); | ||
} | ||
cy.log(`Loaded project name: ${projectName}`); | ||
return createCleanProject(projectName); | ||
}) | ||
.then(() => { | ||
cy.log(`Project ${projectName} confirmed to be created and verified successfully`); | ||
const pvcReplacements: PVCReplacements = { | ||
NAMESPACE: projectName, | ||
PVC_NAME: PVCName, | ||
PVC_DISPLAY_NAME: PVCDisplayName, | ||
PVC_SIZE: PVCSize, | ||
}; | ||
return createPersistentVolumeClaim(pvcReplacements); | ||
}) | ||
.then((commandResult) => { | ||
cy.log(`Persistent Volume Claim created: ${JSON.stringify(commandResult)}`); | ||
}); | ||
}); | ||
|
||
after(() => { | ||
// Delete provisioned Project | ||
if (projectName) { | ||
cy.log(`Deleting Project ${projectName} after the test has finished.`); | ||
deleteOpenShiftProject(projectName); | ||
} | ||
}); | ||
|
||
it('Verify users can create a workbench and connect an existent PersistentVolume', () => { | ||
const workbenchName = projectName.replace('dsp-', ''); | ||
|
||
// Authentication and navigation | ||
cy.step('Log into the application'); | ||
cy.visitWithLogin('/', HTPASSWD_CLUSTER_ADMIN_USER); | ||
|
||
cy.step(`Navigate to Workbenches tab of Project ${projectName}`); | ||
projectListPage.navigate(); | ||
projectListPage.filterProjectByName(projectName); | ||
projectListPage.findProjectLink(projectName).click(); | ||
projectDetails.findSectionTab('workbenches').click(); | ||
|
||
cy.step(`Create Workbench ${projectName} using storage ${PVCDisplayName}`); | ||
workbenchPage.findCreateButton().click(); | ||
createSpawnerPage.getNameInput().fill(workbenchName); | ||
createSpawnerPage.findNotebookImage('s2i-minimal-notebook').click(); | ||
createSpawnerPage.findExsistingPersistentStorageRadio().click(); | ||
createSpawnerPage.selectExistingPersistentStorage(PVCDisplayName); | ||
createSpawnerPage.findSubmitButton().click(); | ||
|
||
cy.step(`Wait for Workbench ${workbenchName} to display a "Running" status`); | ||
const notebookRow = workbenchPage.getNotebookRow(workbenchName); | ||
notebookRow.expectStatusLabelToBe('Running', 120000); | ||
notebookRow.shouldHaveNotebookImageName('Minimal Python'); | ||
notebookRow.shouldHaveContainerSize('Small'); | ||
|
||
cy.step(`Check the cluster storage ${PVCDisplayName} is now connected to ${workbenchName}`); | ||
projectDetails.findSectionTab('cluster-storages').click(); | ||
const csRow = clusterStorage.getClusterStorageRow(PVCDisplayName); | ||
csRow.findConnectedWorkbenches().should('have.text', workbenchName); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
frontend/src/__tests__/cypress/cypress/utils/oc_commands/presistentVolumeClaim.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { PVCReplacements, CommandLineResult } from '~/__tests__/cypress/cypress/types'; | ||
import { replacePlaceholdersInYaml } from '~/__tests__/cypress/cypress/utils/yaml_files'; | ||
import { applyOpenShiftYaml } from './baseCommands'; | ||
|
||
/** | ||
* Create an Persistent Volume Claim based on the PVCReplacements config | ||
* @param persistentVolumeClaimReplacements Dictionary with the config values | ||
* Dict Structure: | ||
* export type PVCReplacements = { | ||
* NAMESPACE: string; | ||
* PVC_NAME: string; | ||
* PVC_DISPLAY_NAME: string; | ||
* PVC_SIZE: string; | ||
* }; | ||
* @param yamlFilePath | ||
*/ | ||
export const createPersistentVolumeClaim = ( | ||
FedeAlonso marked this conversation as resolved.
Show resolved
Hide resolved
|
||
persistentVolumeClaimReplacements: PVCReplacements, | ||
yamlFilePath = 'resources/yaml/persistentVolumeClaim.yaml', | ||
): Cypress.Chainable<CommandLineResult> => { | ||
return cy.fixture(yamlFilePath).then((yamlContent) => { | ||
cy.log(yamlContent); | ||
const modifiedYamlContent = replacePlaceholdersInYaml( | ||
yamlContent, | ||
persistentVolumeClaimReplacements, | ||
); | ||
return applyOpenShiftYaml(modifiedYamlContent); | ||
}); | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we reference these values also from the fixtures file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... I don't really understand what do you mean here.
notebookRow is an object, which gets selected dinamically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antowaddle if you meant 's2i-minimal-notebook' - it comes from the Dashboard UI, not from test data, so there's no need to add it to fixtures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my comment wasn't clear. I was referring to the values below.