-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c59fbff
commit cfd6ee8
Showing
6 changed files
with
159 additions
and
10 deletions.
There are no files selected for viewing
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
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,42 @@ | ||
import LabeledInputPo from '@/utils/components/labeled-input.po'; | ||
import LabeledSelectPo from '@/utils/components/labeled-select.po'; | ||
import { HCI } from '@/constants/types' | ||
import CruResourcePo from '@/utils/components/cru-resource.po'; | ||
|
||
import { Constants } from "@/constants/constants"; | ||
const constants = new Constants(); | ||
|
||
export default class VMBackup extends CruResourcePo { | ||
constructor() { | ||
super({ | ||
type: HCI.BACKUP, | ||
}); | ||
} | ||
|
||
checkState(name: string, state: string = 'Ready', namespace: string = 'default') { | ||
this.censorInColumn(name, 3, namespace, 4, state, 2, { timeout: constants.timeout.uploadTimeout }); | ||
} | ||
|
||
restoreNew(name: string, newVMName: string, namespace?: string) { | ||
this.clickAction(name, 'Restore New'); | ||
if (namespace) { | ||
new LabeledSelectPo('.labeled-select', `:contains("Namespace")`).select({option: namespace}); | ||
} | ||
|
||
new LabeledInputPo('.labeled-input', `:contains("Virtual Machine Name ")`).input(newVMName); | ||
new LabeledSelectPo('.labeled-select', `:contains("Backup")`).self().contains(name); | ||
this.clickFooterBtn('Create'); | ||
} | ||
|
||
restoreExistingVM(name: string) { | ||
this.clickAction(name, 'Replace Existing'); | ||
new LabeledSelectPo('.labeled-select', `:contains("Namespace")`).isDisabled(); | ||
new LabeledInputPo('.labeled-input', `:contains("Virtual Machine Name")`).isDisabled(); | ||
new LabeledSelectPo('.labeled-select', `:contains("Backup")`).self().contains(name); | ||
this.clickFooterBtn('Create'); | ||
} | ||
|
||
clickFooterBtn(text: string = 'Create') { | ||
cy.get('.footer .buttons').find('.btn').contains(text).click(); | ||
} | ||
} |
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,100 @@ | ||
import { onlyOn } from "@cypress/skip-test"; | ||
import { VmsPage } from "@/pageobjects/virtualmachine.po"; | ||
import VMBackup from '@/pageobjects/vmBackup.po'; | ||
import { PageUrl } from "@/constants/constants"; | ||
|
||
const vms = new VmsPage(); | ||
const vmBackups = new VMBackup(); | ||
|
||
describe('VM Backup Validation', () => { | ||
const vmName = 'test'; | ||
let createVMBackupSuccess: boolean = false ; | ||
const vmBackupName = 'test-vm-backup'; | ||
|
||
beforeEach(() => { | ||
cy.login({url: PageUrl.virtualMachine}); | ||
}); | ||
|
||
it('Take a vm backup from vm', () => { | ||
// Create a vm to test the backup operation | ||
const namespace = 'default'; | ||
|
||
const id = `${namespace}/${vmName}`; | ||
const imageEnv = Cypress.env('image'); | ||
const volume = [{ | ||
buttonText: 'Add Volume', | ||
create: false, | ||
size: '2', | ||
image: `default/${Cypress._.toLower(imageEnv.name)}`, | ||
}]; | ||
|
||
vmBackups.deleteFromStore(`${namespace}/${vmBackupName}`) | ||
vms.deleteVMFromStore(id) | ||
vms.goToCreate(); | ||
vms.deleteVMFromStore(`${namespace}/${vmName}`); | ||
vms.setNameNsDescription(vmName, namespace); | ||
vms.setBasics('1', '1'); | ||
vms.setVolumes(volume); | ||
vms.save(); | ||
|
||
// create a vm snapshot | ||
vms.checkVMState(vmName, 'Running'); | ||
vms.clickVMBackupAction(vmName, vmBackupName); | ||
|
||
// check vm snapshot | ||
vmBackups.goToList(); | ||
// vmBackups.checkState(vmBackupName, vmName); | ||
vmBackups.censorInColumn(vmBackupName, 3, namespace, 4, vmName, 5, { timeout: 5000, nameSelector: 'a' }); | ||
|
||
createVMBackupSuccess = true | ||
}) | ||
|
||
it('Resotre New VM from vm backup', () => { | ||
onlyOn(createVMBackupSuccess); | ||
|
||
const newVMName = 'create-new-from-backup'; | ||
|
||
vms.deleteVMFromStore(`default/${newVMName}`) | ||
vmBackups.goToList(); | ||
vmBackups.restoreNew(vmBackupName, newVMName); | ||
vms.checkVMState(newVMName); | ||
|
||
// delete vm | ||
vms.deleteVMFromStore(`default/${newVMName}`); | ||
}) | ||
|
||
it('Resotre New VM in another namespace from vm backup', () => { | ||
onlyOn(createVMBackupSuccess); | ||
|
||
const newVMName = 'create-new-from-backup'; | ||
|
||
vms.deleteVMFromStore(`default/${newVMName}`) | ||
vmBackups.goToList(); | ||
vmBackups.restoreNew(vmBackupName, newVMName, 'harvester-public'); | ||
vms.checkVMState(newVMName); | ||
|
||
// delete vm | ||
vms.deleteVMFromStore(`default/${newVMName}`); | ||
}) | ||
|
||
it('Resotre Existing VM from vm backup', () => { | ||
onlyOn(createVMBackupSuccess); | ||
|
||
vms.goToList(); | ||
vms.clickAction(vmName, 'Stop'); | ||
vms.checkVMState(vmName, 'Off') | ||
vmBackups.goToList(); | ||
vmBackups.restoreExistingVM(vmBackupName); | ||
vms.checkVMState(vmName); | ||
|
||
// delete vm | ||
vms.deleteVMFromStore(`default/test`); | ||
}) | ||
|
||
it('delete backup', () => { | ||
onlyOn(createVMBackupSuccess); | ||
|
||
vmBackups.goToList(); | ||
vmBackups.deleteFromStore(`default/${vmBackupName}`); | ||
}) | ||
}) |
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