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

Testing infra for metalkubed #1886

Closed
wants to merge 1 commit into from
Closed

Conversation

ukalifon
Copy link
Contributor

@ukalifon ukalifon commented Jul 2, 2019

This is the basic Protractor (Selenium) infrastructure we use to test
the baremetal features in the web-ui fork. It is dependent on some
kubevirt code which is shared among the infrastructures, so those deps
are part of this PR as well.

The actual test is in tests/metalkube/dashboard.scenario.ts and it only
reads some of the counters in the dashboards page, and compares them to
what we get from the CLI.

The test might currently fail because not all functionality from the
web-ui has been merged into console yet (it's a long WIP). The test
should pass when the merge is done, as you can see when running the
test against a web-ui instance:

yarn install
yarn webdriver-update
export BRIDGE_BASE_ADDRESS='https://...redhat.com'
export BRIDGE_AUTH_USERNAME=kubeadmin
export BRIDGE_AUTH_PASSWORD=22Z....
oc login -s ..
.redhat.com:6443 -u kubeadmin -p 22ZW....
export KUBECONFIG=/home/ukalifon/.kube/config
yarn run test-suite --suite baremetalSmokeTests --params.openshift true

@openshift-ci-robot openshift-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 2, 2019
@openshift-ci-robot
Copy link
Contributor

Hi @ukalifon. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@spadgett spadgett added this to the v4.2 milestone Jul 2, 2019
@rhrazdil
Copy link

/ok-to-test

@openshift-ci-robot openshift-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 23, 2019
Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove uses of xpath and avoid complicated, fragile selectors. Add data-test-id attributes where needed to simplify the tests.

@ukalifon
Copy link
Contributor Author

/retest

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. component/core Related to console core functionality component/metal3 Related to metal3-plugin and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 8, 2019
@ukalifon ukalifon force-pushed the metal3-tests branch 2 times, most recently from 2a13aec to e7d846d Compare August 9, 2019 08:16
@ukalifon
Copy link
Contributor Author

ukalifon commented Aug 9, 2019

/test ci/prow/e2e-aws

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 9, 2019
import { execSync } from 'child_process';
import { logIn } from './utils/utils';

describe('Authentication', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unclear why we need a special login scenario for kubevirt. Can you elaborate?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spadgett We had to add special login because the login page was different in web-ui and openshift/console at certain point in the past, so login scenario from console didn't work.
Although this is not an issue now, I don't see why plugin related test suites should be running whole console login scenario.
I would prefer having some prerequisite that handles the login quickly rather than executing the whole console login scenario that is executed as a part of different suite anyway.

await browser.get(appHost);
if (process.env.BRIDGE_BASE_ADDRESS !== undefined) {
await logIn();
execSync(`oc login -u ${process.env.BRIDGE_AUTH_USERNAME} -p ${process.env.BRIDGE_AUTH_PASSWORD} --config=${process.env.KUBECONFIG}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config=${process.env.KUBECONFIG} should be unnecessary. oc will already read the env var.

export const WIZARD_TABLE_FIRST_ROW = 1;

// Tab names
export const TABS = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use Object.freeze on all of these to avoid accidentally mutating them in the tests

NICS: 'Network Interfaces',
};

// Network tab columns in VM Wizard
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be much better to include data-test-id in the columns so we don't need to hard-code each index. It makes the test more robust when things change.


// TIMEOUTS
const SEC = 1000;
export const CLONE_VM_TIMEOUT = 300 * SEC;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put SECONDS in each of these names to make it obvious what the unit is where it's used.

Suggested change
export const CLONE_VM_TIMEOUT = 300 * SEC;
export const CLONE_VM_TIMEOUT_SECONDS = 300 * SEC;

};

// eslint-disable-next-line eqeqeq
export const resolveTimeout = (timeout, defaultTimeout) => timeout != undefined ? timeout : defaultTimeout;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't protractor use the default timeout already if none is specified? I'm unclear why this is needed at all.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spadgett This was not intended to use protractor default value as default.
Use case: consider an action that usually takes certain amount of time (starting cirros VM for example), but sometimes we want to start Windows or CentOS VM, which takes more time. So start action has defined default timeout (different from the protractor default) for starting a VM and for special cases a different timeout can be passed to the method.

beforeAll(async() => {
await browser.get(`${appHost}/dashboards`);
await dashboardView.isLoaded();
browser.sleep(10000); // the counters on the page start updating late...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arbitrary sleeps are not good. we should wait until the data appears

const output = execSync('oc get nodes', { encoding: 'utf-8' });
const lines = output.split('\n');
lines.forEach(function(line) {
if (line.indexOf(' Ready ') > 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use -o json and check the JSON values

const lines = output.split('\n').slice(1); // slice(1) to ignore the 1st line of output
lines.forEach(function(line) {
if (line.trim().length > 1) {
if (line.indexOf(' OK ') > 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here. Please use -o json

* await dashboardView.sysEventTime(0).getText()
*/
export function sysEventTime(rowNumber) {
return element(by.xpath(`(//div[@class="co-sysevent__header"])[${rowNumber + 1}]/small`));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid xpath, here and below. add data-test-id if needed

@spadgett spadgett removed this from the v4.2 milestone Sep 9, 2019
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 17, 2019
import { appHost } from '../../protractor.conf';
import * as dashboardView from '../../views/metalkube/dashboards.view';

async function compareCounters(elem, expectedValue) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just compareCounter since it only takes one element.

await browser.get(`${appHost}/dashboards`);
await dashboardView.isLoaded();
// wait until the counters in the inventory card show up
while (!(dashboardView.inventoryNodesUpCounter.isPresent() || dashboardView.inventoryNodesDownCounter.isPresent()) ||

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The negations are quite hard to read. Are we waiting for all the counters to be present?
I think ExpectedConditions is the way to go

await browser.wait(
  until.and(
    dashboardView.inventoryNodesUpCounter.isPresent(),
    dashboardView.inventoryNodesDownCounter.isPresent(),
    dashboardView.inventoryHostsUpCounter.isPresent(),
    dashboardView.inventoryHostsDownCounter.isPresent(),
  ), 15000 // the timeout that we're willing to wait for all these elements
);


@openshift-ci-robot openshift-ci-robot added component/monitoring Related to monitoring component/noobaa Related to noobaa-storage-plugin component/olm Related to OLM component/sdk Related to console-plugin-sdk component/shared Related to console-shared labels Oct 23, 2019
@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 23, 2019
Copy link

@jtomasek jtomasek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any dashboard specific tests suite already? It seems that the scenario which you're introducing could be split into a dashboard suite and metal3-plugin suite. metal3-plugin suite should hold tests which are specific to the baremetal environment.

@@ -113,6 +113,7 @@ export const config: Config = {
return new Promise((resolve) => htmlReporter.afterLaunch(resolve.bind(this, exitCode)));
},
suites: {
baremetalSmokeTests: ['tests/metalkube/dashboard.scenario.ts'],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To follow the convention which kubevirt-plugin set it would be good to call this metal3-plugin and colocate the metal3-plugin tests into the plugin - move the test modules into frontend/packages/metal3-plugin/integration-tests and reference them here as

metal3-plugin: ['../packages/metal3-plugin/integration-tests/tests/dashboard.scenario.ts'],

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 25, 2019
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 25, 2019
@@ -102,7 +111,14 @@ const InventoryItem: React.FC<InventoryItemProps> = React.memo(
</AccordionItem>
</Accordion>
) : (
<<<<<<< HEAD

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase leftover

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines 127 to 130
<ClusterInventoryItem
model={PersistentVolumeClaimModel}
mapper={getPVCStatusGroups}
useAbbr
/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should not have been removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't. it's down below at line 142

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wrong, fixed it.

@@ -102,7 +111,10 @@ const InventoryItem: React.FC<InventoryItemProps> = React.memo(
</AccordionItem>
</Accordion>
) : (
<div className="co-inventory-card__item">
<div
className="co-inventory-card__item co-inventory-card__item--border"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second class should not be there

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not? I didn't add it

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This diff clearly shows you did :) It is a result of an incorrect rebase. The co-inventory-card__item--border class was recently removed by another patch and when you rebased, it is being unintentionally added back.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks

Comment on lines 126 to 130
<ClusterInventoryItem
model={PersistentVolumeClaimModel}
mapper={getPVCStatusGroups}
useAbbr
/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To preserve the order of the ClusterInventoryItems, this should go after StorageClassModel ClusterInventoryItem. Also data-test-id prop should get added to this item as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@knowncitizen knowncitizen force-pushed the metal3-tests branch 3 times, most recently from c17a5dd to 2657874 Compare October 25, 2019 21:31
@jtomasek
Copy link

This needs to get updated to conform to #2051

This is the basic Protractor (Selenium) infrastructure to test the
dashboards.

Included is also a small test to read some of the counters in the
dashboards page, and compare them to what we get from the CLI.

This PR includes PRs 2287 and 2288 from Dan Trainor, who added custom
data-test-id attributes on the elements inthe dashboards, to support
the automation so it will be easier to find the elements. Also huge
thanks to Honza Pokorny, Jason Rist and Jiri Tomasek who helped with
the code and with rebases.

Basic steps to run the tests:

yarn install
yarn webdriver-update
export BRIDGE_BASE_ADDRESS='https://*.*.*.redhat.com'
export BRIDGE_AUTH_USERNAME=kubeadmin
export BRIDGE_AUTH_PASSWORD=22Z....
oc login -s *.*.*.redhat.com:6443 -u kubeadmin -p 22ZW....
export KUBECONFIG=/home/ukalifon/.kube/config
export NO_HEADLESS=true    # optional - if you want to see the browser
yarn run test-suite --suite baremetalSmokeTests --params.openshift true
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ukalifon
To complete the pull request process, please assign spadgett
You can assign the PR to them by writing /assign @spadgett in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci-robot openshift-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 21, 2020
@openshift-ci-robot
Copy link
Contributor

@ukalifon: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-gcp aee82a4 link /test e2e-gcp
ci/prow/backend 7a7209d link /test backend
ci/prow/frontend 7a7209d link /test frontend
ci/prow/analyze 7a7209d link /test analyze
ci/prow/e2e-gcp-console 7a7209d link /test e2e-gcp-console
ci/prow/images 7a7209d link /test images
ci/prow/kubevirt-plugin 7a7209d link /test kubevirt-plugin

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@ukalifon ukalifon closed this Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/ceph Related to ceph-storage-plugin component/core Related to console core functionality component/dashboard Related to dashboard component/dev-console Related to dev-console component/knative Related to knative-plugin component/kubevirt Related to kubevirt-plugin component/metal3 Related to metal3-plugin component/monitoring Related to monitoring component/noobaa Related to noobaa-storage-plugin component/olm Related to OLM component/sdk Related to console-plugin-sdk component/shared Related to console-shared lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants