Skip to content

Commit

Permalink
Do not use AddRecordV3
Browse files Browse the repository at this point in the history
Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>
  • Loading branch information
antoninbas committed Jan 2, 2025
1 parent 23e9bd0 commit 0984369
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/flowaggregator/exporter/ipfix.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (e *IPFIXExporter) sendRecord(record ipfixentities.Record, isRecordIPv6 boo
if err := e.set.PrepareSet(ipfixentities.Data, templateID); err != nil {
return err
}
if err := e.set.AddRecordV3(record); err != nil {
if err := e.set.AddRecordV2(record.GetOrderedElementList(), templateID); err != nil {
return err
}
sentBytes, err := e.exportingProcess.SendSet(e.set)
Expand Down
11 changes: 7 additions & 4 deletions pkg/flowaggregator/exporter/ipfix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ func TestIPFIXExporter_UpdateOptions(t *testing.T) {
setCount := 0
mockSet.EXPECT().ResetSet().Times(2)
mockSet.EXPECT().PrepareSet(gomock.Any(), testTemplateID).Return(nil).Times(2)
mockSet.EXPECT().AddRecordV3(mockRecord).Return(nil).Times(2)
mockRecord.EXPECT().GetOrderedElementList().Return(nil).Times(2)
mockSet.EXPECT().AddRecordV2(gomock.Any(), testTemplateID).Return(nil).Times(2)
mockIPFIXExpProc.EXPECT().SendSet(mockSet).Do(func(set interface{}) {
setCount += 1
}).Return(0, nil).Times(2)
Expand Down Expand Up @@ -165,7 +166,7 @@ func TestIPFIXExporter_UpdateOptions(t *testing.T) {
assert.Equal(t, 2, setCount, "Invalid number of flow sets sent by exporter")
}

func TestIPFIXExporter_AddRecord(t *testing.T) {
func TestIPFIXExporter_AddRecordV2(t *testing.T) {
ctrl := gomock.NewController(t)

mockIPFIXExpProc := ipfixtesting.NewMockIPFIXExportingProcess(ctrl)
Expand Down Expand Up @@ -193,7 +194,8 @@ func TestIPFIXExporter_AddRecord(t *testing.T) {

mockSet.EXPECT().ResetSet()
mockSet.EXPECT().PrepareSet(gomock.Any(), testTemplateID).Return(nil)
mockSet.EXPECT().AddRecordV3(mockRecord).Return(nil)
mockRecord.EXPECT().GetOrderedElementList().Return(nil)
mockSet.EXPECT().AddRecordV2(gomock.Any(), testTemplateID).Return(nil)
mockIPFIXExpProc.EXPECT().SendSet(mockSet).Return(0, nil)

assert.NoError(t, ipfixExporter.AddRecord(mockRecord, false))
Expand Down Expand Up @@ -242,7 +244,8 @@ func TestIPFIXExporter_sendRecord_Error(t *testing.T) {

mockSet.EXPECT().ResetSet()
mockSet.EXPECT().PrepareSet(gomock.Any(), testTemplateID).Return(nil)
mockSet.EXPECT().AddRecordV3(mockRecord).Return(nil)
mockRecord.EXPECT().GetOrderedElementList().Return(nil)
mockSet.EXPECT().AddRecordV2(gomock.Any(), testTemplateID).Return(nil)
mockIPFIXExpProc.EXPECT().SendSet(mockSet).Return(0, fmt.Errorf("send error"))
mockIPFIXExpProc.EXPECT().CloseConnToCollector()

Expand Down

0 comments on commit 0984369

Please sign in to comment.