Skip to content

Commit

Permalink
fix e2e
Browse files Browse the repository at this point in the history
Signed-off-by: clyi <[email protected]>
  • Loading branch information
changluyi committed Dec 26, 2024
1 parent 516ab60 commit caa830e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@ func (c *Controller) getPodAttachmentNet(pod *v1.Pod) ([]*kubeovnNet, error) {
}

if len(attach.IPRequest) != 0 {
ret.IPRequest = attach.IPRequest[0]
ret.IPRequest = strings.Join(attach.IPRequest, ",")
}

ret.MacRequest = attach.MacRequest
Expand Down
16 changes: 13 additions & 3 deletions test/e2e/multus/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,19 @@ var _ = framework.SerialDescribe("[group:multus]", func() {
ginkgo.By("Creating pod " + podName)
mac := "00:00:00:11:22:33"
randomIP := framework.RandomIPs(subnet.Spec.CIDRBlock, "", 1)
requestIP := strings.Split(randomIP, ",")[0]

annotations := map[string]string{nadv1.NetworkAttachmentAnnot: fmt.Sprintf(`[{"name": "%s", "namespace": "%s", "mac": "%s", "ips": ["%s"]}]`, nad.Name, nad.Namespace, mac, requestIP)}
randomIPArray := strings.Split(randomIP, ",")
var requestIPString string
for i, ip := range randomIPArray {
if i == len(randomIPArray)-1 {
requestIPString += fmt.Sprintf(`"%s"`, ip)
} else {
requestIPString += fmt.Sprintf(`"%s",`, ip)
}
}

framework.Logf("requestIPString: %s", requestIPString)
annotations := map[string]string{nadv1.NetworkAttachmentAnnot: fmt.Sprintf(`[{"name": "%s", "namespace": "%s", "mac": "%s", "ips": [%s]}]`, nad.Name, nad.Namespace, mac, requestIPString)}
annotations[fmt.Sprintf(util.LogicalSwitchAnnotationTemplate, provider)] = subnetName

cmd := []string{"sh", "-c", "sleep infinity"}
Expand All @@ -530,6 +540,6 @@ var _ = framework.SerialDescribe("[group:multus]", func() {
retIP := pod.Annotations[fmt.Sprintf(util.IPAddressAnnotationTemplate, provider)]

framework.ExpectEqual(mac, retMac)
framework.ExpectEqual(requestIP, retIP)
framework.ExpectEqual(strings.Join(randomIPArray, ","), retIP)
})
})

0 comments on commit caa830e

Please sign in to comment.