Skip to content

Commit

Permalink
add kubevirt pvc upload test
Browse files Browse the repository at this point in the history
  • Loading branch information
gouyang committed Jun 9, 2021
1 parent c86d34b commit 88f5cee
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import { testName } from '../../support';
import { TEMPLATE_BASE_IMAGE, TEMPLATE_NAME, OS_IMAGES_NS } from '../../const/index';
import { ProvisionSource } from '../../enums/provisionSource';
import { VirtualMachineData } from '../../types/vm';
import { virtualization } from '../../view/virtualization';
import { pvc } from '../../view/pvc';
import { vm } from '../../view/vm';

const imageFormats = ['/tmp/cirros.iso', '/tmp/cirros.gz', '/tmp/cirros.xz'];
const invalidImage = '/tmp/cirros.txt';
const os = 'Red Hat Enterprise Linux 6.0 or higher - Default data image already exists';
const vmData: VirtualMachineData = {
name: `pvc-test-vm-${testName}`,
namespace: testName,
template: TEMPLATE_NAME,
sshEnable: false,
startOnCreation: true,
sourceAvailable: true,
};

describe('kubevirt PVC upload', () => {
before(() => {
cy.viewport(1536, 960);
cy.Login();
cy.visit('/');
cy.createProject(testName);
});

after(() => {
cy.deleteResource({
kind: 'DataVolume',
metadata: {
name: TEMPLATE_BASE_IMAGE,
namespace: OS_IMAGES_NS,
},
});
cy.deleteResource({
kind: 'VirtualMachine',
metadata: {
name: vmData.name,
namespace: vmData.namespace,
},
});
cy.exec('rm -fr /tmp/cirror*');
});

describe('test pvc upload via form', () => {
it('ID(CNV-4778) No warning message shows when image format is supported', () => {
pvc.form.open();
for (const img of imageFormats) {
cy.exec(`touch ${img} || true`);
cy.dropFile(img, img.split('/').pop(), '.pf-c-file-upload');
cy.get('.pf-c-alert__title')
.contains('File type extension')
.should('not.exist');
}
});

it('ID(CNV-4891) It shows a warning message when image format is not supported', () => {
pvc.form.open();
cy.exec(`touch ${invalidImage} || true`);
cy.dropFile(invalidImage, invalidImage.split('/').pop(), '.pf-c-file-upload');
cy.get('.pf-c-alert__title')
.contains('File type extension')
.should('exist');
});

it('ID(CNV-5176) It shows an error when uploading data to golden OS again', () => {
cy.createDataVolume(TEMPLATE_BASE_IMAGE, OS_IMAGES_NS);
pvc.form.open();
pvc.form.selectOS(os);
cy.get('.pf-c-alert__title')
.contains('Operating system source already defined')
.should('exist');
});

it('ID(CNV-5041) VM can be up after deleting the uploaded PVC', () => {
vm.create(vmData);
vm.stop(vmData);
// only delete template pvc for ocs, hpp does not support this
if (Cypress.env('STORAGE_CLASS') === 'ocs-storagecluster-ceph-rbd') {
cy.deleteResource({
kind: 'DataVolume',
metadata: {
name: TEMPLATE_BASE_IMAGE,
namespace: OS_IMAGES_NS,
},
});
}
vm.start(vmData);
vm.delete();
});
});

describe('test pvc upload via cli', () => {
it('ID(CNV-5044) Verify boot source is available for template after upload via cli', () => {
cy.exec(
`test -f ${Cypress.env(
'UPLOAD_IMG',
)} || curl --fail -L ${ProvisionSource.URL.getSource()} -o ${Cypress.env('UPLOAD_IMG')}`,
{ timeout: 600000 },
);
if (Cypress.env('STORAGE_CLASS') === 'ocs-storagecluster-ceph-rbd') {
cy.exec(
`virtctl image-upload dv ${TEMPLATE_BASE_IMAGE} --image-path=${Cypress.env(
'UPLOAD_IMG',
)} --size=1Gi --storage-class=ocs-storagecluster-ceph-rbd --access-mode=ReadWriteMany --block-volume -n ${OS_IMAGES_NS} --insecure || true`,
);
}
if (Cypress.env('STORAGE_CLASS') === 'hostpath-provisioner') {
cy.exec(
`virtctl image-upload dv ${TEMPLATE_BASE_IMAGE} --image-path=${Cypress.env(
'UPLOAD_IMG',
)} --size=1Gi --storage-class=hostpath-provisioner --access-mode=ReadWriteOnce -n ${OS_IMAGES_NS} --insecure || true`,
);
}

virtualization.templates.visit();
virtualization.templates.testSource(TEMPLATE_NAME, 'Unknown');
});

it('ID(CNV-5597) Verify create VM from the template which source is uploaded via CLI', () => {
vm.create(vmData);
vm.stop(vmData);
vm.delete();
});

it('ID(CNV-5598) Delete DV/PVC from CLI', () => {
cy.deleteResource({
kind: 'DataVolume',
metadata: {
name: TEMPLATE_BASE_IMAGE,
namespace: OS_IMAGES_NS,
},
});
virtualization.templates.visit();
virtualization.templates.testSource(TEMPLATE_NAME, 'Add source');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ export type VirtualMachineData = {
cdrom?: boolean;
sshEnable?: boolean;
startOnCreation?: boolean;
sourceAvailable?: boolean;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
export const pvc = {
form: {
open: () => {
cy.clickNavLink(['Storage', 'PersistentVolumeClaims']);
cy.byTestID('item-create').click();
cy.byLegacyTestID('dropdown-menu')
.contains('With Data upload form')
.click();
},
fillImageName: (name: string) => {
cy.get('#file-upload-filename')
.type(name, { force: true })
.should('have.value', name);
},
selectOS: (name: string) => {
cy.get('#golden-os-switch').click();
cy.get('#golden-os-select').select(name);
},
fillPVCName: (name: string) => {
cy.get('#pvc-name')
.clear()
.type(name);
},
fillPVCSize: (size: string) => {
cy.get('#request-size-input')
.clear()
.type(size);
},
selectSC: (name: string) => {
cy.get('#upload-form-ds-sc-select').click();
cy.get('.pf-c-select__menu-item')
.contains(name)
.click();
},
create: () => {
cy.get('#save-changes').click();
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,20 @@ export const vm = {
name,
namespace,
provisionSource,
pvcName,
pvcNS,
pvcSize,
sshEnable,
startOnCreation,
template,
sourceAvailable,
} = vmData;
virtualization.vms.visit();
wizard.vm.open();
wizard.vm.processSelectTemplate(template);
wizard.vm.processBootSource(provisionSource, cdrom, pvcSize);
if (!sourceAvailable || sourceAvailable === undefined) {
wizard.vm.processBootSource(provisionSource, cdrom, pvcSize, pvcName, pvcNS);
}
wizard.vm.processReview(namespace, name, flavor, sshEnable, startOnCreation);
},
start: (vmData: VirtualMachineData) => {
Expand Down

0 comments on commit 88f5cee

Please sign in to comment.