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

Upgrade to gosnappi v0.12.1. #32

Merged
merged 2 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions e2e/simple_ondatra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func configureATEInterfaces(t *testing.T, ate *ondatra.ATEDevice, srcATE, dstATE
for _, p := range []*intf{ateSrc, ateDst, ateAuxDst} {
topology.Ports().Add().SetName(p.Name)
dev := topology.Devices().Add().SetName(p.Name)
eth := dev.Ethernets().Add().SetName(fmt.Sprintf("%s_ETH", p.Name))
eth.SetPortName(dev.Name()).SetMac(p.MAC)
eth := dev.Ethernets().Add().SetName(fmt.Sprintf("%s_ETH", p.Name)).SetMac(p.MAC)
eth.Connection().SetPortName(dev.Name())
}

c, err := topology.ToJson()
Expand Down Expand Up @@ -188,7 +188,7 @@ func TestMirror(t *testing.T) {
func addMPLSFlow(t *testing.T, otgCfg gosnappi.Config, name, srcName, dstName, srcv4, dstv4 string) {
mplsFlow := otgCfg.Flows().Add().SetName(name)
mplsFlow.Metrics().SetEnable(true)
mplsFlow.TxRx().Port().SetTxName(srcName).SetRxName(dstName)
mplsFlow.TxRx().Port().SetTxName(srcName).SetRxNames([]string{dstName})

mplsFlow.Rate().SetChoice("pps").SetPps(1)

Expand Down
8 changes: 6 additions & 2 deletions flows/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ func Ports(flow *otg.Flow, intfs []*lwotg.OTGIntf) (tx string, rx string, err er
}

txName := flow.GetTxRx().GetPort().GetTxName()
rxName := flow.GetTxRx().GetPort().GetRxName()
if rxList := flow.GetTxRx().GetPort().GetRxNames(); len(rxList) != 1 {
return "", "", fmt.Errorf("flows received at multiple ports are not supported, got: %d ports (%v)", len(rxList), rxList)

}
rxName := flow.GetTxRx().GetPort().GetRxNames()[0]

for _, i := range intfs {
if i.OTGPortName == txName {
Expand All @@ -43,7 +47,7 @@ func Ports(flow *otg.Flow, intfs []*lwotg.OTGIntf) (tx string, rx string, err er
// specification if there is no rate specified.
//
// TODO(robjs): support specifications other than simple PPS.
func Rate(flow *otg.Flow, hdrs []gopacket.SerializableLayer) (int64, error) {
func Rate(flow *otg.Flow, hdrs []gopacket.SerializableLayer) (uint64, error) {
if flowT := flow.GetRate().GetChoice(); flowT != otg.FlowRate_Choice_pps && flowT != otg.FlowRate_Choice_unspecified {
return 0, fmt.Errorf("unsupported flow rate specification, %v", flowT)
}
Expand Down
24 changes: 18 additions & 6 deletions flows/common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func TestPorts(t *testing.T) {
TxRx: &otg.FlowTxRx{
Choice: &portValue,
Port: &otg.FlowPort{
TxName: "port1",
RxName: proto.String("port2"),
TxName: "port1",
RxNames: []string{"port2"},
},
},
},
Expand All @@ -45,8 +45,8 @@ func TestPorts(t *testing.T) {
TxRx: &otg.FlowTxRx{
Choice: &portValue,
Port: &otg.FlowPort{
TxName: "port1",
RxName: proto.String("port2"),
TxName: "port1",
RxNames: []string{"port2"},
},
},
},
Expand All @@ -59,6 +59,18 @@ func TestPorts(t *testing.T) {
}},
wantTx: "eth0",
wantRx: "eth1",
}, {
desc: "multiple rx ports",
inFlow: &otg.Flow{
TxRx: &otg.FlowTxRx{
Choice: &portValue,
Port: &otg.FlowPort{
TxName: "port1",
RxNames: []string{"port1", "port2"},
},
},
},
wantErr: true,
}}

for _, tt := range tests {
Expand All @@ -85,7 +97,7 @@ func TestRate(t *testing.T) {
desc string
inFlow *otg.Flow
inHeaders []gopacket.SerializableLayer
wantPPS int64
wantPPS uint64
wantErr bool
}{{
desc: "invalid specification",
Expand All @@ -104,7 +116,7 @@ func TestRate(t *testing.T) {
inFlow: &otg.Flow{
Rate: &otg.FlowRate{
Choice: &ratePPS,
Pps: proto.Int64(1234),
Pps: proto.Uint64(1234),
},
},
wantPPS: 1234,
Expand Down
76 changes: 38 additions & 38 deletions flows/mpls/mpls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,15 @@ func TestHeaders(t *testing.T) {
Mpls: &otg.FlowMpls{
Label: &otg.PatternFlowMplsLabel{
Choice: &mplsLabelValue,
Value: proto.Int32(42),
Value: proto.Uint32(42),
},
TimeToLive: &otg.PatternFlowMplsTimeToLive{
Choice: &mplsTTLValue,
Value: proto.Int32(2),
Value: proto.Uint32(2),
},
BottomOfStack: &otg.PatternFlowMplsBottomOfStack{
Choice: &mplsBOSValue,
Value: proto.Int32(1),
Value: proto.Uint32(1),
},
},
}},
Expand Down Expand Up @@ -257,7 +257,7 @@ func TestHeaders(t *testing.T) {
Mpls: &otg.FlowMpls{
Label: &otg.PatternFlowMplsLabel{
Choice: &mplsLabelValue,
Value: proto.Int32(42),
Value: proto.Uint32(42),
},
TimeToLive: &otg.PatternFlowMplsTimeToLive{
Choice: &mplsTTLValues,
Expand Down Expand Up @@ -286,11 +286,11 @@ func TestHeaders(t *testing.T) {
Mpls: &otg.FlowMpls{
Label: &otg.PatternFlowMplsLabel{
Choice: &mplsLabelValue,
Value: proto.Int32(42),
Value: proto.Uint32(42),
},
TimeToLive: &otg.PatternFlowMplsTimeToLive{
Choice: &mplsTTLValue,
Value: proto.Int32(2),
Value: proto.Uint32(2),
},
BottomOfStack: &otg.PatternFlowMplsBottomOfStack{
Choice: &mplsBOSValues,
Expand Down Expand Up @@ -319,27 +319,27 @@ func TestHeaders(t *testing.T) {
Mpls: &otg.FlowMpls{
Label: &otg.PatternFlowMplsLabel{
Choice: &mplsLabelValue,
Value: proto.Int32(42),
Value: proto.Uint32(42),
},
TimeToLive: &otg.PatternFlowMplsTimeToLive{
Choice: &mplsTTLValue,
Value: proto.Int32(2),
Value: proto.Uint32(2),
},
BottomOfStack: &otg.PatternFlowMplsBottomOfStack{
Choice: &mplsBOSValue,
Value: proto.Int32(0),
Value: proto.Uint32(0),
},
},
}, {
Choice: &mplsChoice,
Mpls: &otg.FlowMpls{
Label: &otg.PatternFlowMplsLabel{
Choice: &mplsLabelValue,
Value: proto.Int32(84),
Value: proto.Uint32(84),
},
BottomOfStack: &otg.PatternFlowMplsBottomOfStack{
Choice: &mplsBOSValue,
Value: proto.Int32(1),
Value: proto.Uint32(1),
},
},
}},
Expand Down Expand Up @@ -381,15 +381,15 @@ func TestHeaders(t *testing.T) {
Mpls: &otg.FlowMpls{
Label: &otg.PatternFlowMplsLabel{
Choice: &mplsLabelValue,
Value: proto.Int32(42),
Value: proto.Uint32(42),
},
TimeToLive: &otg.PatternFlowMplsTimeToLive{
Choice: &mplsTTLValue,
Value: proto.Int32(2),
Value: proto.Uint32(2),
},
BottomOfStack: &otg.PatternFlowMplsBottomOfStack{
Choice: &mplsBOSValue,
Value: proto.Int32(1),
Value: proto.Uint32(1),
},
},
}, {
Expand All @@ -405,7 +405,7 @@ func TestHeaders(t *testing.T) {
},
Version: &otg.PatternFlowIpv4Version{
Choice: &ipVersionValue,
Value: proto.Int32(4),
Value: proto.Uint32(4),
},
},
}},
Expand Down Expand Up @@ -447,15 +447,15 @@ func TestHeaders(t *testing.T) {
Mpls: &otg.FlowMpls{
Label: &otg.PatternFlowMplsLabel{
Choice: &mplsLabelValue,
Value: proto.Int32(42),
Value: proto.Uint32(42),
},
TimeToLive: &otg.PatternFlowMplsTimeToLive{
Choice: &mplsTTLValue,
Value: proto.Int32(2),
Value: proto.Uint32(2),
},
BottomOfStack: &otg.PatternFlowMplsBottomOfStack{
Choice: &mplsBOSValue,
Value: proto.Int32(1),
Value: proto.Uint32(1),
},
},
}, {
Expand All @@ -470,7 +470,7 @@ func TestHeaders(t *testing.T) {
},
Version: &otg.PatternFlowIpv4Version{
Choice: &ipVersionValue,
Value: proto.Int32(4),
Value: proto.Uint32(4),
},
},
}},
Expand All @@ -496,15 +496,15 @@ func TestHeaders(t *testing.T) {
Mpls: &otg.FlowMpls{
Label: &otg.PatternFlowMplsLabel{
Choice: &mplsLabelValue,
Value: proto.Int32(42),
Value: proto.Uint32(42),
},
TimeToLive: &otg.PatternFlowMplsTimeToLive{
Choice: &mplsTTLValue,
Value: proto.Int32(2),
Value: proto.Uint32(2),
},
BottomOfStack: &otg.PatternFlowMplsBottomOfStack{
Choice: &mplsBOSValue,
Value: proto.Int32(1),
Value: proto.Uint32(1),
},
},
}, {
Expand All @@ -519,7 +519,7 @@ func TestHeaders(t *testing.T) {
},
Version: &otg.PatternFlowIpv4Version{
Choice: &ipVersionValue,
Value: proto.Int32(4),
Value: proto.Uint32(4),
},
},
}},
Expand All @@ -545,15 +545,15 @@ func TestHeaders(t *testing.T) {
Mpls: &otg.FlowMpls{
Label: &otg.PatternFlowMplsLabel{
Choice: &mplsLabelValue,
Value: proto.Int32(42),
Value: proto.Uint32(42),
},
TimeToLive: &otg.PatternFlowMplsTimeToLive{
Choice: &mplsTTLValue,
Value: proto.Int32(2),
Value: proto.Uint32(2),
},
BottomOfStack: &otg.PatternFlowMplsBottomOfStack{
Choice: &mplsBOSValue,
Value: proto.Int32(1),
Value: proto.Uint32(1),
},
},
}, {
Expand Down Expand Up @@ -594,15 +594,15 @@ func TestHeaders(t *testing.T) {
Mpls: &otg.FlowMpls{
Label: &otg.PatternFlowMplsLabel{
Choice: &mplsLabelValue,
Value: proto.Int32(42),
Value: proto.Uint32(42),
},
TimeToLive: &otg.PatternFlowMplsTimeToLive{
Choice: &mplsTTLValue,
Value: proto.Int32(2),
Value: proto.Uint32(2),
},
BottomOfStack: &otg.PatternFlowMplsBottomOfStack{
Choice: &mplsBOSValue,
Value: proto.Int32(1),
Value: proto.Uint32(1),
},
},
}, {
Expand All @@ -618,7 +618,7 @@ func TestHeaders(t *testing.T) {
},
Version: &otg.PatternFlowIpv4Version{
Choice: &ipVersionValue,
Value: proto.Int32(42),
Value: proto.Uint32(42),
},
},
}},
Expand Down Expand Up @@ -1545,15 +1545,15 @@ func TestDecode(t *testing.T) {
Mpls: &otg.FlowMpls{
Label: &otg.PatternFlowMplsLabel{
Choice: &mplsLabelValue,
Value: proto.Int32(42),
Value: proto.Uint32(42),
},
TimeToLive: &otg.PatternFlowMplsTimeToLive{
Choice: &mplsTTLValue,
Value: proto.Int32(2),
Value: proto.Uint32(2),
},
BottomOfStack: &otg.PatternFlowMplsBottomOfStack{
Choice: &mplsBOSValue,
Value: proto.Int32(1),
Value: proto.Uint32(1),
},
},
}, {
Expand All @@ -1569,7 +1569,7 @@ func TestDecode(t *testing.T) {
},
Version: &otg.PatternFlowIpv4Version{
Choice: &ipVersionValue,
Value: proto.Int32(4),
Value: proto.Uint32(4),
},
},
}},
Expand All @@ -1596,15 +1596,15 @@ func TestDecode(t *testing.T) {
Mpls: &otg.FlowMpls{
Label: &otg.PatternFlowMplsLabel{
Choice: &mplsLabelValue,
Value: proto.Int32(42),
Value: proto.Uint32(42),
},
TimeToLive: &otg.PatternFlowMplsTimeToLive{
Choice: &mplsTTLValue,
Value: proto.Int32(2),
Value: proto.Uint32(2),
},
BottomOfStack: &otg.PatternFlowMplsBottomOfStack{
Choice: &mplsBOSValue,
Value: proto.Int32(1),
Value: proto.Uint32(1),
},
},
}, {
Expand All @@ -1620,7 +1620,7 @@ func TestDecode(t *testing.T) {
},
Version: &otg.PatternFlowIpv4Version{
Choice: &ipVersionValue,
Value: proto.Int32(4),
Value: proto.Uint32(4),
},
},
}},
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/golang/glog v1.1.1
github.com/google/go-cmp v0.5.9
github.com/google/gopacket v1.1.19
github.com/open-traffic-generator/snappi/gosnappi v0.11.15
github.com/open-traffic-generator/snappi/gosnappi v0.12.1
github.com/openconfig/featureprofiles v0.0.0-20230629171650-1057c66c4e52
github.com/openconfig/gnmi v0.10.0
github.com/openconfig/goyang v1.4.0
Expand Down
Loading
Loading