Skip to content
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

Bug 1882197: Add test for golden image upload #6735

Merged
merged 1 commit into from
Sep 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { execSync } from 'child_process';
import { testName } from '@console/internal-integration-tests/protractor.conf';
import { browser, ExpectedConditions as until } from 'protractor';
import { click } from '@console/shared/src/test-utils/utils';
import { errorMessage, saveChangesBtn } from '@console/internal-integration-tests/views/crud.view';
import { pvcStatus } from '@console/ceph-storage-plugin/integration-tests/views/pvc.view';
import { PVC_STATUS } from '@console/ceph-storage-plugin/integration-tests/utils/consts';
import { CDI_UPLOAD_TIMEOUT_SECS, STORAGE_CLASS } from './utils/constants/common';
import { OperatingSystem } from './utils/constants/wizard';
import * as cdiUploadView from '../views/cdiUploadView';
import { PVCData } from './types/pvc';
import { UploadForm } from './models/pvcUploadForm';

// this scenario tests the upload procedure, without creating a vm from the uploaded resource.
// https://issues.redhat.com/browse/CNV-6020

describe('KubeVirt CDI Upload', () => {
const uploadForm = new UploadForm();
const srcImage =
'http://cnv-qe-server.rhevdev.lab.eng.rdu2.redhat.com/files/cnv-tests/cirros-images/cirros-0.4.0-x86_64-disk.qcow2';
const desImage = '/tmp/cirros.qcow2';
const invalidImage = '/tmp/cirros.txt';
const pvcName = `upload-pvc-${testName}`;

beforeAll(async () => {
execSync(`curl ${srcImage} -o ${desImage}`);
execSync(`ln -s -f ${desImage} ${invalidImage}`);
});

afterAll(async () => {
gouyang marked this conversation as resolved.
Show resolved Hide resolved
execSync(`rm ${desImage} ${invalidImage}`);
execSync(`kubectl delete -n ${testName} dv ${pvcName}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we also delete the downloaded image?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, delete the downloaded image also.

});

it(
'ID(CNV-4718) Upload data to CDI',
async () => {
const pvc: PVCData = {
image: desImage,
pvcName: `upload-pvc-${testName}`,
pvcSize: '1',
pvcSizeUnits: 'Gi',
storageClass: STORAGE_CLASS,
};

await uploadForm.upload(pvc);

gouyang marked this conversation as resolved.
Show resolved Hide resolved
await browser.wait(until.textToBePresentInElement(cdiUploadView.uploadProgress, '100%'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we check the final PVC exists?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a step to verify the PVC is in Bound status.

await click(cdiUploadView.viewStatusID);
await browser.wait(until.textToBePresentInElement(pvcStatus, PVC_STATUS.BOUND));
},
CDI_UPLOAD_TIMEOUT_SECS,
);

it(
'ID(CNV-4891) It shows error messsages when image format is not supported',
gouyang marked this conversation as resolved.
Show resolved Hide resolved
async () => {
const pvc: PVCData = {
image: invalidImage,
pvcName: `upload-pvc-${testName}-invalid`,
pvcSize: '1',
pvcSizeUnits: 'Gi',
storageClass: STORAGE_CLASS,
};

await uploadForm.upload(pvc);
await browser.wait(until.presenceOf(errorMessage));
expect(errorMessage.getText()).toContain('not supported');
},
CDI_UPLOAD_TIMEOUT_SECS,
);

it(
'ID(CNV-4890) Upload image for golden OS',
async () => {
const pvc: PVCData = {
image: desImage,
os: OperatingSystem.RHEL7,
pvcSize: '1',
pvcSizeUnits: 'Gi',
storageClass: STORAGE_CLASS,
};

await uploadForm.upload(pvc);
// It has to click the upload button again to trigger uploading based on actual test results.
await click(saveChangesBtn);
await browser.wait(until.textToBePresentInElement(cdiUploadView.uploadProgress, '100%'));
await click(cdiUploadView.viewStatusID);
await browser.wait(until.textToBePresentInElement(pvcStatus, PVC_STATUS.BOUND));
},
CDI_UPLOAD_TIMEOUT_SECS,
);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/* eslint-disable no-await-in-loop */
import { browser, ExpectedConditions as until } from 'protractor';
import {
createItemButton,
isLoaded,
saveChangesBtn,
} from '@console/internal-integration-tests/views/crud.view';
import { clickNavLink } from '@console/internal-integration-tests/views/sidenav.view';
import {
inputPVCName,
inputPVCSize,
selectItemFromDropdown,
storageclassDropdown,
selectAccessMode,
sizeUnitsDropdown,
} from '@console/ceph-storage-plugin/integration-tests/views/pvc.view';
import { click, fillInput } from '@console/shared/src/test-utils/utils';
import { selectOptionByText } from '../utils/utils';
import * as cdiUploadView from '../../views/cdiUploadView';
import { PVCData } from '../types/pvc';

export class UploadForm {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice refactoring :)

async openForm() {
await clickNavLink(['Storage', 'Persistent Volume Claims']);
await isLoaded();
await click(createItemButton);
await click(cdiUploadView.uploadCdiFormButton);

await browser.wait(
until.textToBePresentInElement(
$('.co-m-pane__heading'),
'Upload Data to Persistent Volume Claim',
),
);
}

async fillUploadImage(name: string) {
// firefox needs the input to be shown
await browser.executeAsyncScript((callback) => {
(document.querySelector('input[type="file"]') as HTMLElement).style.display = 'inline';
callback();
});
await cdiUploadView.uploadInput.sendKeys(name);
}

async selectGoldenOS(os: string) {
await click(cdiUploadView.goldenOSCheckbox);
await selectOptionByText(cdiUploadView.goldenOSDropDownID, os);
}

async fillPVCName(pvcName: string) {
await fillInput(inputPVCName, pvcName);
}

async selectStorageClass(sc: string) {
await selectItemFromDropdown(sc, storageclassDropdown);
}

async fillPVCSize(pvcSize: string, pvcSizeUnits: string) {
await inputPVCSize.sendKeys(pvcSize);
await selectItemFromDropdown(pvcSizeUnits, sizeUnitsDropdown);
}

async selectAccessMode(accessMode: string) {
await click(selectAccessMode(accessMode));
}

async fillAll(data: PVCData) {
const { image, os, pvcName, pvcSize, pvcSizeUnits, storageClass, accessMode } = data;
await this.selectStorageClass(storageClass);
await this.fillPVCSize(pvcSize, pvcSizeUnits);
if (accessMode) {
await this.selectAccessMode(accessMode);
}
if (os) {
this.selectGoldenOS(os);
} else {
await this.fillPVCName(pvcName);
}
await this.fillUploadImage(image);
}

async upload(data: PVCData) {
await this.openForm();
await this.fillAll(data);
await click(saveChangesBtn);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export type PVCData = {
image: string;
os?: string;
pvcName?: string;
pvcSize: string;
pvcSizeUnits: string;
storageClass: string;
accessMode?: string;
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export const JASMINE_EXTENDED_TIMEOUT_INTERVAL = 500 * SEC;
export const V2V_INSTANCE_CONNECTION_TIMEOUT = 30 * SEC;
export const V2V_VM_IMPORT_TIMEOUT = 3600 * SEC;

export const CDI_UPLOAD_TIMEOUT_SECS = 300 * SEC;

export const VIRTUALIZATION_TITLE = 'Virtualization';

// Wizard strings
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { element, by, $ } from 'protractor';

export const uploadCdiFormButton = element(by.partialButtonText('Data upload'));
export const uploadInput = $('input[type="file"]');
export const unitDropdown = $('button[data-test-id="dropdown-button"]');
gouyang marked this conversation as resolved.
Show resolved Hide resolved
export const uploadProgress = element.all(by.css('.pf-c-progress__measure')).first();
export const goldenOSCheckbox = $('#golden-os-switch');
export const goldenOSDropDownID = $('#golden-os-select');
export const viewStatusID = $('#cdi-upload-primary-pvc');