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

Added ceph osd tree related test cases for OCS expand #3793

Merged
merged 1 commit into from Jan 8, 2020

Conversation

gnehapk
Copy link
Contributor

@gnehapk gnehapk commented Dec 17, 2019

No description provided.

@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 17, 2019
@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. component/ceph Related to ceph-storage-plugin labels Dec 17, 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 Dec 17, 2019
Comment on lines 104 to 111
export const getZoneIds = (nodes) =>
nodes.filter((node) => node.type === ZONE).map((node) => node.id);

export const getNodeIds = (nodes) =>
nodes.filter((node) => node.type === HOST).map((node) => node.id);

export const getOSDIds = (nodes) =>
nodes.filter((node) => node.type === OSD).map((node) => node.id);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion:

getIds = (nodes, type) =>
  nodes.filter((node) => node.type === type).map((node) => node.id);

export const getOSDIds = (nodes) =>
nodes.filter((node) => node.type === OSD).map((node) => node.id);

export const getNewOSDIds = (nodes, osds) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

add types

Comment on lines 117 to 156
export const createOSDTreeMap = (nodes) => {
const tree = {};
nodes.forEach((node) => {
tree[node.id] = node;
});
return tree;
};

export const verifyZoneOSDMapping = (zones, osds, osdtree) => {
let filteredOsds = [];
zones.forEach((zone) => {
const hostId = osdtree[zone].children[0];
const len = osdtree[hostId].children.length;
filteredOsds = osds.filter((osd) => osd !== osdtree[hostId].children[len - 1]);
});

return filteredOsds.length === 0;
};

