Skip to content

Commit

Permalink
Merge pull request #2515 from cyclinder/ci/fix_ifacer_1
Browse files Browse the repository at this point in the history
CI: don't run node reboot case for ifacer
  • Loading branch information
weizhoublue authored Nov 1, 2023
2 parents c3a1f57 + fa6c689 commit 63e2e55
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,11 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator")

ctx, cancel := context.WithTimeout(context.Background(), common.PodStartTimeout)
defer cancel()

depObject, err := frame.WaitDeploymentReady(depName, namespace, ctx)
Expect(err).NotTo(HaveOccurred(), "waiting for deploy ready failed, error is: %v ", err)
Expect(err).NotTo(HaveOccurred(), "waiting for deploy ready failed: %v ", err)
podList, err := frame.GetPodListByLabel(depObject.Spec.Template.Labels)
Expect(err).NotTo(HaveOccurred(), "failed to get podList, error is: %v ", err)
Expect(err).NotTo(HaveOccurred(), "failed to get podList: %v ", err)

// Check pod's mac address prefix
commandString := fmt.Sprintf("ip link show dev %s | awk '/ether/ {print substr($2,0,5)}'", common.NIC2)
Expand Down
96 changes: 50 additions & 46 deletions test/e2e/ifacer/ifacer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package ifacer_test
import (
"context"
"fmt"
"math/rand"
"time"

. "github.com/onsi/ginkgo/v2"
Expand All @@ -30,8 +29,7 @@ var _ = Describe("test ifacer", Label("ifacer"), func() {
namespace = "ns" + tools.RandomName()
spiderMultusNadName = "test-multus-" + common.GenerateString(10, true)

r := rand.New(rand.NewSource(time.Now().UnixNano()))
vlanInterface = r.Intn(100)
vlanInterface = 50
GinkgoWriter.Println("Generate vlan ID of sub-interface:", vlanInterface)

err := frame.CreateNamespaceUntilDefaultServiceAccountReady(namespace, common.ServiceAccountReadyTimeout)
Expand Down Expand Up @@ -121,7 +119,7 @@ var _ = Describe("test ifacer", Label("ifacer"), func() {
for _, node := range frame.Info.KindNodeList {
showMasterResult, err := frame.DockerExecCommand(ctx, node, checkMasterUPString)
if err != nil {
GinkgoWriter.Printf("Failed to execute command on the node %s : %v \n", node, err)
GinkgoWriter.Printf("Failed to execute command %s on the node %s : %v \n", checkMasterUPString, node, showMasterResult)
return false
}

Expand All @@ -132,7 +130,7 @@ var _ = Describe("test ifacer", Label("ifacer"), func() {

showResult, err := frame.DockerExecCommand(ctx, node, checkIPLinkString)
if err != nil {
GinkgoWriter.Printf("Failed to execute command on the node %s: %v \n", node, err)
GinkgoWriter.Printf("Failed to execute %s on the node %s: %v \n", checkIPLinkString, node, showResult)
return false
}

Expand All @@ -152,7 +150,7 @@ var _ = Describe("test ifacer", Label("ifacer"), func() {
setDownString := fmt.Sprintf("ip link set %s.%d down", common.NIC1, vlanInterface)
for _, node := range frame.Info.KindNodeList {
_, err := frame.DockerExecCommand(ctx, node, setDownString)
Expect(err).NotTo(HaveOccurred(), "Failed to execute down %s on the node %s: %v", vlanInterface, err)
Expect(err).NotTo(HaveOccurred(), "Failed to execute %s on the node %s: %v", setDownString, node, err)
}
GinkgoWriter.Println("Restart all pods")
podList, err := frame.GetPodListByLabel(dsObject.Spec.Template.Labels)
Expand Down Expand Up @@ -184,45 +182,51 @@ var _ = Describe("test ifacer", Label("ifacer"), func() {
return true
}, common.ResourceDeleteTimeout, common.ForcedWaitingTime).Should(BeTrue())

GinkgoWriter.Println("After the host is restarted, the sub-interface is lost. Restarting the Pod will refresh the sub-interface.")
ctx, cancel = context.WithTimeout(context.Background(), common.ExecCommandTimeout)
defer cancel()
deleteIPLinkString := fmt.Sprintf("ip link delete dev %s.%d", common.NIC1, vlanInterface)
Eventually(func() bool {
for _, node := range frame.Info.KindNodeList {
_, err := frame.DockerExecCommand(ctx, node, deleteIPLinkString)
Expect(err).NotTo(HaveOccurred(), "Failed to execute the delete sub-interface command on the node %s %v", node, err)
}
return true
}, common.ResourceDeleteTimeout, common.ForcedWaitingTime).Should(BeTrue())

GinkgoWriter.Println("After deleting the sub-interface, restart all Pods")
podList, err = frame.GetPodListByLabel(dsObject.Spec.Template.Labels)
Expect(err).NotTo(HaveOccurred(), "failed to get Pod list, Pod list is %v", len(podList.Items))
Expect(frame.DeletePodList(podList)).NotTo(HaveOccurred())

GinkgoWriter.Println("The sub-interfaces of all nodes are automatically rebuilt, and the status is UP")
ctx, cancel = context.WithTimeout(context.Background(), common.ExecCommandTimeout)
defer cancel()

err = frame.WaitPodListRunning(dsObject.Spec.Template.Labels, 2, ctx)
Expect(err).NotTo(HaveOccurred())

checkIPLinkString = fmt.Sprintf("ip link show up %s.%d", common.NIC1, vlanInterface)
Eventually(func() bool {
for _, node := range frame.Info.KindNodeList {
showResult, err := frame.DockerExecCommand(ctx, node, checkIPLinkUpString)
if err != nil {
GinkgoWriter.Printf("failed to check if subinterfaces is up on node %s: %v \n", node, err)
return false
}

if len(showResult) == 0 {
GinkgoWriter.Printf("sub-vlan interfaces is down, waiting...")
return false
}
}
return true
}, common.ResourceDeleteTimeout, common.ForcedWaitingTime).Should(BeTrue())
// macvlan issue: https://github.com/containernetworking/plugins/pull/954
// When the master interface on the node has been deleted, and loadConf tries
// to get the MTU, This causes cmdDel to return a linkNotFound error to the
// runtime.
// TODO(cyclinder): undo the following comment if cni-plugins has new release
// GinkgoWriter.Println("After the host is restarted, the sub-interface is lost. Restarting the Pod will refresh the sub-interface.")
// ctx, cancel = context.WithTimeout(context.Background(), common.ExecCommandTimeout)
// defer cancel()
//
// deleteIPLinkString := fmt.Sprintf("ip link delete dev %s.%d", common.NIC1, vlanInterface)
// Eventually(func() bool {
// for _, node := range frame.Info.KindNodeList {
// _, err := frame.DockerExecCommand(ctx, node, deleteIPLinkString)
// Expect(err).NotTo(HaveOccurred(), "Failed to execute the delete sub-interface command on the node %s %v", node, err)
// }
// return true
// }, common.ResourceDeleteTimeout, common.ForcedWaitingTime).Should(BeTrue())
//
// GinkgoWriter.Println("After deleting the sub-interface, restart all Pods")
// podList, err = frame.GetPodListByLabel(dsObject.Spec.Template.Labels)
// Expect(err).NotTo(HaveOccurred(), "failed to get Pod list, Pod list is %v", len(podList.Items))
// Expect(frame.DeletePodList(podList)).NotTo(HaveOccurred())
//
// GinkgoWriter.Println("The sub-interfaces of all nodes are automatically rebuilt, and the status is UP")
// ctx, cancel = context.WithTimeout(context.Background(), common.ExecCommandTimeout)
// defer cancel()
//
// err = frame.WaitPodListRunning(dsObject.Spec.Template.Labels, 2, ctx)
// Expect(err).NotTo(HaveOccurred())
//
// checkIPLinkString = fmt.Sprintf("ip link show up %s.%d", common.NIC1, vlanInterface)
// Eventually(func() bool {
// for _, node := range frame.Info.KindNodeList {
// showResult, err := frame.DockerExecCommand(ctx, node, checkIPLinkUpString)
// if err != nil {
// GinkgoWriter.Printf("failed to check if subinterfaces is up on node %s: %v \n", node, err)
// return false
// }
//
// if len(showResult) == 0 {
// GinkgoWriter.Printf("sub-vlan interfaces is down, waiting...")
// return false
// }
// }
// return true
// }, common.ResourceDeleteTimeout, common.ForcedWaitingTime).Should(BeTrue())
})
})
7 changes: 3 additions & 4 deletions test/e2e/performance/performance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,14 @@ var _ = Describe("performance test case", Serial, Label("performance"), func() {
defer cancel()
var curlCheckString string
if frame.Info.IpV6Enabled && !frame.Info.IpV4Enabled {
curlCheckString = fmt.Sprintf("curl -I -m 1 -g http://[%s]:80 --insecure", pod.Status.PodIP)
curlCheckString = fmt.Sprintf("curl --retry 10 -m 1 -g http://[%s]:80 --insecure", pod.Status.PodIP)
} else {
curlCheckString = fmt.Sprintf("curl -I -m 1 http://%s:80 --insecure", pod.Status.PodIP)
curlCheckString = fmt.Sprintf("curl --retry 10 -m 1 http://%s:80 --insecure", pod.Status.PodIP)
}

for _, node := range frame.Info.KindNodeList {
curlReturnResult, errCurl := frame.DockerExecCommand(ctx, node, curlCheckString)
Expect(errCurl).NotTo(HaveOccurred())
GinkgoWriter.Printf("Failed to execute the curl command on the node, error is %v", string(curlReturnResult))
Expect(errCurl).NotTo(HaveOccurred(), "Failed to execute the command %s on the node: %v", curlCheckString, string(curlReturnResult))
}
}

Expand Down

0 comments on commit 63e2e55

Please sign in to comment.