-
Notifications
You must be signed in to change notification settings - Fork 135
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
CNF-13652: Test integration of SRIOV and NMState operators #1990
Conversation
@zeeke: This pull request references CNF-13652 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.17.0" version, but no target version was set. 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 openshift-eng/jira-lifecycle-plugin repository. |
/test ? |
@zeeke: The following commands are available to trigger required jobs:
The following commands are available to trigger optional jobs:
Use
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-sigs/prow repository. |
/test e2e-telco5g-cnftests |
/test e2e-telco5g-cnftests |
7692f80
to
bcb630c
Compare
/test e2e-telco5g-cnftests |
1 similar comment
/test e2e-telco5g-cnftests |
func waitForNMStatePolicyToBeStable(nmstatePolicy *nmstatev1.NodeNetworkConfigurationPolicy) { | ||
key := runtimeclient.ObjectKey{Name: nmstatePolicy.Name} | ||
Eventually(func(g Gomega) { | ||
err := client.Client.Get(context.Background(), key, nmstatePolicy) |
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 nmstatePolicy is using the arg var, which creates confusion about the scope of the variables. Maybe have a new one.
Help functions imo are easier to read/be refactored if they are not having many assertions. I always suggest the assertion to be in the main block and have function that return error/true.
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 nmstatePolicy is using the arg var, which creates confusion about the scope of the variables. Maybe have a new one.
good point. And since the function only use the name of the policy, I refactor it to pass a string only.
Help functions imo are easier to read/be refactored if they are not having many assertions. I always suggest the assertion to be in the main block and have function that return error/true.
I'm not 100% with it: helper functions must be short (<20 lines, as a rule of thumb) and that's where they get their readability. On the other side, the call site needs to be way more readable, as it contains the complicated test logic. With the current implementation, the call site reads:
waitForNMStatePolicyToBeStable(nodeNetworkConfigPolicy.Name)
which reads straightforward to me.
With functions like these, we might lose reusability; a function that waits for different conditions is almost copy/paste, but that's another story.
testDevice := devices[0] | ||
By("Using device " + testDevice.Name) | ||
|
||
By("Configuring IPAM on Physical Function via NMState") |
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.
Is that different than "Configuring and IPv4 address"? just IPAM (Address Management) makes me think whereabouts/or other IPAM is being deployed
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.
IPv4 is definitely more clear! changing
sriovclient = sriovtestclient.New("") | ||
} | ||
|
||
var _ = Describe("[nmstate] SR-IOV Network Operator Integration", Ordered, func() { |
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.
Why the ordered
is needed?
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.
To use the BeforeAll
section.
https://onsi.github.io/ginkgo/#setup-in-ordered-containers-beforeall-and-afterall
The question might be, why did I used a BeforeAll if there is only one test case? The answer is "I hope to add more test cases in the future". It might be an early optimization, WDYT?
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.
Pretty sure you can use BeforeEach, AfterEach stacked on top of Describe/Context to achieve what you need in the future.
According to the doc
Ginkgo did not include support for Ordered containers for quite some time. As you can see Ordered containers make it possible to circumvent the "Declare in container nodes, initialize in setup nodes" principle; and they make it possible to write dependent specs This comes at a cost, of course - specs in Ordered containers cannot be fully parallelized which can result in slower suite runtimes. Despite these cons, pragmatism prevailed and Ordered containers were introduced in response to real-world needs in the community. Nonetheless, we recommend using Ordered containers only when needed.
So I would say specs(tests) should be not ordered unless they really really need to be.
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.
okay, let's go for the BeforeEach way
resNum := testedNode.Status.Allocatable[corev1.ResourceName("openshift.io/testnmstateresource")] | ||
capacity, _ := resNum.AsInt64() | ||
return capacity | ||
}, 10*time.Minute, time.Second).Should(Equal(int64(10))) |
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 the end spec is " there should be 10 VRFs"?
I suggest to extend the description that appears if the spec fails, e.g.
Should(Equal(int64(10))," the number of VFs observes is not that same as the one sriov created")
``
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.
sounds good. changing
}) | ||
|
||
func findNonPrimarySriovDevicesAndNode(n *cluster.EnabledNodes) (string, []*sriovv1.InterfaceExt, error) { | ||
errs := []error{} |
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 could use this lib https://pkg.go.dev/errors to wrap errors
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'm using that package at the end of the function:
if len(retDevices) == 0 {
return "", nil, fmt.Errorf("can't find any SR-IOV devices in cluster's nodes: %w", errors.Join(errs...))
}
How would you use it with Wrap(...)
?
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 think you can avoid the []array
func main() {
var err error
if false{
err1 := errors.New("err1")
err = errors.Join(err, err1)
err2 := errors.New("err2")
err = errors.Join(err, err2)
}
fmt.Println(err)
}
but to be honest, both works
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.
going for the errors.Join(...)
approach
|
||
if len(nonPrimaryDevices) > len(retDevices) { | ||
retNode = node | ||
retDevices = nonPrimaryDevices |
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.
Can you just return here in the happy path, and return the wrap errors. I might be missing if there is selection between two nodes that have sriov or not
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.
good point: this function is not very clear. The point is to find the node with the most number of SR-IOV devices. Going to reword the variables and comment to make it clearer.
name: openshift-nmstate | ||
spec: | ||
finalizers: | ||
- kubernetes |
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.
[nit] my yamllint is complaining that it need ---
and two spaces here (same for all yamls)
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's make the linter happy 😉
b7f7b62
to
cd0875f
Compare
/test e2e-telco5g-cnftests |
name: kubernetes-nmstate-operator | ||
source: art-nightly-operator-catalog | ||
sourceNamespace: openshift-marketplace | ||
--- |
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 ---
goes to the top
yamllint feature-configs/ci/nmstate/kustomization.yaml
feature-configs/ci/nmstate/kustomization.yaml
1:1 warning missing document start "---" (document-start)
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.
just noticed all the yaml under feature-configs
does not have ---
. Lets make it as all the other and live with that until we decide to put yamllint in the CI. Does it sound good?
6b21f40
to
f81a28a
Compare
/test e2e-telco5g-cnftests |
/retest |
/retest |
Expect(err).ToNot(HaveOccurred()) | ||
DeferCleanup(sriovclient.Delete, context.Background(), sriovNetworkNodePolicy) | ||
|
||
By("Verify Virtual Functions have been correctly configured") |
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.
nit: verifying that (same below)
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.
Changed!
/test e2e-telco5g-cnftests |
/retest |
/test e2e-telco5g-cnftests |
/test e2e-telco5g-cnftests |
/retest |
/test e2e-telco5g-cnftests |
/retest |
602c277
to
1047a6a
Compare
Signed-off-by: Andrea Panattoni <[email protected]>
Signed-off-by: Andrea Panattoni <[email protected]>
Add a test that configures the same NIC via Kubernetes-NMState and SR-IOV network operator. The test ensure that if NMState doesn't have any SR-IOV configuration, then both operator should work correctly. Signed-off-by: Andrea Panattoni <[email protected]>
`kubernetes-nmsate` CI does not publish images on `quay.io/openshift/*`. The best way to deploy a recent version of the operator is to leverage the `quay.io/openshift-release-dev/ocp-release-nightly:iib-int-index-art-operators-4.17` index image, which picks latest nightly builds from Brew. Signed-off-by: Andrea Panattoni <[email protected]>
/test e2e-telco5g-cnftests |
@zeeke: The following test failed, say
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-sigs/prow repository. I understand the commands that are listed here. |
Failing tests
are known bugs. See https://issues.redhat.com/browse/CNF-14296 |
/lgtm |
/override ci/prow/e2e-aws-ci-tests |
@zeeke: Overrode contexts on behalf of zeeke: ci/prow/e2e-aws-ci-tests 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-sigs/prow repository. |
872a4ce
into
openshift-kni:master
Run `sriov/knmstate` combined tests defined in - openshift-kni/cnf-features-deploy#1990 as part of the cnf-tests suite. Signed-off-by: Andrea Panattoni <[email protected]>
This changes implements a simple test to verify the NMState operator does not interfere with the SR-IOV network operator.