export const verifyNodeOSDMapping = (nodes, osds, osdtree) => {
let filteredOsds = [];
nodes.forEach((node) => {
const len = osdtree[node].children.length;
filteredOsds = osds.filter((osd) => osd !== osdtree[node].children[len - 1]);
Copy link
Contributor

Choose a reason for hiding this comment

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

add types

@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 17, 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 Dec 17, 2019
@gnehapk
Copy link
Contributor Author

gnehapk commented Dec 18, 2019

@afreen23 @bipuladh Please review.

@@ -92,6 +106,11 @@ if (clusterStatus && cephHealth) {
await verifyFields();
await click(confirmButton);

expansionObjects.osdtree = JSON.parse(
execSync(
`oc -n openshift-storage rsh $(oc -n openshift-storage get pod | grep ceph-operator| awk '{print$1}') ceph --conf=/var/lib/rook/openshift-storage/openshift-storage.config osd tree --format=json`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
`oc -n openshift-storage rsh $(oc -n openshift-storage get pod | grep ceph-operator| awk '{print$1}') ceph --conf=/var/lib/rook/openshift-storage/openshift-storage.config osd tree --format=json`,
`oc -n ${NS} rsh $(oc -n ${NS} get pod | grep ceph-operator| awk '{print$1}') ceph --conf=/var/lib/rook/${NS}/${NS}.config osd tree --format=json`,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

@@ -44,6 +54,10 @@ const expansionObjects = {
updatedClusterJSON: {},
previousPods: { items: [] as PodKind[] },
updatedPods: { items: [] as PodKind[] },
osdtree: { nodes: [] as nodeType[] },
Copy link
Contributor

Choose a reason for hiding this comment

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

You have already defined osdTreeType below.

Suggested change
osdtree: { nodes: [] as nodeType[] },
osdtree: <osdTreeType>{},

or

Suggested change
osdtree: { nodes: [] as nodeType[] },
osdtree: {} as osdTreeType,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both are different. osdtree has nodes which is of nodeType[] and not node.

Copy link
Contributor

@afreen23 afreen23 Dec 18, 2019

Choose a reason for hiding this comment

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

You should have one structure for osdTree, if you are creating one for formatted , then name it properly.
It can cause readability issues.

Copy link
Contributor

@afreen23 afreen23 Dec 18, 2019

Choose a reason for hiding this comment

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

AFAIK , this variable osdTree s the actual osd tree , so its type should be defined as OsdTreeType.
Then you are creating a map out of it, you can name it nodeMap or whatever you feel alongwith its type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will prefer not to create OsdTree type separately as its used just at one place. Ack on the map object and will rename it to FormattedOsdTreeType as it makes more sense.

Comment on lines 55 to 56
previousPods: { items: [] as PodKind[] },
updatedPods: { items: [] as PodKind[] },
Copy link
Contributor

Choose a reason for hiding this comment

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

you must define a proper type for this, since its being reused and it look more cleaner.

return filteredOsds.length === 0;
};

export type nodeType = {
Copy link
Contributor

@afreen23 afreen23 Dec 18, 2019

Choose a reason for hiding this comment

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

I prefer to have type names defined in Pascal case. It helps in differentiating between variable names and keys defined within an object type.
Also omits the need of suffix: type

Suggested change
export type nodeType = {
export type Node = {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack for the Pascal case. Whats the reason for omitting type. Its being added to differentiate its type name from the variable name

Copy link
Contributor

Choose a reason for hiding this comment

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

You can add if you want, defining in Pascal works thats why I dont encourage.

primary_affinity?: number;
};

export type osdTreeType = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export type osdTreeType = {
export type OsdTree = {

@gnehapk
Copy link
Contributor Author

gnehapk commented Dec 18, 2019

/test e2e-gcp-console

});
}

type Pod = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let be consistent.

Suggested change
type Pod = {
type PodType = {

previousCnt: number;
updatedCnt: number;
updatedClusterJSON: {};
previousPods: Pod;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
previousPods: Pod;
previousPods: PodType;

updatedCnt: number;
updatedClusterJSON: {};
previousPods: Pod;
updatedPods: Pod;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
updatedPods: Pod;
updatedPods: PodType;

@gnehapk
Copy link
Contributor Author

gnehapk commented Dec 18, 2019

@ebondare @rhrazdil @pumpmypic @hnallurv Please review.

@@ -92,6 +106,11 @@ if (clusterStatus && cephHealth) {
await verifyFields();
await click(confirmButton);

expansionObjects.osdTree = JSON.parse(
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be fetched twice, once before expansion and once after ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not needed. Only need to test with the ceph osd tree reponse post expansion.

execSync(
`oc -n ${NS} rsh $(oc -n ${NS} get pod | grep ceph-operator| awk '{print$1}') ceph --conf=/var/lib/rook/${NS}/${NS}.config osd tree --format=json`,
).toString(),
);
const statusCol = storageClusterRow(uid).$('td:nth-child(4)');
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not reliable, in 4.4 the status is in 3 column.
Use something else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't see any other option. This test is written w.r.t 4.3 setup.

Copy link
Contributor

@afreen23 afreen23 Dec 19, 2019

Choose a reason for hiding this comment

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

So, we are okay with breaking tests in 4.4+. This will cause timeout error, because it will never match "ready" status. I am not into integration testing but may be adding ids (though its touching core). There would be some way may be xpath ?
Or non reliable way would be to send seperate fixes for each branch.
@bipuladh might be able to help ?

Choose a reason for hiding this comment

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

My point of view to these inter-version changes in the UI is that once a PR is directed to console/master, it should be working in console/master.
I know it's hard to maintain upstream tests working, especially without a gating job that would enforce developers to fix tests that their changes break.

But if we implement test cases intentionally for old versions, it inevitably means that more time will be invested (or more like wasted, as it's not really an investment) into fixing the test for the next version.

Copy link
Contributor

@afreen23 afreen23 Dec 19, 2019

Choose a reason for hiding this comment

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

Agree with @rhrazdil . I checked tests are not backported to 4.3/4.2 due to code freeze.
Hence it makes sense to write tests against master now and follow this suggested way to maintain.

Copy link
Contributor Author

@gnehapk gnehapk Dec 24, 2019

Choose a reason for hiding this comment

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

For adding class to this status field, require changes in the common components i.e. OperandTableHeader inside OperandList which is being used by all the provided APIs views. Hence, I don't think that its a good idea to modify the common component just for adding class, as I am not sure, what impacts it might have.

@shyRozen
Copy link
Contributor

/test e2e-gcp-console

Copy link
Contributor

@afreen23 afreen23 left a comment

Choose a reason for hiding this comment

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

The logic looks good now

@gnehapk
Copy link
Contributor Author

gnehapk commented Dec 28, 2019

/test e2e-gcp-console

2 similar comments
@gnehapk
Copy link
Contributor Author

gnehapk commented Jan 2, 2020

/test e2e-gcp-console

@gnehapk
Copy link
Contributor Author

gnehapk commented Jan 6, 2020

/test e2e-gcp-console

@bipuladh
Copy link
Contributor

bipuladh commented Jan 8, 2020

/approve

@gnehapk
Copy link
Contributor Author

gnehapk commented Jan 8, 2020

/lgtm

@openshift-ci-robot
Copy link
Contributor

@gnehapk: you cannot LGTM your own PR.

In response to this:

/lgtm

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.

@bipuladh
Copy link
Contributor

bipuladh commented Jan 8, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 8, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: afreen23, bipuladh, gnehapk

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

The pull request process is described 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-merge-robot openshift-merge-robot merged commit 68af0f5 into openshift:master Jan 8, 2020
@spadgett spadgett added this to the v4.4 milestone Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/ceph Related to ceph-storage-plugin lgtm Indicates that a PR is ready to be merged. 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.

None yet

8 participants