diff --git a/pkg/qe-tests/cypress/integration/models/providerVmware.ts b/pkg/qe-tests/cypress/integration/models/providerVmware.ts index 7db94cb5..15d0d806 100644 --- a/pkg/qe-tests/cypress/integration/models/providerVmware.ts +++ b/pkg/qe-tests/cypress/integration/models/providerVmware.ts @@ -183,4 +183,17 @@ export class ProviderVmware extends Provider { this.fillESxiPassword(esxiPassword); confirm(); } + + moveCluster(providerData: VmwareProviderData): void { + const { hostname } = providerData; + let cmd = 'oc delete pod/move-cluster-to-folder'; + cmd += `; oc run --env FORKLIFT_NAMESPACE=openshift-mtv --env CLUSTER_NAME=MTV --env SERVER=${hostname} --env USER=xxx --env PASSWORD=xxx --env IGNOR_CERT_CHECK=true --env K8_API_URL="\`oc status |grep api|awk '{print $6}'\`" --env K8_API_KEY "\`oc whoami --show-token\`" move-cluster-to-folder --it --image quay.io/mtvqe/moveclustertosubfolder`; + cy.exec(cmd).its('stdout').should('contain', 'Operation Completed Successfully'); + } + + recoverMoveCluster(providerData: VmwareProviderData): void { + const { hostname } = providerData; + const cmd = `oc run --env TEARDOWN=true --env CLUSTER_NAME --env DATACENTER_NAME --env SERVER=${hostname} --env USER=xxx --env PASSWORD=xxx --env IGNOR_CERT_CHECK=true`; + cy.exec(cmd).its('stdout').should('contain', 'Operation Completed Successfully'); + } } diff --git a/pkg/qe-tests/cypress/integration/tests/Rhv/config_separate_mapping_rhv.ts b/pkg/qe-tests/cypress/integration/tests/Rhv/config_separate_mapping_rhv.ts index 8813c491..ab6a6773 100644 --- a/pkg/qe-tests/cypress/integration/tests/Rhv/config_separate_mapping_rhv.ts +++ b/pkg/qe-tests/cypress/integration/tests/Rhv/config_separate_mapping_rhv.ts @@ -35,6 +35,7 @@ export const providerData: RhvProviderData = { password: v2v_rhv_password, cert: v2v_rhv_cert, }; + // edit rhv provider data export const incorrectProviderData: RhvProviderData = { type: providerType.rhv, @@ -44,6 +45,7 @@ export const incorrectProviderData: RhvProviderData = { password: 'mtv@123!', cert: v2v_rhv_cert, }; + export const networkMappingPeer: MappingPeer[] = [ { sProvider: 'ovirtmgmt', @@ -109,7 +111,7 @@ export const editStorageMapping: MappingData = { }; export const rhel8Cold: PlanData = { - name: 'testplan-rhv-rhel8-separate-mapping-cold', + name: `testplan-${providerData.name}separate-mapping-cold`, sProvider: providerData.name, tProvider: 'host', namespace: targetNamespace, diff --git a/pkg/qe-tests/cypress/integration/tests/Rhv/editPlanTest.ts b/pkg/qe-tests/cypress/integration/tests/Rhv/editPlanTest.ts index e3cb762a..004e9abc 100644 --- a/pkg/qe-tests/cypress/integration/tests/Rhv/editPlanTest.ts +++ b/pkg/qe-tests/cypress/integration/tests/Rhv/editPlanTest.ts @@ -12,6 +12,7 @@ describe('Creating plan', () => { it('Editing an existing plan', () => { plan.create(testrhel8Cold.planData); plan.edit(testrhel8Cold.planData, duplicateTestData.planData); + plan.execute(duplicateTestData.planData); }); it('Deleting plan', () => { diff --git a/pkg/qe-tests/cypress/integration/tests/Rhv/end_to_end_Rhv_cold_test.ts b/pkg/qe-tests/cypress/integration/tests/Rhv/end_to_end_Rhv_cold_test.ts index bc184c36..d602dfe0 100644 --- a/pkg/qe-tests/cypress/integration/tests/Rhv/end_to_end_Rhv_cold_test.ts +++ b/pkg/qe-tests/cypress/integration/tests/Rhv/end_to_end_Rhv_cold_test.ts @@ -1,5 +1,5 @@ import { testrhel8Cold } from './config_separate_mapping_rhv'; -import { login } from '../../../utils/utils'; +import { cleanVms, login } from '../../../utils/utils'; import { providerRhv } from '../../models/providerRhv'; import { RhvProviderData } from '../../types/types'; import { MappingNetwork } from '../../models/mappingNetwork'; @@ -33,4 +33,13 @@ describe('Creating provider and deleting', () => { it('Running plan created in a previous tests', () => { plan.execute(testrhel8Cold.planData); }); + + after('Deleting plan, mappings and provider created in a previous tests', () => { + // login(currentTest.loginData); + plan.delete(testrhel8Cold.planData); + networkMapping.delete(testrhel8Cold.planData.networkMappingData); + storageMapping.delete(testrhel8Cold.planData.storageMappingData); + provider.delete(testrhel8Cold.planData.providerData); + cleanVms(testrhel8Cold.planData.vmList, testrhel8Cold.planData.namespace); + }); }); diff --git a/pkg/qe-tests/cypress/integration/tests/tier0/tier0_config_rhv.ts b/pkg/qe-tests/cypress/integration/tests/tier0/tier0_config_rhv.ts new file mode 100644 index 00000000..cbfc77b6 --- /dev/null +++ b/pkg/qe-tests/cypress/integration/tests/tier0/tier0_config_rhv.ts @@ -0,0 +1,204 @@ +import { + HookData, + LoginData, + MappingData, + MappingPeer, + PlanData, + RhvProviderData, + TestData, + // HookData, +} from '../../types/types'; +import { providerType, storageType } from '../../types/constants'; + +//Defining URL and credentials for target cluster +const url = Cypress.env('url'); +const user_login = 'kubeadmin'; +const user_password = Cypress.env('pass'); + +/** + * Starting RHV section + **/ +//Getting required env variables for RHV +const v2v_rhv_providername = Cypress.env('v2v_rhv_providername'); +const v2v_rhv_username = Cypress.env('v2v_rhv_username'); +const v2v_rhv_password = Cypress.env('v2v_rhv_password'); +const v2v_rhv_hostname = Cypress.env('v2v_rhv_hostname'); +const v2v_rhv_clustername = Cypress.env('v2v_rhv_clustername'); +const v2v_rhv_cert = Cypress.env('v2v_rhv_cert'); +const vmListArray = Cypress.env('vm_list'); +const preAnsiblePlaybook = Cypress.env('preAnsiblePlaybook'); +const postAnsiblePlaybook = Cypress.env('postAnsiblePlaybook'); + +// Defining data required for login +export const loginData: LoginData = { + username: user_login, + password: user_password, + url: url, +}; + +//Defining RHV provider +export const rhvProvider: RhvProviderData = { + type: providerType.rhv, + name: v2v_rhv_providername, + hostname: v2v_rhv_hostname, + username: v2v_rhv_username, + password: v2v_rhv_password, + cert: v2v_rhv_cert, +}; + +//Defining RHV network mapping peers for 2 networks +export const rhvNetworkMappingPeer_2x_network: MappingPeer[] = [ + { + sProvider: 'ovirtmgmt', + dProvider: 'Pod network', + }, + { + sProvider: 'vm', + dProvider: 'default / mybridge', + }, +]; + +//Defining RHV storage mapping peer for NFS +export const rhvStorageMappingPeer_nfs: MappingPeer[] = [ + { + sProvider: 'v2v-fc', + dProvider: storageType.nfs, + }, +]; + +//Defining RHV storage mapping peer for ceph-rbd +export const rhvStorageMappingPeer_ceph: MappingPeer[] = [ + { + sProvider: 'v2v-fc', + dProvider: storageType.cephRbd, + }, +]; + +//Defining RHV network mapping using 2 peers +export const rhvNetworkMapping_2x_network: MappingData = { + name: `network-${rhvProvider.name}-mapping`, + sProviderName: rhvProvider.name, + tProviderName: 'host', + mappingPeer: rhvNetworkMappingPeer_2x_network, +}; + +//Defining RHV storage mapping for ceph-rbd file system +export const rhvStorageMapping_ceph: MappingData = { + name: `storage-ceph-${rhvProvider.name}-mapping`, + sProviderName: rhvProvider.name, + tProviderName: 'host', + mappingPeer: rhvStorageMappingPeer_ceph, +}; + +//Defining RHV storage mapping for NFS file system +export const rhvStorageMapping_nfs: MappingData = { + name: `storage-nfs-${rhvProvider.name}-mapping`, + sProviderName: rhvProvider.name, + tProviderName: 'host', + mappingPeer: rhvStorageMappingPeer_nfs, +}; + +export const preHookData: HookData = { + ansiblePlaybook: preAnsiblePlaybook, +}; + +export const postHookData: HookData = { + ansiblePlaybook: postAnsiblePlaybook, +}; + +//Defining RHV cold migration plan for ceph-rbd file system +export const rhvTier0Plan_ceph_cold: PlanData = { + name: `rhv-tier0-ceph-${rhvProvider.name}`, + sProvider: rhvProvider.name, + tProvider: 'host', + namespace: 'tier0', + sourceClusterName: v2v_rhv_clustername, + vmList: vmListArray, + useExistingNetworkMapping: true, + useExistingStorageMapping: true, + providerData: rhvProvider, + networkMappingData: rhvNetworkMapping_2x_network, + storageMappingData: rhvStorageMapping_ceph, + warmMigration: false, + preHook: preHookData, + postHook: postHookData, +}; + +//Defining RHV cold migration plan for NFS file system +export const rhvTier0Plan_nfs_cold: PlanData = { + name: `rhv-tier0-nfs-${rhvProvider.name}`, + sProvider: rhvProvider.name, + tProvider: 'host', + namespace: 'tier0', + sourceClusterName: v2v_rhv_clustername, + vmList: vmListArray, + useExistingNetworkMapping: true, + useExistingStorageMapping: true, + providerData: rhvProvider, + networkMappingData: rhvNetworkMapping_2x_network, + storageMappingData: rhvStorageMapping_nfs, + warmMigration: false, +}; + +//Defining RHV warm migration plan for NFS file system +export const rhvTier0Plan_nfs_warm: PlanData = { + name: `rhv-tier0-nfs-${rhvProvider.name}`, + sProvider: rhvProvider.name, + tProvider: 'host', + namespace: 'tier0', + sourceClusterName: v2v_rhv_clustername, + vmList: vmListArray, + useExistingNetworkMapping: true, + useExistingStorageMapping: true, + providerData: rhvProvider, + networkMappingData: rhvNetworkMapping_2x_network, + storageMappingData: rhvStorageMapping_nfs, + warmMigration: true, +}; + +//Defining RHV warm migration plan for ceph-rbd file system +export const rhvTier0Plan_ceph_warm: PlanData = { + name: `rhv-tier0-ceph-${rhvProvider.name}`, + sProvider: rhvProvider.name, + tProvider: 'host', + namespace: 'tier0', + sourceClusterName: v2v_rhv_clustername, + vmList: vmListArray, + useExistingNetworkMapping: true, + useExistingStorageMapping: true, + providerData: rhvProvider, + networkMappingData: rhvNetworkMapping_2x_network, + storageMappingData: rhvStorageMapping_ceph, + warmMigration: true, +}; + +//Defining test for RHV cold migration with ceph-rbd file system +export const rhvTier0TestCephCold: TestData = { + loginData: loginData, + planData: rhvTier0Plan_ceph_cold, +}; + +//Defining test for RHV cold migration with nfs file system +export const rhvTier0TestNfsCold: TestData = { + loginData: loginData, + planData: rhvTier0Plan_nfs_cold, +}; + +//Defining test for RHV warm migration with ceph-rbd file system +export const rhvTiesr0TestCephWarm: TestData = { + loginData: loginData, + planData: rhvTier0Plan_ceph_warm, +}; + +//Defining test for RHV warm migration with nfs file system +export const rhvTier0TestNfsWarm: TestData = { + loginData: loginData, + planData: rhvTier0Plan_nfs_warm, +}; + +export const rhvTier0TestArray = [ + rhvTier0TestCephCold, + rhvTier0TestNfsCold, + rhvTiesr0TestCephWarm, + rhvTier0TestNfsWarm, +]; diff --git a/pkg/qe-tests/cypress/integration/tests/tier0/config_tier0.ts b/pkg/qe-tests/cypress/integration/tests/tier0/tier0_config_vmware.ts similarity index 56% rename from pkg/qe-tests/cypress/integration/tests/tier0/config_tier0.ts rename to pkg/qe-tests/cypress/integration/tests/tier0/tier0_config_vmware.ts index b1a3613d..4ad98ec7 100644 --- a/pkg/qe-tests/cypress/integration/tests/tier0/config_tier0.ts +++ b/pkg/qe-tests/cypress/integration/tests/tier0/tier0_config_vmware.ts @@ -210,171 +210,3 @@ export const vmwareTier0TestArray = [ vmwareTier0TestCephWarm, vmwareTier0TestNfsWarm, ]; - -/** - * Starting RHV section - **/ -//Getting required env variables for RHV -const v2v_rhv_providername = Cypress.env('v2v_rhv_providername'); -const v2v_rhv_username = Cypress.env('v2v_rhv_username'); -const v2v_rhv_password = Cypress.env('v2v_rhv_password'); -const v2v_rhv_hostname = Cypress.env('v2v_rhv_hostname'); -const v2v_rhv_clustername = Cypress.env('v2v_rhv_clustername'); -const v2v_rhv_cert = Cypress.env('v2v_rhv_cert'); - -//Defining RHV provider -export const rhvProvider: RhvProviderData = { - type: providerType.rhv, - name: v2v_rhv_providername, - hostname: v2v_rhv_hostname, - username: v2v_rhv_username, - password: v2v_rhv_password, - cert: v2v_rhv_cert, -}; - -//Defining RHV network mapping peers for 2 networks -export const rhvNetworkMappingPeer_2x_network: MappingPeer[] = [ - { - sProvider: 'ovirtmgmt', - dProvider: 'Pod network', - }, - { - sProvider: 'vm', - dProvider: 'default / mybridge', - }, -]; - -//Defining RHV storage mapping peer for NFS -export const rhvStorageMappingPeer_nfs: MappingPeer[] = [ - { - sProvider: 'v2v-fc', - dProvider: storageType.nfs, - }, -]; - -//Defining RHV storage mapping peer for ceph-rbd -export const rhvStorageMappingPeer_ceph: MappingPeer[] = [ - { - sProvider: 'v2v-fc', - dProvider: storageType.cephRbd, - }, -]; - -//Defining RHV network mapping using 2 peers -export const rhvNetworkMapping_2x_network: MappingData = { - name: 'network-qe-rhv-mapping', - sProviderName: rhvProvider.name, - tProviderName: 'host', - mappingPeer: rhvNetworkMappingPeer_2x_network, -}; - -//Defining RHV storage mapping for NFS file system -export const rhvStorageMapping_nfs: MappingData = { - name: 'storage-qe-rhv-mapping', - sProviderName: rhvProvider.name, - tProviderName: 'host', - mappingPeer: rhvStorageMappingPeer_nfs, -}; - -//Defining RHV storage mapping for ceph-rbd file system -export const rhvStorageMapping_ceph: MappingData = { - name: 'storage-qe-rhv-mapping', - sProviderName: rhvProvider.name, - tProviderName: 'host', - mappingPeer: rhvStorageMappingPeer_ceph, -}; - -//Defining RHV cold migration plan for NFS file system -export const rhvTier0Plan_nfs_cold: PlanData = { - name: `rhv-tier0-nfs-${rhvProvider.name}`, - sProvider: rhvProvider.name, - tProvider: 'host', - namespace: 'tier0', - sourceClusterName: v2v_rhv_clustername, - vmList: vmListArray, - useExistingNetworkMapping: true, - useExistingStorageMapping: true, - providerData: rhvProvider, - networkMappingData: rhvNetworkMapping_2x_network, - storageMappingData: rhvStorageMapping_nfs, - warmMigration: false, -}; - -//Defining RHV cold migration plan for ceph-rbd file system -export const rhvTier0Plan_ceph_cold: PlanData = { - name: `rhv-tier0-ceph-${rhvProvider.name}`, - sProvider: rhvProvider.name, - tProvider: 'host', - namespace: 'tier0', - sourceClusterName: v2v_rhv_clustername, - vmList: vmListArray, - useExistingNetworkMapping: true, - useExistingStorageMapping: true, - providerData: rhvProvider, - networkMappingData: rhvNetworkMapping_2x_network, - storageMappingData: rhvStorageMapping_ceph, - warmMigration: false, -}; - -//Defining RHV warm migration plan for NFS file system -export const rhvTier0Plan_nfs_warm: PlanData = { - name: `rhv-tier0-nfs-${rhvProvider.name}`, - sProvider: rhvProvider.name, - tProvider: 'host', - namespace: 'tier0', - sourceClusterName: v2v_rhv_clustername, - vmList: vmListArray, - useExistingNetworkMapping: true, - useExistingStorageMapping: true, - providerData: rhvProvider, - networkMappingData: rhvNetworkMapping_2x_network, - storageMappingData: rhvStorageMapping_nfs, - warmMigration: true, -}; - -//Defining RHV warm migration plan for ceph-rbd file system -export const rhvTier0Plan_ceph_warm: PlanData = { - name: `rhv-tier0-ceph-${rhvProvider.name}`, - sProvider: rhvProvider.name, - tProvider: 'host', - namespace: 'tier0', - sourceClusterName: v2v_rhv_clustername, - vmList: vmListArray, - useExistingNetworkMapping: true, - useExistingStorageMapping: true, - providerData: rhvProvider, - networkMappingData: rhvNetworkMapping_2x_network, - storageMappingData: rhvStorageMapping_ceph, - warmMigration: true, -}; - -//Defining test for RHV cold igration with nfs file system -export const rhvTier0TestNfsCold: TestData = { - loginData: loginData, - planData: rhvTier0Plan_nfs_cold, -}; - -//Defining test for RHV cold migration with ceph-rbd file system -export const rhvTiesr0TestCephCold: TestData = { - loginData: loginData, - planData: rhvTier0Plan_ceph_cold, -}; - -//Defining test for RHV wamm igration with nfs file system -export const rhvTier0TestNfsWarm: TestData = { - loginData: loginData, - planData: rhvTier0Plan_nfs_warm, -}; - -//Defining test for RHV warm migration with ceph-rbd file system -export const rhvTiesr0TestCephWarm: TestData = { - loginData: loginData, - planData: rhvTier0Plan_ceph_warm, -}; - -export const rhvTier0TestArray = [ - rhvTier0TestNfsCold, - rhvTiesr0TestCephCold, - rhvTier0TestNfsWarm, - rhvTiesr0TestCephWarm, -]; diff --git a/pkg/qe-tests/cypress/integration/tests/tier0/tier0_tests_rhv.ts b/pkg/qe-tests/cypress/integration/tests/tier0/tier0_tests_rhv.ts index 011450a5..754791a3 100644 --- a/pkg/qe-tests/cypress/integration/tests/tier0/tier0_tests_rhv.ts +++ b/pkg/qe-tests/cypress/integration/tests/tier0/tier0_tests_rhv.ts @@ -1,20 +1,20 @@ -import { rhvTier0TestArray } from './config_tier0'; -import { login } from '../../../utils/utils'; +import { rhvTier0TestArray } from './tier0_config_rhv'; +import { cleanVms, login } from '../../../utils/utils'; import { providerRhv } from '../../models/providerRhv'; import { MappingNetwork } from '../../models/mappingNetwork'; import { MappingStorage } from '../../models/mappingStorage'; import { Plan } from '../../models/plan'; -describe( - 'Tier0 tests, creating RHV provider, network and storage(both ceph and nfs) mappings, ' + - 'plan (both cold and warm), running plan and deleting at the end', - () => { - const provider = new providerRhv(); - const networkMapping = new MappingNetwork(); - const storageMapping = new MappingStorage(); - const plan = new Plan(); +rhvTier0TestArray.forEach((currentTest) => { + describe( + 'Tier0 tests, creating RHV provider, network and storage(both ceph and nfs) mappings, ' + + 'plan (both cold and warm), running plan and deleting at the end', + () => { + const provider = new providerRhv(); + const networkMapping = new MappingNetwork(); + const storageMapping = new MappingStorage(); + const plan = new Plan(); - rhvTier0TestArray.forEach((currentTest) => { beforeEach(() => { login(currentTest.loginData); }); @@ -37,17 +37,12 @@ describe( }); after('Deleting plan, mappings and provider created in a previous tests', () => { - login(currentTest.loginData); plan.delete(currentTest.planData); networkMapping.delete(currentTest.planData.networkMappingData); storageMapping.delete(currentTest.planData.storageMappingData); provider.delete(currentTest.planData.providerData); - const namespace = currentTest.planData.namespace; - const vm_list = currentTest.planData.vmList; - vm_list.forEach((vm) => { - cy.exec(`oc delete vm ${vm} -n${namespace}`); - }); + cleanVms(currentTest.planData.vmList, currentTest.planData.namespace); }); - }); - } -); + } + ); +}); diff --git a/pkg/qe-tests/cypress/integration/tests/tier0/tier0_tests_vmware.ts b/pkg/qe-tests/cypress/integration/tests/tier0/tier0_tests_vmware.ts index e32e2a1c..6b186e5f 100644 --- a/pkg/qe-tests/cypress/integration/tests/tier0/tier0_tests_vmware.ts +++ b/pkg/qe-tests/cypress/integration/tests/tier0/tier0_tests_vmware.ts @@ -1,5 +1,5 @@ import { ProviderVmware } from '../../models/providerVmware'; -import { vmwareTier0TestArray } from './config_tier0'; +import { vmwareTier0TestArray } from './tier0_config_vmware'; import { login } from '../../../utils/utils'; import { MappingNetwork } from '../../models/mappingNetwork'; import { MappingStorage } from '../../models/mappingStorage'; @@ -21,28 +21,23 @@ vmwareTier0TestArray.forEach((currentTest) => { }); it('Login to MTV and create provider', () => { - // login(currentTest.loginData); provider.create(currentTest.planData.providerData); }); it('Create new network and storage mapping', () => { - // login(currentTest.loginData); networkMapping.create(currentTest.planData.networkMappingData); storageMapping.create(currentTest.planData.storageMappingData); }); it('Creating plan with existing network and storage mapping', () => { - // login(currentTest.loginData); plan.create(currentTest.planData); }); it('Running plan created in a previous tests', () => { - // login(currentTest.loginData); plan.execute(currentTest.planData); }); after('Deleting VMs, plan, mappings and provider created in a previous tests', () => { - // login(currentTest.loginData); plan.delete(currentTest.planData); networkMapping.delete(currentTest.planData.networkMappingData); storageMapping.delete(currentTest.planData.storageMappingData); @@ -53,7 +48,6 @@ vmwareTier0TestArray.forEach((currentTest) => { cy.exec(`oc delete vm ${vm} -n${namespace}`); }); }); - // }); } ); }); diff --git a/pkg/qe-tests/cypress/utils/utils.ts b/pkg/qe-tests/cypress/utils/utils.ts index c1c6c7b0..2d2a3dca 100644 --- a/pkg/qe-tests/cypress/utils/utils.ts +++ b/pkg/qe-tests/cypress/utils/utils.ts @@ -21,7 +21,7 @@ export function inputText(fieldId: string, text: string): void { // Clicking on button with selection by text (when no other selector can be used) export function clickByText(fieldId: string, buttonText: string): void { - cy.contains(fieldId, buttonText).click(); + cy.contains(fieldId, buttonText, { timeout: 30 * SEC }).click(); } // Clicking on object selected by fieldId @@ -103,3 +103,9 @@ export function clickOnCancel(): void { clickByText(button, 'Cancel'); clickByText(button, 'Yes, cancel'); } + +export function cleanVms(vm_list: string[], namespace: string): void { + vm_list.forEach((vm) => { + cy.exec(`oc delete vm ${vm} -n${namespace}`); + }); +}