forked from openshift/console
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1882197: Add test for golden image upload
- Loading branch information
Showing
5 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
frontend/packages/kubevirt-plugin/integration-tests/tests/cdi-upload.scenario.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,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 () => { | ||
execSync(`rm ${desImage} ${invalidImage}`); | ||
execSync(`kubectl delete -n ${testName} dv ${pvcName}`); | ||
}); | ||
|
||
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); | ||
|
||
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, | ||
); | ||
|
||
it( | ||
'ID(CNV-4891) It shows error messsages when image format is not supported', | ||
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, | ||
); | ||
}); |
88 changes: 88 additions & 0 deletions
88
frontend/packages/kubevirt-plugin/integration-tests/tests/models/pvcUploadForm.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,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 { | ||
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); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
frontend/packages/kubevirt-plugin/integration-tests/tests/types/pvc.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,9 @@ | ||
export type PVCData = { | ||
image: string; | ||
os?: string; | ||
pvcName?: string; | ||
pvcSize: string; | ||
pvcSizeUnits: string; | ||
storageClass: string; | ||
accessMode?: string; | ||
}; |
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
9 changes: 9 additions & 0 deletions
9
frontend/packages/kubevirt-plugin/integration-tests/views/cdiUploadView.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,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"]'); | ||
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'); |