Skip to content

Commit

Permalink
Address comments on UT
Browse files Browse the repository at this point in the history
Signed-off-by: heanlan <hanlan@vmware.com>
  • Loading branch information
heanlan committed Aug 30, 2022
1 parent 5146d3a commit d3a309c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/flowaggregator/s3uploader/s3uploader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/stretchr/testify/assert"
ipfixentitiestesting "github.com/vmware/go-ipfix/pkg/entities/testing"
"github.com/vmware/go-ipfix/pkg/registry"
"k8s.io/apimachinery/pkg/util/wait"

flowrecordtesting "antrea.io/antrea/pkg/flowaggregator/flowrecord/testing"
flowaggregatortesting "antrea.io/antrea/pkg/flowaggregator/testing"
Expand Down Expand Up @@ -162,7 +163,7 @@ func TestFlowRecordPeriodicCommit(t *testing.T) {
s3UploadProc := S3UploadProcess{
compress: false,
maxRecordPerFile: 10,
uploadInterval: 1 * time.Second,
uploadInterval: 100 * time.Millisecond,
currentBuffer: &bytes.Buffer{},
bufferQueue: make([]*bytes.Buffer, 0),
buffersToUpload: make([]*bytes.Buffer, 0, maxNumBuffersPendingUpload),
Expand All @@ -174,7 +175,13 @@ func TestFlowRecordPeriodicCommit(t *testing.T) {
s3UploadProc.cachedRecordCount = 1
s3UploadProc.startExportProcess()
// wait for ticker to tick
time.Sleep(1 * time.Second)
err := wait.PollImmediate(10*time.Millisecond, 200*time.Millisecond, func() (bool, error) {
if mockS3Uploader.testReader.Len() != 0 {
return true, nil
}
return false, nil
})
assert.NoErrorf(t, err, "time out while waiting for ticker to tick")
s3UploadProc.stopExportProcess(false)
assert.Equal(t, 0, len(s3UploadProc.bufferQueue))
assert.Equal(t, 0, len(s3UploadProc.buffersToUpload))
Expand Down

0 comments on commit d3a309c

Please sign in to comment.