Fix LessOrEqualThan method of rocksmq (#18789)

Signed-off-by: yun.zhang <yun.zhang@zilliz.com>

Signed-off-by: yun.zhang <yun.zhang@zilliz.com>
This commit is contained in:
jaime 2022-08-23 16:56:52 +08:00 committed by GitHub
parent 5c4f854271
commit 909e46b6c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -124,9 +124,9 @@ func TestRmqClient_GetLatestMsg(t *testing.T) {
for {
select {
case <-ctx.Done():
ret, err := actualLastMsg.ID().LessOrEqualThan(expectLastMsg.Serialize())
ret, err := expectLastMsg.LessOrEqualThan(actualLastMsg.ID().Serialize())
assert.Nil(t, err)
assert.False(t, ret)
assert.True(t, ret)
return
case msg := <-consumer.Chan():
consumer.Ack(msg)

View File

@ -41,7 +41,7 @@ func (rid *rmqID) AtEarliestPosition() bool {
func (rid *rmqID) LessOrEqualThan(msgID []byte) (bool, error) {
rMsgID := DeserializeRmqID(msgID)
return rid.messageID < rMsgID, nil
return rid.messageID <= rMsgID, nil
}
func (rid *rmqID) Equal(msgID []byte) (bool, error) {

View File

@ -60,6 +60,10 @@ func TestLessOrEqualThan(t *testing.T) {
ret, err = rid2.LessOrEqualThan(rid1.Serialize())
assert.Nil(t, err)
assert.False(t, ret)
ret, err = rid1.LessOrEqualThan(rid1.Serialize())
assert.Nil(t, err)
assert.True(t, ret)
}
func Test_Equal(t *testing.T) {