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

e2e: fix e2e test for the sriovnetworknodepolicy #742

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions test/e2e/sriovoperatornodepolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,29 @@ var _ = Describe("Operator", func() {
},
},
}
policy3 := &sriovnetworkv1.SriovNetworkNodePolicy{
TypeMeta: metav1.TypeMeta{
Kind: "SriovNetworkNodePolicy",
APIVersion: "sriovnetwork.openshift.io/v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "policy-1",
Namespace: testNamespace,
},
Spec: sriovnetworkv1.SriovNetworkNodePolicySpec{
ResourceName: "resource_1",
NodeSelector: map[string]string{
"feature.node.kubernetes.io/network-sriov.capable": "true",
},
Priority: 99,
Mtu: 9000,
NumVfs: 6,
NicSelector: sriovnetworkv1.SriovNetworkNicSelector{
PfNames: []string{"#2-4"},
},
DeviceType: "vfio-pci",
},
}

JustBeforeEach(func() {
By("wait for the node state ready")
Expand Down Expand Up @@ -257,6 +280,9 @@ var _ = Describe("Operator", func() {
err = WaitForDaemonSetReady(dpDaemonSet, k8sClient, testNamespace, "sriov-device-plugin", RetryInterval, Timeout)
Expect(err).NotTo(HaveOccurred())

pfName, rngStart, rngEnd, err := sriovnetworkv1.ParseVfRange(policy.Spec.NicSelector.PfNames[0])
Expect(err).NotTo(HaveOccurred())

By("update the spec of SriovNetworkNodeState CR")
found := false
for _, address := range policy.Spec.NicSelector.RootDevices {
Expand All @@ -268,8 +294,6 @@ var _ = Describe("Operator", func() {
Expect(iface.VfGroups[0].DeviceType).To(Equal(policy.Spec.DeviceType))
Expect(iface.VfGroups[0].ResourceName).To(Equal(policy.Spec.ResourceName))

pfName, rngStart, rngEnd, err := sriovnetworkv1.ParseVfRange(policy.Spec.NicSelector.PfNames[0])
Expect(err).NotTo(HaveOccurred())
rng := strconv.Itoa(rngStart) + "-" + strconv.Itoa(rngEnd)
Expect(iface.Name).To(Equal(pfName))
Expect(iface.VfGroups[0].VfRange).To(Equal(rng))
Expand All @@ -287,7 +311,10 @@ var _ = Describe("Operator", func() {
Expect(iface.NumVfs).To(Equal(policy.Spec.NumVfs))
Expect(iface.Mtu).To(Equal(policy.Spec.Mtu))
Expect(len(iface.VFs)).To(Equal(policy.Spec.NumVfs))
for _, vf := range iface.VFs {
for i, vf := range iface.VFs {
if i < rngStart || rngEnd < i {
continue
}
if policy.Spec.DeviceType == "netdevice" || policy.Spec.DeviceType == "" {
Expect(vf.Mtu).To(Equal(policy.Spec.Mtu))
}
Expand All @@ -301,8 +328,9 @@ var _ = Describe("Operator", func() {
}
Expect(found).To(BeTrue())
},
Entry("Set one PF with VF range", policy1),
Entry("Set one PF with VF range", policy2),
Entry("Set one vfio PF with VF range #0-5", policy1),
Entry("Set one netdevice PF with VF range #0-0", policy2),
Entry("Set one vfio PF with VF range #2-4", policy3),
)
})

Expand Down
Loading