-
Notifications
You must be signed in to change notification settings - Fork 593
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
Showing
5 changed files
with
295 additions
and
2 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
96 changes: 96 additions & 0 deletions
96
frontend/packages/kubevirt-plugin/integration-tests/tests/vmi.actions.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,96 @@ | ||
import { browser, ExpectedConditions as until } from 'protractor'; | ||
import { testName } from '@console/internal-integration-tests/protractor.conf'; | ||
import { | ||
resourceRows, | ||
resourceRowsPresent, | ||
isLoaded, | ||
textFilter, | ||
} from '@console/internal-integration-tests/views/crud.view'; | ||
import { | ||
addLeakableResource, | ||
createResource, | ||
removeLeakedResources, | ||
removeLeakableResource, | ||
waitForCount, | ||
} from '@console/shared/src/test-utils/utils'; | ||
import { getVMIManifest } from './utils/mocks'; | ||
import { fillInput } from './utils/utils'; | ||
import { | ||
PAGE_LOAD_TIMEOUT_SECS, | ||
VMI_ACTION, | ||
TAB, | ||
VM_IMPORT_TIMEOUT_SECS, | ||
VM_STATUS, | ||
} from './utils/consts'; | ||
import { VirtualMachine } from './models/virtualMachine'; | ||
|
||
const waitForVM = async ( | ||
manifest: any, | ||
status: VM_STATUS, | ||
resourcesSet: Set<string>, | ||
kind?: 'virtualmachines' | 'virtualmachineinstances', | ||
) => { | ||
const vm = new VirtualMachine(manifest.metadata, kind || 'virtualmachines'); | ||
|
||
createResource(manifest); | ||
addLeakableResource(resourcesSet, manifest); | ||
await vm.waitForStatus(status); | ||
|
||
return vm; | ||
}; | ||
|
||
const waitForVMDelete = async (vm: VirtualMachine) => { | ||
await vm.navigateToListView(); | ||
await isLoaded(); | ||
|
||
await fillInput(textFilter, vm.name); | ||
await resourceRowsPresent(); | ||
|
||
await browser.wait(until.and(waitForCount(resourceRows, 0)), PAGE_LOAD_TIMEOUT_SECS); | ||
}; | ||
|
||
describe('Test VMI actions', () => { | ||
const leakedResources = new Set<string>(); | ||
|
||
afterAll(async () => { | ||
removeLeakedResources(leakedResources); | ||
}); | ||
|
||
describe('Test VMI list view kebab dropdown', () => { | ||
let vm: VirtualMachine; | ||
let testVM: any; | ||
|
||
beforeAll(async () => { | ||
testVM = getVMIManifest('Container', testName, `vm-list-actions-${testName}`); | ||
vm = await waitForVM(testVM, VM_STATUS.Running, leakedResources, 'virtualmachineinstances'); | ||
}, VM_IMPORT_TIMEOUT_SECS); | ||
|
||
it('Deletes VMI', async () => { | ||
await vm.navigateToListView(); | ||
await isLoaded(); | ||
|
||
await vm.listViewAction(VMI_ACTION.Delete, false); | ||
removeLeakableResource(leakedResources, testVM); | ||
await waitForVMDelete(vm); | ||
}); | ||
}); | ||
|
||
describe('Test VMI detail view actions dropdown', () => { | ||
let vm: VirtualMachine; | ||
let testVM: any; | ||
|
||
beforeAll(async () => { | ||
testVM = getVMIManifest('Container', testName, `vm-detail-actions-${testName}`); | ||
vm = await waitForVM(testVM, VM_STATUS.Running, leakedResources, 'virtualmachineinstances'); | ||
}, VM_IMPORT_TIMEOUT_SECS); | ||
|
||
it('Deletes VM', async () => { | ||
await vm.navigateToTab(TAB.Details); | ||
await isLoaded(); | ||
|
||
await vm.action(VMI_ACTION.Delete, false); | ||
removeLeakableResource(leakedResources, testVM); | ||
await waitForVMDelete(vm); | ||
}); | ||
}); | ||
}); |
74 changes: 74 additions & 0 deletions
74
frontend/packages/kubevirt-plugin/integration-tests/tests/vmi.dashboard.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,74 @@ | ||
import { testName } from '@console/internal-integration-tests/protractor.conf'; | ||
import { | ||
addLeakableResource, | ||
removeLeakedResources, | ||
createResource, | ||
} from '@console/shared/src/test-utils/utils'; | ||
import { VirtualMachineInstanceModel } from '../../src/models'; | ||
import { | ||
vmDetailsName, | ||
vmDetailsNamespace, | ||
vmDetailsNode, | ||
vmDetailsIPAddress, | ||
vmStatus, | ||
vmInventoryNICs, | ||
vmInventoryDisks, | ||
} from '../views/dashboard.view'; | ||
import { getVMIManifest } from './utils/mocks'; | ||
import { VirtualMachine } from './models/virtualMachine'; | ||
import { VM_STATUS, NOT_AVAILABLE } from './utils/consts'; | ||
|
||
const waitForVM = async ( | ||
manifest: any, | ||
status: VM_STATUS, | ||
resourcesSet: Set<string>, | ||
kind?: 'virtualmachines' | 'virtualmachineinstances', | ||
) => { | ||
const vm = new VirtualMachine(manifest.metadata, kind || 'virtualmachines'); | ||
|
||
createResource(manifest); | ||
addLeakableResource(resourcesSet, manifest); | ||
await vm.waitForStatus(status); | ||
|
||
return vm; | ||
}; | ||
|
||
describe('Test VMI dashboard', () => { | ||
const leakedResources = new Set<string>(); | ||
const testVM = getVMIManifest('Container', testName); | ||
|
||
let vm: VirtualMachine; | ||
|
||
afterAll(async () => { | ||
removeLeakedResources(leakedResources); | ||
}); | ||
|
||
beforeAll(async () => { | ||
vm = await waitForVM(testVM, VM_STATUS.Running, leakedResources, 'virtualmachineinstances'); | ||
await vm.navigateToDashboard(); | ||
}); | ||
|
||
it('Inventory card', async () => { | ||
expect(vmInventoryNICs.getText()).toEqual('1 NIC'); | ||
expect(vmInventoryNICs.$('a').getAttribute('href')).toMatch( | ||
new RegExp(`.*/k8s/ns/${vm.namespace}/${VirtualMachineInstanceModel.plural}/${vm.name}/nics`), | ||
); | ||
expect(vmInventoryDisks.getText()).toEqual('1 Disk'); | ||
expect(vmInventoryDisks.$('a').getAttribute('href')).toMatch( | ||
new RegExp( | ||
`.*/k8s/ns/${vm.namespace}/${VirtualMachineInstanceModel.plural}/${vm.name}/disks`, | ||
), | ||
); | ||
}); | ||
|
||
it('Status card', async () => { | ||
expect(vmStatus.getText()).toEqual(VM_STATUS.Running); | ||
}); | ||
|
||
it('Details card', async () => { | ||
expect(vmDetailsName.getText()).toEqual(vm.name); | ||
expect(vmDetailsNamespace.getText()).toEqual(vm.namespace); | ||
expect(vmDetailsNode.getText()).not.toEqual(NOT_AVAILABLE); | ||
expect(vmDetailsIPAddress.getText()).not.toEqual(NOT_AVAILABLE); | ||
}); | ||
}); |
105 changes: 105 additions & 0 deletions
105
frontend/packages/kubevirt-plugin/integration-tests/tests/vmi.overview.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,105 @@ | ||
import * as _ from 'lodash'; | ||
import { testName } from '@console/internal-integration-tests/protractor.conf'; | ||
import { isLoaded, resourceTitle } from '@console/internal-integration-tests/views/crud.view'; | ||
import { asyncForEach, createResource, deleteResource } from '@console/shared/src/test-utils/utils'; | ||
import * as vmView from '../views/virtualMachine.view'; | ||
import { getVMIManifest, basicVMConfig } from './utils/mocks'; | ||
import { exposeServices } from './utils/utils'; | ||
import { VirtualMachine } from './models/virtualMachine'; | ||
import { TAB, VM_STATUS, NOT_AVAILABLE } from './utils/consts'; | ||
import { NodePortService } from './utils/types'; | ||
|
||
describe('Test VMI overview', () => { | ||
const vmiName = `vmi-${testName}`; | ||
const cloudInit = `#cloud-config\nuser: cloud-user\npassword: atomic\nchpasswd: {expire: False}`; | ||
const serviceCommon = { name: vmiName, kind: 'vmi', type: 'NodePort', namespace: testName }; | ||
const testVMI = getVMIManifest('Container', testName, vmiName, cloudInit); | ||
const vmi = new VirtualMachine(testVMI.metadata, 'virtualmachineinstances'); | ||
const nodePortServices = new Set<NodePortService>(); | ||
nodePortServices.add({ | ||
...serviceCommon, | ||
exposeName: `${vmiName}-service-ssh`, | ||
port: '22', | ||
targetPort: '20022', | ||
}); | ||
nodePortServices.add({ | ||
...serviceCommon, | ||
exposeName: `${vmiName}-service-smtp`, | ||
port: '25', | ||
targetPort: '20025', | ||
}); | ||
nodePortServices.add({ | ||
...serviceCommon, | ||
exposeName: `${vmiName}-service-http`, | ||
port: '80', | ||
targetPort: '20080', | ||
}); | ||
|
||
beforeAll(async () => { | ||
createResource(testVMI); | ||
await vmi.waitForStatus(VM_STATUS.Running); | ||
|
||
exposeServices(nodePortServices); | ||
}); | ||
|
||
afterAll(() => { | ||
deleteResource(testVMI); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await vmi.navigateToTab(TAB.Details); | ||
await isLoaded(); | ||
}); | ||
|
||
it('Check VMI details in overview', async () => { | ||
const expectation = { | ||
name: vmiName, | ||
status: VM_STATUS.Running, | ||
description: testName, | ||
os: basicVMConfig.operatingSystem, | ||
profile: basicVMConfig.workloadProfile, | ||
bootOrderTexts: ['rootdisk (Disk)', 'nic0 (NIC)', 'cloudinitdisk (Disk)'], | ||
flavorText: 'Tiny: 1 vCPU, 1 GiB Memory', | ||
}; | ||
|
||
const found = { | ||
name: await resourceTitle.getText(), | ||
status: await vmi.getStatus(), | ||
description: await vmView.vmDetailDesc(testName, vmiName).getText(), | ||
os: await vmView.vmDetailOS(testName, vmiName).getText(), | ||
profile: await vmView.vmDetailWorkloadProfile(testName, vmiName).getText(), | ||
bootOrderTexts: await vmView.vmDetailBootOrder(testName, vmiName).getText(), | ||
flavorText: await vmView.vmDetailFlavor(testName, vmiName).getText(), | ||
}; | ||
|
||
const equal = _.isEqual(found, expectation); | ||
if (!equal) { | ||
// eslint-disable-next-line no-console | ||
console.error(`Expected:\n${JSON.stringify(expectation)},\nGot:\n${JSON.stringify(found)}`); | ||
} | ||
expect(equal).toBe(true); | ||
|
||
expect(await vmView.vmDetailIP(testName, vmiName).getText()).not.toEqual(NOT_AVAILABLE); | ||
expect( | ||
await vmView | ||
.vmDetailPod(testName, vmiName) | ||
.$('a') | ||
.getText(), | ||
).toContain('virt-launcher'); | ||
expect( | ||
await vmView | ||
.vmDetailNode(testName, vmiName) | ||
.$('a') | ||
.getText(), | ||
).not.toEqual(NOT_AVAILABLE); | ||
}); | ||
|
||
it('Check VMI services', async () => { | ||
await asyncForEach(nodePortServices, async (srv) => { | ||
expect(await vmView.vmDetailService(srv.exposeName).getText()).toEqual(srv.exposeName); | ||
expect(await vmView.vmDetailService(srv.exposeName).getAttribute('href')).toContain( | ||
`/k8s/ns/${testName}/services/${srv.exposeName}`, | ||
); | ||
}); | ||
}); | ||
}); |