Skip to content

Commit

Permalink
tests: adjust pv test to test nfs and csi
Browse files Browse the repository at this point in the history
  • Loading branch information
mrCherry97 committed Aug 22, 2024
1 parent 336653d commit cceb08b
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 12 deletions.
23 changes: 23 additions & 0 deletions tests/integration/fixtures/test-persistent-volume-CSI.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
kind: PersistentVolume
apiVersion: v1
metadata:
name: csi
spec:
capacity:
storage: 5Gi
csi:
driver: csi-driver.example.com
volumeHandle: existingVolumeName
fsType: ext4
volumeAttributes:
test: mount
test2: mount2
accessModes:
- ReadWriteOnce
claimRef:
kind: PersistentVolumeClaim
namespace: default
name: test123
apiVersion: v1
persistentVolumeReclaimPolicy: Retain
volumeMode: Filesystem
109 changes: 97 additions & 12 deletions tests/integration/tests/cluster/test-persistent-volumes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
import 'cypress-file-upload';
import { loadFile } from '../../support/loadFile';

const PV_NAME = `test-pv-${Math.random()
const PV_NFS_NAME = `test-pv-${Math.random()
.toString()
.substr(2, 8)}`;

async function loadPV(pvName) {
const PV = await loadFile('test-persistent-volumes.yaml');
const PV_CSI_NAME = `test-pv-${Math.random()
.toString()
.substr(2, 8)}`;

async function loadPV(pvName, fileName) {
const PV = await loadFile(fileName);

const newPV = { ...PV };
newPV.metadata.name = pvName;
Expand All @@ -21,34 +25,115 @@ context('Test Persistent Volumes', () => {
cy.loginAndSelectCluster();
});

it('Create PV', () => {
it('Create PV with NFS', () => {
cy.navigateTo('Storage', 'Persistent Volumes');

cy.openCreate().click();

cy.wrap(loadPV(PV_NAME)).then(PV_CONFIG => {
const PV = JSON.stringify(PV_CONFIG);
cy.pasteToMonaco(PV);
});
cy.wrap(loadPV(PV_NFS_NAME, 'test-persistent-volume-NFS.yaml')).then(
PV_CONFIG => {
const PV = JSON.stringify(PV_CONFIG);
cy.pasteToMonaco(PV);
},
);

cy.saveChanges('Create');

cy.contains('ui5-title', PV_NAME).should('be.visible');
cy.contains('ui5-title', PV_NFS_NAME).should('be.visible');
});

it('Check PV details', () => {
it('Check PV with NFS details', () => {
cy.getMidColumn()
.contains('ReadWriteOnce')
.should('be.visible');

cy.getMidColumn()
.contains('Events')
.should('be.visible');

cy.getMidColumn()
.contains('Filesystem')
.should('be.visible');

cy.getMidColumn()
.contains('Recycle')
.should('be.visible');

cy.getMidColumn()
.contains('slow')
.should('be.visible');

cy.getMidColumn()
.contains('Network File System')
.should('be.visible');

cy.getMidColumn()
.contains('172.17.0.2')
.should('be.visible');

cy.getMidColumn()
.contains('/tmp')
.should('be.visible');
});

it('Check PV with NFS on the list and delete', () => {
cy.closeMidColumn();

cy.deleteFromGenericList('Persistent Volume', PV_NFS_NAME);
});

it('Create PV with CSI', () => {
cy.openCreate().click();

cy.wrap(loadPV(PV_CSI_NAME, 'test-persistent-volume-NFS.yaml')).then(
PV_CONFIG => {
const PV = JSON.stringify(PV_CONFIG);
cy.pasteToMonaco(PV);
},
);

cy.saveChanges('Create');

cy.contains('ui5-title', PV_CSI_NAME).should('be.visible');
});

it('Check PV with NFS details', () => {
cy.getMidColumn()
.contains('ReadWriteOnce')
.should('be.visible');

cy.getMidColumn()
.contains('Events')
.should('be.visible');

cy.getMidColumn()
.contains('Filesystem')
.should('be.visible');

cy.getMidColumn()
.contains('Retain')
.should('be.visible');

cy.getMidColumn()
.contains('ext4')
.should('be.visible');

cy.getMidColumn()
.contains('Container Storage Interface')
.should('be.visible');

cy.getMidColumn()
.contains('csi-driver.example.com')
.should('be.visible');

cy.getMidColumn()
.contains('existingVolumeName')
.should('be.visible');
});

it('Check PV list and delete', () => {
it('Check PV with NFS on the list and delete', () => {
cy.closeMidColumn();

cy.deleteFromGenericList('Persistent Volume', PV_NAME);
cy.deleteFromGenericList('Persistent Volume', PV_CSI_NAME);
});
});

0 comments on commit cceb08b

Please sign in to comment.