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

[e2e] fix generate support bundle test #1258

Merged
merged 2 commits into from
May 9, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/constants/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export class Constants {
public timeout = { timeout: 10000, maxTimeout: 60000, uploadTimeout: 600000, downloadTimeout: 120000, provisionTimeout: 1500000};
public timeout = { timeout: 10000, maxTimeout: 60000, uploadTimeout: 600000, downloadTimeout: 240000, provisionTimeout: 1500000};
public username = Cypress.env("username");
public password = Cypress.env("password");
public mockPassword = Cypress.env("mockPassword");
Expand Down
8 changes: 4 additions & 4 deletions cypress/testcases/backupAndSnapshot/vmBackup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('VM Backup Validation', () => {
createVMBackupSuccess = true
})

it('Resotre New VM from vm backup', () => {
it('Restore new VM from vm backup', () => {
onlyOn(createVMBackupSuccess);

const newVMName = 'create-new-from-backup';
Expand All @@ -63,7 +63,7 @@ describe('VM Backup Validation', () => {
vms.deleteVMFromStore(`default/${newVMName}`);
})

it('Resotre New VM in another namespace from vm backup', () => {
it('Restore New VM in another namespace from vm backup', () => {
onlyOn(createVMBackupSuccess);

const newVMName = 'create-new-from-backup';
Expand All @@ -77,7 +77,7 @@ describe('VM Backup Validation', () => {
vms.deleteVMFromStore(`default/${newVMName}`);
})

it('Resotre Existing VM from vm backup', () => {
it('Restore Existing VM from vm backup', () => {
onlyOn(createVMBackupSuccess);

vms.goToList();
Expand All @@ -91,7 +91,7 @@ describe('VM Backup Validation', () => {
vms.deleteVMFromStore(`default/test`);
})

it('delete backup', () => {
it('Delete backup', () => {
onlyOn(createVMBackupSuccess);

vmBackups.goToList();
Expand Down
6 changes: 3 additions & 3 deletions cypress/testcases/backupAndSnapshot/vmSnapshot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('VM snapshot Form Validation', () => {
cy.login({url: PageUrl.virtualMachine});
});

it('Take a vm snaphost from vm', () => {
it('Take a vm snapshot from vm', () => {
// Create a vm to test the snapshot operation
const namespace = 'default';

Expand Down Expand Up @@ -47,7 +47,7 @@ describe('VM snapshot Form Validation', () => {
createVMSnapshotSuccess = true
})

it('Resotre New VM from vm snapshot', () => {
it('Restore New VM from vm snapshot', () => {
onlyOn(createVMSnapshotSuccess);

const newVMName = 'create-new-from-snapshot';
Expand All @@ -61,7 +61,7 @@ describe('VM snapshot Form Validation', () => {
vms.deleteVMFromStore(`default/${newVMName}`);
})

it('Resotre Existing VM from vm snapshot', () => {
it('Restore Existing VM from vm snapshot', () => {
onlyOn(createVMSnapshotSuccess);

vms.goToList();
Expand Down
2 changes: 1 addition & 1 deletion cypress/testcases/backupAndSnapshot/volumeSnapshot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Validation volume snapshot', () => {
createVolumeSnapshotSuccess = true
})

it('Resotre New volume from volume snapshot', () => {
it('Restore New volume from volume snapshot', () => {
onlyOn(createVolumeSnapshotSuccess);

const newName = 'create-new-from-snapshot';
Expand Down
4 changes: 2 additions & 2 deletions cypress/testcases/dashboard/0_FirstTimeLogin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("First Time Login Page", () => {
});

context("Set Password", () => {
specify("Password inconsistant", () => {
specify("Password inconsistent", () => {
onlyOn(isFirstTimeLogin);
const page = new LoginPage();
page.visit();
Expand All @@ -52,7 +52,7 @@ describe("First Time Login Page", () => {

});

specify("Password consistant", () => {
specify("Password consistent", () => {
onlyOn(isFirstTimeLogin);
const page = new LoginPage();
page.visit();
Expand Down
59 changes: 33 additions & 26 deletions cypress/testcases/dashboard/support.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,60 +62,67 @@ describe("Support Page", () => {
.should($el => expect($el).to.have.length(0))
})

it('is should download', () => {
it('should download successfully', () => {
let filename: string | undefined = undefined
page.generateSupportBundleBtn.click()

page.inputSupportBundle('this is a test bundle')
.get("@generateBtn").click()
.intercept("/v1/harvester/*supportbundles/**/bundle*", req =>
req.continue(res => {
cy.log(res.body.status)
filename = res.body.status?.filename || undefined
filename = res.body?.metadata?.name
})
)

cy.window().then(win => {
let timeout = {timeout: constants.timeout.downloadTimeout}
return cy.get("@generateView").then(timeout, $el => {
const timeout = {timeout: constants.timeout.downloadTimeout}
cy.log(`Wait for ${timeout.timeout} ms to generate and download support bundle`)
return cy.get("@generateView").then(timeout, ($el) => {
return new Promise((resolve, reject) => {
// delay 3s to refresh page, this will fix page reload bug
// `DOMNodeRemoved` is deprecated, we probably need to use `MutationObserver`
// in the future
$el.one("DOMNodeRemoved", () => setTimeout(() => resolve(win.history.go(0)), 3000))
const modalObserver = new MutationObserver((mutationList) => {
if(mutationList.length && mutationList[0]?.type === "childList") {
// page needs to reload after downloaded support bundle, delay 3s to refresh page
setTimeout(() => resolve(win.history.go(0)), 3000)
}else{
reject('Error: monitoring generate modal closed, no childList mutation found');
}
});
modalObserver.observe($el[0], { childList: true, characterData: true });
})
})
})
.then(() => { // the scope will execute after page reloaded
new Promise((resolve, reject) => {
if (filename !== undefined) {
cy.task("findFiles", {path: Cypress.config("downloadsFolder"), fileName: "supportbundle"})
.then((files: any) => files.length == 1 ? resolve(files[0]) : reject(files))
if(filename === undefined) {
reject('filename is undefined')
}
resolve(filename)
const supportBundle = {path: Cypress.config("downloadsFolder"), fileName: "supportbundle"}
// resolve real bundle filename
cy.task("findFiles", supportBundle)
.then((files: any) => files.length === 1 ? resolve(files[0]) : reject(files))
})
.then(filename => {
cy.log("Downloaded SupportBundle: ", filename)
let zipfilename = `${Cypress.config("downloadsFolder")}/${filename}`
return new Promise((resolve, reject) => {
cy.task("readZipFile", zipfilename)
.then(entries => resolve(entries))
const zipFileName = `${Cypress.config("downloadsFolder")}/${filename}`
// resolve file entries in zip
return new Promise((resolve) => {
cy.task("readZipFile", zipFileName).then(entries => resolve(entries))
})
})
.then((items: any) => {
cy.log(`ZipFile entries: ${items.length}`)
let {dirs, files} = items.reduce((groups: any, e: any) => {
cy.log(`Total file entries in zip : ${items.length}`)

const {dirs, files} = items.reduce((groups: any, e: any) => {
e.isDirectory ? groups.dirs.push(e) : groups.files.push(e)
return groups
}, {dirs:[], files:[]})

cy.log("Total Dirs:", dirs)
cy.log("Total Files:", files)
return {dirs, files}
cy.log("Total Dirs count :", dirs.length)
cy.log("Total Files count:", files.length)
expect(dirs.length).to.greaterThan(0)
expect(files.length).to.greaterThan(0)
})
// .then(({dirs, files}) => {}) // new verfiers here

})
})

})
})
2 changes: 1 addition & 1 deletion cypress/testcases/virtualmachines/virtual-machine.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ describe('VM runStategy Validation (Halted)', () => {

const namespace = 'default'

it('Craete VM use Halted (Run Strategy)', () => {
it('Create VM use Halted (Run Strategy)', () => {
vms.goToCreate();

const imageEnv = Cypress.env('image');
Expand Down