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

Automate CNV installation and uninstallation #4430

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions frontend/integration-tests/views/crud.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { $, $$, browser, by, ExpectedConditions as until, element } from 'protra

import * as yamlView from './yaml.view';
import { appHost, testName, waitForNone } from '../protractor.conf';
import { waitForCount } from '@console/shared/src/test-utils/utils';

export const createYAMLButton = $('#yaml-create');
export const createItemButton = $('#item-create');
Expand Down Expand Up @@ -81,6 +82,7 @@ export const clickKebabAction = (resourceName: string, actionLabel: string) => {
.$('[data-test-id="kebab-button"]')
.click()
.then(() => browser.wait(until.elementToBeClickable(actionForLabel(actionLabel))))
.then(() => browser.wait(waitForCount($$('.pf-m-disabled'), 0)))
.then(() => actionForLabel(actionLabel).click());
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { click } from '@console/shared/src/test-utils/utils';

import { isLoaded } from '@console/internal-integration-tests/views/crud.view';
import * as sidenavView from '@console/internal-integration-tests/views/sidenav.view';
guy9050 marked this conversation as resolved.
Show resolved Hide resolved
import * as cnvView from '../views/containerNativeVirtualization.view';
import { waitFor } from '../tests/utils/utils';

describe('Kubevirt Installation', () => {
beforeAll(async () => {
await sidenavView.clickNavLink(['Operators', 'OperatorHub']);
await isLoaded();
await click(cnvView.namespaceButton);
await click(cnvView.openshiftNamespaceButton);
await isLoaded();
});

it('Install Kubevirt', async () => {
await click(cnvView.elmCnvOperator);
await click(cnvView.elmInstall);
await waitFor(cnvView.kubevirtOperatorStatus, 'Succeeded', 5);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { click } from '@console/shared/src/test-utils/utils';
import { browser } from 'protractor';
import { clickNavLink } from '@console/internal-integration-tests/views/sidenav.view';
import * as cnvView from '../views/containerNativeVirtualization.view';
import { confirmAction } from '../views/vm.actions.view';
import { waitFor } from '../tests/utils/utils';
import { execSync } from 'child_process';
import * as crudView from '@console/internal-integration-tests/views/crud.view';
guy9050 marked this conversation as resolved.
Show resolved Hide resolved

describe('Uninstall Kubevirt', () => {
beforeAll(async () => {
await clickNavLink(['Operators', 'Installed Operators']);
await crudView.isLoaded();
await click(cnvView.namespaceButton);
await click(cnvView.openshiftNamespaceButton);
});

it('Deleting the KubeVirt HyperConverged Operator Custom Resource', async () => {
await crudView.isLoaded();
await cnvView.elmKebab.click();
await crudView.isLoaded();
await cnvView.elmUninstall.click();
await waitFor(cnvView.kubevirtOperatorStatus, 'Succeeded', 5);
await confirmAction();
});

it('Deleting the Container-native virtualization catalog subscription', async () => {
await clickNavLink(['Operators', 'OperatorHub']);
await crudView.isLoaded();
await cnvView.elmCNV.click();
await browser.sleep(20000);
});

it('Delete the openshift-cnv project', async () => {
await clickNavLink(['Administration', 'Namespaces']);
await cnvView.nameFilter.sendKeys('openshift-cnv');
await crudView.isLoaded();
await crudView.clickKebabAction('openshift-cnv', 'Delete Namespace');
await crudView.isLoaded();
await cnvView.verifyDelete.sendKeys('openshift-cnv');
await crudView.isLoaded();
await confirmAction();
});

it('Delete kubevirt.io apiservices', async () => {
execSync('kubectl delete apiservices v1alpha3.subresources.kubevirt.io -n openshift-cnv');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const rhelTinyCommonTemplateName = execSync(
export const NOT_AVAILABLE = 'Not available';

// TIMEOUTS
const SEC = 1000;
export const SEC = 1000;
export const CLONE_VM_TIMEOUT_SECS = 720 * SEC;
export const CLONED_VM_BOOTUP_TIMEOUT_SECS = 300 * SEC;
export const PAGE_LOAD_TIMEOUT_SECS = 15 * SEC;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
isLoaded as yamlPageIsLoaded,
saveButton,
} from '@console/internal-integration-tests/views/yaml.view';
import { STORAGE_CLASS, PAGE_LOAD_TIMEOUT_SECS } from './consts';
import { STORAGE_CLASS, PAGE_LOAD_TIMEOUT_SECS, SEC } from './consts';
import { NodePortService } from './types';

export async function fillInput(elem: any, value: string) {
Expand Down Expand Up @@ -149,3 +149,18 @@ export function resolveStorageDataAttribute(configMap: any, attribute: string):
}
return _.get(configMap, ['data', attribute]);
}

export const waitFor = async (element, text, count = 1) => {
let rowNumber = 0;
while (rowNumber !== count) {
await browser.wait(until.visibilityOf(element));
const elemText = await element.getText();
if (elemText.includes(text)) {
rowNumber += 1;
} else {
rowNumber = 0;
}
/* eslint-disable no-await-in-loop */
await browser.sleep(5 * SEC);
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { $, by, element } from 'protractor';

export const elmCnvOperator = element(
by.cssContainingText('.catalog-tile-pf-title', 'Container-native virtualization Operator'),
);

export const elmCNV = element(
by.cssContainingText('.catalog-tile-pf-title', 'Container-native virtualization'),
);
export const elmInstall = element(by.linkText('Install'));
export const namespaceButton = $('.co-namespace-selector button');
export const messageLbl = $('.cos-status-box');
export const nameFilter = $('.pf-c-form-control.co-text-filter');
export const verifyDelete = element(by.css('.co-delete-modal')).element(
by.css('.pf-c-form-control'),
);
export const openshiftNamespaceButton = $('#openshift-cnv-link');
export const kubevirtOperatorStatus = $('.co-clusterserviceversion-row__status');
export const elmKebab = element(by.xpath("//button[@data-test-id='kebab-button']"));
export const elmUninstall = element(by.xpath("//button[@data-test-action='Uninstall Operator']"));
export const elmActionMenu = element(by.xpath("//button[@data-test-id='actions-menu-button']"));
3 changes: 3 additions & 0 deletions frontend/packages/kubevirt-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
"consolePlugin": {
"entry": "src/plugin.tsx",
"integrationTestSuites": {
"kubevirt-installation": [
"integration-tests/installation/*.scenario.ts"
],
"kubevirt": [
"integration-tests/tests/*.scenario.ts"
],
Expand Down