From 4737e203a3d9701bd051755047afb54a9973a0b4 Mon Sep 17 00:00:00 2001 From: ceclinux Date: Mon, 4 Jul 2022 15:05:31 +0800 Subject: [PATCH] wip --- ci/jenkins/test.sh | 2 +- test/e2e/framework.go | 9 +++++++-- test/e2e/multicast_test.go | 23 ++++++++++++++++++----- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/ci/jenkins/test.sh b/ci/jenkins/test.sh index 4efb8f988c6..9e683a0c6c5 100755 --- a/ci/jenkins/test.sh +++ b/ci/jenkins/test.sh @@ -541,7 +541,7 @@ function run_e2e { if [[ $TESTBED_TYPE == "flexible-ipam" ]]; then go test -v antrea.io/antrea/test/e2e --logs-export-dir `pwd`/antrea-test-logs --provider remote -timeout=100m --prometheus --antrea-ipam else - go test -v antrea.io/antrea/test/e2e --logs-export-dir `pwd`/antrea-test-logs --provider remote -timeout=100m --prometheus + go test -run=TestMulticast -v antrea.io/antrea/test/e2e --logs-export-dir `pwd`/antrea-test-logs --provider remote -timeout=100m --prometheus fi if [[ "$?" != "0" ]]; then TEST_FAILURE=true diff --git a/test/e2e/framework.go b/test/e2e/framework.go index 2e94293ba51..0c1a80d676f 100644 --- a/test/e2e/framework.go +++ b/test/e2e/framework.go @@ -24,11 +24,13 @@ import ( "os" "path/filepath" "reflect" - "regexp" + + "k8s.io/klog/v2" "strconv" "strings" "time" + "regexp" "github.com/containernetworking/plugins/pkg/ip" log "github.com/sirupsen/logrus" "golang.org/x/mod/semver" @@ -2165,7 +2167,10 @@ func (data *TestData) GetMulticastInterfaces(antreaNamespace string) ([]string, } func GetTransportInterface(data *TestData) (string, error) { - _, transportInterfaceUntrimmed, _, err := data.RunCommandOnNode(nodeName(0), fmt.Sprintf("/bin/sh -c ip -br addr show | grep %s | awk '{split($1,a,\"@\"); print a[1]}'", clusterInfo.nodes[0].ipv4Addr)) + a, transportInterfaceUntrimmed, b, err := data.RunCommandOnNode(nodeName(0), fmt.Sprintf("/bin/sh -c 'ip -br addr | grep %s | awk -F\" \" \"{print \\$1}\"'", clusterInfo.nodes[0].ipv4Addr)) + klog.Infof("%+v", a) + klog.Infof("%+v", b) + klog.Infof("%+v", err) if err != nil { return "", err } diff --git a/test/e2e/multicast_test.go b/test/e2e/multicast_test.go index a4e64f60cc4..d4c6728d00d 100644 --- a/test/e2e/multicast_test.go +++ b/test/e2e/multicast_test.go @@ -91,7 +91,6 @@ func TestMulticast(t *testing.T) { for _, mc := range testcases { mc := mc t.Run(mc.name, func(t *testing.T) { - t.Parallel() runTestMulticastBetweenPods(t, data, mc, nodeMulticastInterfaces) }) } @@ -131,7 +130,6 @@ func TestMulticast(t *testing.T) { for _, mc := range testcases { mc := mc t.Run(mc.name, func(t *testing.T) { - t.Parallel() runTestMulticastBetweenPods(t, data, mc, nodeMulticastInterfaces) }) } @@ -580,16 +578,19 @@ func runTestMulticastBetweenPods(t *testing.T, data *TestData, mc multicastTestc if err := wait.Poll(3*time.Second, defaultTimeout, func() (bool, error) { if !senderReady { // Sender pods should add an outbound multicast route except running as HostNetwork. - _, mrouteResult, _, err := data.RunCommandOnNode(nodeName(mc.senderConfig.nodeIdx), fmt.Sprintf("/bin/sh -c ip mroute show iif %s |grep ',%s)'|grep '%s'", gatewayInterface, mc.group.String(), strings.Join(nodeMulticastInterfaces[mc.senderConfig.nodeIdx], " "))) + _, mrouteResult, _, err := data.RunCommandOnNode(nodeName(mc.senderConfig.nodeIdx), fmt.Sprintf("/bin/sh -c 'ip mroute show iif %s |grep ',%s'|grep '%s''", gatewayInterface, mc.group.String(), strings.Join(nodeMulticastInterfaces[mc.senderConfig.nodeIdx], " "))) if err != nil { + t.Logf("%+v", mrouteResult) return false, err } if !mc.senderConfig.isHostNetwork { if len(mrouteResult) == 0 { + t.Logf("%+v", mrouteResult) return false, nil } } else { if len(mrouteResult) != 0 { + t.Logf("%+v", mrouteResult) return false, nil } } @@ -601,23 +602,27 @@ func runTestMulticastBetweenPods(t *testing.T, data *TestData, mc multicastTestc continue } for _, receiverMulticastInterface := range nodeMulticastInterfaces[receiver.nodeIdx] { - _, mRouteResult, _, err := data.RunCommandOnNode(nodeName(receiver.nodeIdx), fmt.Sprintf("/bin/sh -c ip mroute show iif %s|grep ',%s)'", receiverMulticastInterface, mc.group.String())) + _, mRouteResult, _, err := data.RunCommandOnNode(nodeName(receiver.nodeIdx), fmt.Sprintf("/bin/sh -c 'ip mroute show iif %s|grep ',%s''", receiverMulticastInterface, mc.group.String())) if err != nil { + t.Logf("%+v", mRouteResult) return false, err } // If multicast traffic is sent from non-HostNetwork pods and senders-receivers are located in different nodes, // the receivers should configure corresponding inbound multicast routes. if mc.senderConfig.nodeIdx != receiver.nodeIdx && !receiver.isHostNetwork { if len(mRouteResult) == 0 { + t.Logf("%+v", mRouteResult) return false, nil } } else { if len(mRouteResult) != 0 { + t.Logf("%+v", mRouteResult) return false, nil } } - _, mAddrResult, _, err := data.RunCommandOnNode(nodeName(receiver.nodeIdx), fmt.Sprintf("/bin/sh -c ip maddr show %s | grep %s", receiverMulticastInterface, mc.group.String())) + _, mAddrResult, _, err := data.RunCommandOnNode(nodeName(receiver.nodeIdx), fmt.Sprintf("/bin/sh -c 'ip maddr show %s | grep %s'", receiverMulticastInterface, mc.group.String())) if err != nil { + t.Logf("%+v", mAddrResult) return false, err } // The receivers should also join multicast group. @@ -625,14 +630,17 @@ func runTestMulticastBetweenPods(t *testing.T, data *TestData, mc multicastTestc // which will not persist after mcjoin exits. if !receiver.isHostNetwork { if len(mAddrResult) == 0 { + t.Logf("%+v", mAddrResult) return false, nil } } else { if len(mAddrResult) != 0 { + t.Logf("%+v", mAddrResult) return false, nil } } } +t.Logf("%+v", receiver) readyReceivers = readyReceivers.Insert(receiver.nodeIdx) } return true, nil @@ -675,6 +683,7 @@ func computeMulticastInterfaces(t *testing.T, data *TestData) (map[int][]string, return nil, err } transportInterface, err := GetTransportInterface(data) + t.Logf("%+v", transportInterface) if err != nil { t.Fatalf("Error getting transport interfaces: %v", err) } @@ -686,9 +695,13 @@ func computeMulticastInterfaces(t *testing.T, data *TestData) (map[int][]string, } // The final multicast interfaces used for the node is calculated by (localInterfacesSet intersects multicastInterfaceSet adds transportInterface). localInterfacesSet := sets.NewString(strings.Split(strings.TrimSpace(localInterfacesStr), "\n")...) + t.Logf("%+v", localInterfacesSet) multicastInterfaceSet := sets.NewString(multicastInterfaces...) + t.Logf("%+v", multicastInterfaceSet) externalMulticastInterfaces := localInterfacesSet.Intersection(multicastInterfaceSet) + t.Logf("%+v", externalMulticastInterfaces) currNodeMulticastInterfaces := externalMulticastInterfaces.Insert(transportInterface).List() + t.Logf("%+v", currNodeMulticastInterfaces) t.Logf("Multicast interfaces for node index %d is %+v", nodeIdx, currNodeMulticastInterfaces) nodeMulticastInterfaces[nodeIdx] = currNodeMulticastInterfaces }