Skip to content

Commit

Permalink
Merge pull request #9691 from yaacov/add-delete-resource-before-create
Browse files Browse the repository at this point in the history
Bug 1988812: Delete test project after creating it
  • Loading branch information
openshift-ci[bot] committed Aug 2, 2021
2 parents ece0da0 + c2d0b6c commit 4b0f141
Show file tree
Hide file tree
Showing 20 changed files with 169 additions and 30 deletions.
Expand Up @@ -2,9 +2,9 @@ import { ConfigMapKind } from '@console/internal/module/k8s';
import { projectDropdown } from '../../../integration-tests-cypress/views/common';
import { V1alpha1DataVolume } from '../../src/types/api';
import {
EXPECT_LOGIN_SCRIPT_PATH,
KUBEVIRT_PROJECT_NAME,
KUBEVIRT_STORAGE_CLASS_DEFAULTS,
EXPECT_LOGIN_SCRIPT_PATH,
} from '../const';
import nadFixture from '../fixtures/nad';
import { VirtualMachineData } from '../types/vm';
Expand Down Expand Up @@ -35,6 +35,17 @@ declare global {

Cypress.Commands.add('deleteResource', (resource, ignoreNotFound = true) => {
const kind = resource.kind === 'NetworkAttachmentDefinition' ? 'net-attach-def' : resource.kind;

// If cluster resource, ommit namespace
if (!resource.metadata.namespace) {
cy.exec(
`kubectl delete --ignore-not-found=${ignoreNotFound} --cascade ${kind} ${resource.metadata.name} --wait=true --timeout=120s`,
{ timeout: 120000 },
);

return;
}

cy.exec(
`kubectl delete --ignore-not-found=${ignoreNotFound} -n ${resource.metadata.namespace} --cascade ${kind} ${resource.metadata.name} --wait=true --timeout=120s`,
{ timeout: 120000 },
Expand Down
Expand Up @@ -71,6 +71,12 @@ describe('Test VM Clone', () => {
namespace: vmData.namespace,
},
});
cy.deleteResource({
kind: 'Namespace',
metadata: {
name: testName,
},
});
});

it('ID(CNV-1730) Displays warning in clone wizard when cloned VM is running', () => {
Expand Down
Expand Up @@ -35,6 +35,12 @@ describe('Test VM Migration', () => {
namespace: vmData.namespace,
},
});
cy.deleteResource({
kind: 'Namespace',
metadata: {
name: testName,
},
});
});

it('ID(CNV-6764) Migrate VM action button is not displayed when VM is off', () => {
Expand Down
@@ -1,11 +1,11 @@
import {
DEFAULTS_VALUES,
OS_IMAGES_NS,
TEMPLATE_BASE_IMAGE,
TEMPLATE_NAME,
VM_ACTION,
VM_ACTION_TIMEOUT,
VM_STATUS,
OS_IMAGES_NS,
TEMPLATE_NAME,
TEMPLATE_BASE_IMAGE,
} from '../../const/index';
import { testName } from '../../support';
import { VirtualMachineData } from '../../types/vm';
Expand All @@ -17,9 +17,9 @@ import {
} from '../../view/actions';
import { alertTitle, confirmCloneButton } from '../../view/clone';
import {
switchPerspective,
Perspective,
addHeader,
Perspective,
switchPerspective,
topologyHeader,
} from '../../view/dev-perspective';
import { detailsTab } from '../../view/selector';
Expand Down Expand Up @@ -62,6 +62,12 @@ describe('test dev console', () => {
namespace: testName,
},
});
cy.deleteResource({
kind: 'Namespace',
metadata: {
name: testName,
},
});
switchPerspective(Perspective.Administrator);
});

Expand Down
@@ -1,4 +1,4 @@
import { TEMPLATE_BASE_IMAGE, TEMPLATE_NAME, OS_IMAGES_NS } from '../../const/index';
import { OS_IMAGES_NS, TEMPLATE_BASE_IMAGE, TEMPLATE_NAME } from '../../const/index';
import { ProvisionSource } from '../../enums/provisionSource';
import { testName } from '../../support';
import { VirtualMachineData } from '../../types/vm';
Expand Down Expand Up @@ -40,6 +40,12 @@ describe('kubevirt PVC upload', () => {
namespace: vmData.namespace,
},
});
cy.deleteResource({
kind: 'Namespace',
metadata: {
name: testName,
},
});
cy.exec('rm -fr /tmp/cirros.*');
});

Expand Down
Expand Up @@ -21,6 +21,15 @@ describe('Validate NAD for PXE provision source', () => {
virtualization.vms.visit();
});

after(() => {
cy.deleteResource({
kind: 'Namespace',
metadata: {
name: testName,
},
});
});

it('ID(CNV-5045) Verify PXE provision source must have NAD available', () => {
wizard.vm.open();
wizard.vm.selectTemplate(vmData);
Expand Down
Expand Up @@ -32,6 +32,12 @@ describe('Test vm creation', () => {
namespace: vmData.namespace,
},
});
cy.deleteResource({
kind: 'Namespace',
metadata: {
name: testName,
},
});
});

