Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a seal policy which restrict the lifetime of a segment (#7172)
issue: #7164 Signed-off-by: sunby <bingyi.sun@zilliz.com>
- Loading branch information
sunby
committed
Aug 20, 2021
1 parent
9b7c782
commit 6e34f4c
Showing
4 changed files
with
53 additions
and
23 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
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,35 @@ | ||
package datacoord | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/milvus-io/milvus/internal/proto/datapb" | ||
"github.com/milvus-io/milvus/internal/util/tsoutil" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestSealSegmentPolicy(t *testing.T) { | ||
t.Run("test seal segment by lifetime", func(t *testing.T) { | ||
lifetime := 2 * time.Second | ||
now := time.Now() | ||
curTS := now.UnixNano() / int64(time.Millisecond) | ||
nosealTs := (now.Add(lifetime / 2)).UnixNano() / int64(time.Millisecond) | ||
sealTs := (now.Add(lifetime)).UnixNano() / int64(time.Millisecond) | ||
|
||
p := sealByLifetimePolicy(lifetime) | ||
|
||
segment := &SegmentInfo{ | ||
SegmentInfo: &datapb.SegmentInfo{ | ||
ID: 1, | ||
LastExpireTime: tsoutil.ComposeTS(curTS, 0), | ||
}, | ||
} | ||
|
||
shouldSeal := p(segment, tsoutil.ComposeTS(nosealTs, 0)) | ||
assert.False(t, shouldSeal) | ||
|
||
shouldSeal = p(segment, tsoutil.ComposeTS(sealTs, 0)) | ||
assert.True(t, shouldSeal) | ||
}) | ||
} |
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