Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ceclinux committed Jul 4, 2022
1 parent 1ba767f commit 4737e20
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ci/jenkins/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions test/e2e/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
23 changes: 18 additions & 5 deletions test/e2e/multicast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down Expand Up @@ -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)
})
}
Expand Down Expand Up @@ -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
}
}
Expand All @@ -601,38 +602,45 @@ 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.
// Note that in HostNetwork mode, the "join multicast" action is taken by mcjoin,
// 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
Expand Down Expand Up @@ -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)
}
Expand All @@ -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
}
Expand Down

0 comments on commit 4737e20

Please sign in to comment.