it('ID(CNV-6732) [bz1942839] validate virtio-win-image of windows vm', () => {
Expand Down
Expand Up @@ -16,6 +16,19 @@ const vmData: VirtualMachineData = {
startOnCreation: false,
};

const vmFixture = {
kind: 'VirtualMachine',
metadata: {
name: vmData.name,
namespace: vmData.namespace,
},
};

const vmiData: VirtualMachineData = {
name: `smoke-test-vmi-actions-${testName}`,
namespace: testName,
};

describe('Test VM/VMI actions', () => {
before(() => {
cy.Login();
Expand All @@ -24,11 +37,12 @@ describe('Test VM/VMI actions', () => {
});

after(() => {
cy.deleteResource(vmFixture);
cy.deleteResource(vmiFixture);
cy.deleteResource({
kind: 'VirtualMachine',
kind: 'Namespace',
metadata: {
name: vmData.name,
namespace: vmData.namespace,
name: testName,
},
});
});
Expand Down Expand Up @@ -103,31 +117,28 @@ describe('Test VM/VMI actions', () => {
});

describe('Test vmi action', () => {
const vmiData: VirtualMachineData = {
name: 'vmi-ephemeral',
namespace: testName,
};

beforeEach(() => {
vmiFixture.metadata.name = vmiData.name;
vmiFixture.metadata.namespace = testName;
cy.deleteResource(vmiFixture);
cy.applyResource(vmiFixture);
virtualization.vms.visit();
waitForStatus(VM_STATUS.Running, vmiData);
});

it('ID(CNV-3693) Test VMI list view action', () => {
vm.delete();
cy.byLegacyTestID('vmi-ephemeral').should('not.exist');
cy.byLegacyTestID(vmiData.name).should('not.exist');
});

it('ID(CNV-3699) Test VMI detail view action', () => {
cy.byLegacyTestID('vmi-ephemeral')
cy.byLegacyTestID(vmiData.name)
.should('exist')
.click();
cy.byLegacyTestID('horizontal-link-Details').click();
cy.get('.loading-box__loaded').should('be.visible');
vm.delete();
cy.byLegacyTestID('vmi-ephemeral').should('not.exist');
cy.byLegacyTestID(vmiData.name).should('not.exist');
});
});
});
Expand Up @@ -10,6 +10,15 @@ describe('smoke tests', () => {
cy.createProject(testName);
});

after(() => {
cy.deleteResource({
kind: 'Namespace',
metadata: {
name: testName,
},
});
});

describe('visit template list page', () => {
it('template list page is loaded', () => {
virtualization.templates.visit();
Expand Down
Expand Up @@ -54,6 +54,12 @@ describe('Test vm creation', () => {
},
});
});
cy.deleteResource({
kind: 'Namespace',
metadata: {
name: testName,
},
});
});

[fedoraData, rhelData, winData].forEach((data) => {
Expand Down
Expand Up @@ -3,7 +3,7 @@ import { ProvisionSource } from '../../enums/provisionSource';
import { testName } from '../../support';
import { VirtualMachineData } from '../../types/vm';
import { virtualization } from '../../view/virtualization';
import { waitForStatus, vm } from '../../view/vm';
import { vm, waitForStatus } from '../../view/vm';

const vmData: VirtualMachineData = {
name: `smoke-test-vm-${testName}`,
Expand Down Expand Up @@ -31,6 +31,12 @@ describe('smoke tests', () => {
namespace: vmData.namespace,
},
});
cy.deleteResource({
kind: 'Namespace',
metadata: {
name: testName,
},
});
});

describe('visit vm list page', () => {
Expand Down
Expand Up @@ -21,6 +21,12 @@ describe('smoke tests', () => {
namespace: testName,
},
});
cy.deleteResource({
kind: 'Namespace',
metadata: {
name: testName,
},
});
});

describe('visit vmi list page', () => {
Expand Down
Expand Up @@ -19,10 +19,14 @@ describe('Connect to a VM using SSH testing', () => {
cy.createProject(testName);
});

sshTestingFunctions.forEach((fn) => fn({ vmName: `${testName}-vm` }));

after(() => {
cy.deleteProject(testName);
cy.visit('');
cy.deleteResource({
kind: 'Namespace',
metadata: {
name: testName,
},
});
});

sshTestingFunctions.forEach((fn) => fn({ vmName: `${testName}-vm` }));
});
Expand Up @@ -10,6 +10,15 @@ describe('ID (CNV-6821) Sysprep testing', () => {
cy.createProject(testName);
});

after(() => {
cy.deleteResource({
kind: 'Namespace',
metadata: {
name: testName,
},
});
});

it('should navigate to advanced wizard - advanced tab', () => {
cy.get('[data-test=nav]')
.filter('[href$=virtualization]')
Expand Down Expand Up @@ -70,9 +79,4 @@ describe('ID (CNV-6821) Sysprep testing', () => {
.click();
cy.byLegacyTestID(`sysprep-config-${vmName}`).should('be.visible');
});

after(() => {
cy.deleteProject(testName);
cy.visit('');
});
});
Expand Up @@ -48,7 +48,12 @@ describe('test custom template creation support', () => {
});

after(() => {
cy.deleteTestProject(testName);
cy.deleteResource({
kind: 'Namespace',
metadata: {
name: testName,
},
});
});

it('ID(CNV-5729) create custom template from common template with no boot source', () => {
Expand Down
Expand Up @@ -37,6 +37,12 @@ describe('test vm template source image', () => {
namespace: OS_IMAGES_NS,
},
});
cy.deleteResource({
kind: 'Namespace',
metadata: {
name: testName,
},
});
});

it('customize common template source', () => {
Expand Down
Expand Up @@ -19,6 +19,15 @@ describe('test vm template source image', () => {
cy.createProject(testName);
});

after(() => {
cy.deleteResource({
kind: 'Namespace',
metadata: {
name: testName,
},
});
});

beforeEach(() => {
virtualization.templates.visit();
cy.deleteResource({
Expand Down
Expand Up @@ -11,6 +11,15 @@ describe('test VM template support', () => {
cy.createProject(testName);
});

after(() => {
cy.deleteResource({
kind: 'Namespace',
metadata: {
name: testName,
},
});
});

beforeEach(() => {
virtualization.templates.visit();
});
Expand Down

0 comments on commit 4b0f141

Please sign in to comment.