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
Conversation
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); |
There was a problem hiding this comment.
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) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add types
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]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add types
frontend/packages/ceph-storage-plugin/integration-tests/utils/helpers.ts
Show resolved
Hide resolved
frontend/packages/ceph-storage-plugin/integration-tests/utils/helpers.ts
Show resolved
Hide resolved
@@ -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`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`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`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
frontend/packages/ceph-storage-plugin/integration-tests/tests/2-tests/add-capacity.scenario.ts
Show resolved
Hide resolved
@@ -44,6 +54,10 @@ const expansionObjects = { | |||
updatedClusterJSON: {}, | |||
previousPods: { items: [] as PodKind[] }, | |||
updatedPods: { items: [] as PodKind[] }, | |||
osdtree: { nodes: [] as nodeType[] }, |
There was a problem hiding this comment.
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.
osdtree: { nodes: [] as nodeType[] }, | |
osdtree: <osdTreeType>{}, |
or
osdtree: { nodes: [] as nodeType[] }, | |
osdtree: {} as osdTreeType, |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
previousPods: { items: [] as PodKind[] }, | ||
updatedPods: { items: [] as PodKind[] }, |
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
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
export type nodeType = { | |
export type Node = { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export type osdTreeType = { | |
export type OsdTree = { |
/test e2e-gcp-console |
}); | ||
} | ||
|
||
type Pod = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let be consistent.
type Pod = { | |
type PodType = { |
previousCnt: number; | ||
updatedCnt: number; | ||
updatedClusterJSON: {}; | ||
previousPods: Pod; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previousPods: Pod; | |
previousPods: PodType; |
updatedCnt: number; | ||
updatedClusterJSON: {}; | ||
previousPods: Pod; | ||
updatedPods: Pod; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updatedPods: Pod; | |
updatedPods: PodType; |
frontend/packages/ceph-storage-plugin/integration-tests/tests/2-tests/add-capacity.scenario.ts
Show resolved
Hide resolved
@@ -92,6 +106,11 @@ if (clusterStatus && cephHealth) { | |||
await verifyFields(); | |||
await click(confirmButton); | |||
|
|||
expansionObjects.osdTree = JSON.parse( |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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)'); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
/test e2e-gcp-console |
There was a problem hiding this 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
/test e2e-gcp-console |
2 similar comments
/test e2e-gcp-console |
/test e2e-gcp-console |
/approve |
/lgtm |
@gnehapk: you cannot LGTM your own PR. In response to this:
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. |
/lgtm |
[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 |
No description provided.