forked from contiv/ofnet
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Add test case to check the order of Multipart Reply message 2. Fix an issue in IPv6 PacketIn test Signed-off-by: wenying <[email protected]>
- Loading branch information
Showing
5 changed files
with
74 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v0.2.2 | ||
v0.2.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// #nosec G404: random number generator not used for security purposes | ||
package ofctrl | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"antrea.io/libOpenflow/openflow13" | ||
) | ||
|
||
type multipartActor struct { | ||
*OfActor | ||
expectedTxs map[uint32]chan *openflow13.MultipartReply | ||
} | ||
|
||
func (o *multipartActor) MultipartReply(sw *OFSwitch, rep *openflow13.MultipartReply) { | ||
if ch, found := o.expectedTxs[rep.Xid]; found { | ||
ch <- rep | ||
} | ||
} | ||
func TestMultipartReply(t *testing.T) { | ||
app := new(multipartActor) | ||
app.OfActor = new(OfActor) | ||
app.expectedTxs = make(map[uint32]chan *openflow13.MultipartReply) | ||
ctrl := NewController(app) | ||
brName := "brMultipart" | ||
ovsBr := prepareControllerAndSwitch(t, app.OfActor, ctrl, brName) | ||
defer func() { | ||
assert.Nilf(t, ovsBr.DeleteBridge(brName), "Failed to delete br %s", brName) | ||
ctrl.Delete() | ||
}() | ||
testTableFeatures(t, app) | ||
} | ||
|
||
func testTableFeatures(t *testing.T, app *multipartActor) { | ||
app.Switch.EnableMonitor() | ||
ofSwitch := app.Switch | ||
mpartRequest := &openflow13.MultipartRequest{ | ||
Header: openflow13.NewOfp13Header(), | ||
Type: openflow13.MultipartType_TableFeatures, | ||
Flags: 0, | ||
} | ||
mpartRequest.Header.Type = openflow13.Type_MultiPartRequest | ||
mpartRequest.Header.Length = mpartRequest.Len() | ||
ch := make(chan *openflow13.MultipartReply) | ||
xid := mpartRequest.Xid | ||
app.expectedTxs[xid] = ch | ||
ofSwitch.Send(mpartRequest) | ||
|
||
getTableCount := func() int { | ||
tableCount := 0 | ||
for rep := range ch { | ||
flags := rep.Flags | ||
tableLen := len(rep.Body) | ||
tableCount += tableLen | ||
if flags == 0 { | ||
break | ||
} | ||
} | ||
return tableCount | ||
} | ||
tableCount := getTableCount() | ||
assert.Equal(t, 254, tableCount) | ||
delete(app.expectedTxs, xid) | ||
close(ch) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters