fix unexpected metrics value cause by wrong time unit (#25240)

Signed-off-by: Wei Liu <wei.liu@zilliz.com>
pull/25360/head
wei liu 2023-07-06 08:48:27 +08:00 committed by GitHub
parent c84496a1ba
commit 71d99d4ec2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 2821 additions and 1 deletions

View File

@ -359,6 +359,7 @@ generate-mockery: getdeps
# internal/datacoord
$(PWD)/bin/mockery --dir=internal/datacoord --name=compactionPlanContext --filename=mock_compaction_plan_context.go --output=internal/datacoord --structname=MockCompactionPlanContext --with-expecter --inpackage
$(PWD)/bin/mockery --dir=internal/datacoord --name=Handler --filename=mock_handler.go --output=internal/datacoord --structname=NMockHandler --with-expecter --inpackage
$(PWD)/bin/mockery --name=DataCoordComponent --dir=$(PWD)/internal/types --output=$(PWD)/internal/types --filename=mock_datacoord.go --with-expecter --structname=MockDataCoord --outpkg=types --inpackage
#internal/proxy
$(PWD)/bin/mockery --name=LBPolicy --dir=$(PWD)/internal/proxy --output=$(PWD)/internal/proxy --filename=mock_lb_policy.go --structname=MockLBPolicy --with-expecter --outpkg=proxy --inpackage
$(PWD)/bin/mockery --name=LBBalancer --dir=$(PWD)/internal/proxy --output=$(PWD)/internal/proxy --filename=mock_lb_balancer.go --structname=MockLBBalancer --with-expecter --outpkg=proxy --inpackage

View File

@ -66,7 +66,7 @@ func (m *timeTickSender) start(ctx context.Context) {
log.Info("timeTickSender context done")
return
case t := <-ticker.C:
m.sendReport(ctx, uint64(t.Unix()))
m.sendReport(ctx, uint64(t.UnixMilli()))
}
}
}

View File

@ -22,8 +22,12 @@ import (
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"go.uber.org/atomic"
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
"github.com/milvus-io/milvus/internal/proto/datapb"
"github.com/milvus-io/milvus/internal/types"
)
func TestTimetickManagerNormal(t *testing.T) {
@ -159,3 +163,25 @@ func TestTimetickManagerSendNotSuccess(t *testing.T) {
err := manager.sendReport(ctx, 100)
assert.Error(t, err)
}
func TestTimetickManagerSendReport(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
mockDataCoord := types.NewMockDataCoord(t)
tsInMill := time.Now().UnixMilli()
validTs := atomic.NewBool(false)
mockDataCoord.EXPECT().ReportDataNodeTtMsgs(mock.Anything, mock.Anything).Run(func(ctx context.Context, req *datapb.ReportDataNodeTtMsgsRequest) {
if req.GetBase().Timestamp > uint64(tsInMill) {
validTs.Store(true)
}
}).Return(&commonpb.Status{
ErrorCode: commonpb.ErrorCode_Success,
}, nil)
manager := newTimeTickManager(mockDataCoord, 0)
go manager.start(ctx)
assert.Eventually(t, func() bool {
return validTs.Load()
}, 2*time.Second, 500*time.Millisecond)
}

File diff suppressed because it is too large Load Diff