mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-30 10:59:32 +08:00
c725416288
issue: #33285 - move streaming related proto into pkg. - add v2 message type and change flush message into v2 message. Signed-off-by: chyezh <chyezh@outlook.com>
60 lines
2.6 KiB
Go
60 lines
2.6 KiB
Go
package status
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/milvus-io/milvus/pkg/streaming/proto/streamingpb"
|
|
)
|
|
|
|
func TestStreamingError(t *testing.T) {
|
|
streamingErr := NewOnShutdownError("test")
|
|
assert.Contains(t, streamingErr.Error(), "code: STREAMING_CODE_ON_SHUTDOWN, cause: test")
|
|
assert.False(t, streamingErr.IsWrongStreamingNode())
|
|
pbErr := streamingErr.AsPBError()
|
|
assert.Equal(t, streamingpb.StreamingCode_STREAMING_CODE_ON_SHUTDOWN, pbErr.Code)
|
|
|
|
streamingErr = NewUnknownError("test")
|
|
assert.Contains(t, streamingErr.Error(), "code: STREAMING_CODE_UNKNOWN, cause: test")
|
|
assert.False(t, streamingErr.IsWrongStreamingNode())
|
|
pbErr = streamingErr.AsPBError()
|
|
assert.Equal(t, streamingpb.StreamingCode_STREAMING_CODE_UNKNOWN, pbErr.Code)
|
|
|
|
streamingErr = NewInvalidRequestSeq("test")
|
|
assert.Contains(t, streamingErr.Error(), "code: STREAMING_CODE_INVALID_REQUEST_SEQ, cause: test")
|
|
assert.False(t, streamingErr.IsWrongStreamingNode())
|
|
pbErr = streamingErr.AsPBError()
|
|
assert.Equal(t, streamingpb.StreamingCode_STREAMING_CODE_INVALID_REQUEST_SEQ, pbErr.Code)
|
|
|
|
streamingErr = NewChannelNotExist("test")
|
|
assert.Contains(t, streamingErr.Error(), "code: STREAMING_CODE_CHANNEL_NOT_EXIST, cause: test")
|
|
assert.True(t, streamingErr.IsWrongStreamingNode())
|
|
pbErr = streamingErr.AsPBError()
|
|
assert.Equal(t, streamingpb.StreamingCode_STREAMING_CODE_CHANNEL_NOT_EXIST, pbErr.Code)
|
|
|
|
streamingErr = NewUnmatchedChannelTerm("test", 1, 2)
|
|
assert.Contains(t, streamingErr.Error(), "code: STREAMING_CODE_UNMATCHED_CHANNEL_TERM, cause: channel test")
|
|
assert.True(t, streamingErr.IsWrongStreamingNode())
|
|
pbErr = streamingErr.AsPBError()
|
|
assert.Equal(t, streamingpb.StreamingCode_STREAMING_CODE_UNMATCHED_CHANNEL_TERM, pbErr.Code)
|
|
|
|
streamingErr = NewIgnoreOperation("test")
|
|
assert.Contains(t, streamingErr.Error(), "code: STREAMING_CODE_IGNORED_OPERATION, cause: test")
|
|
assert.False(t, streamingErr.IsWrongStreamingNode())
|
|
pbErr = streamingErr.AsPBError()
|
|
assert.Equal(t, streamingpb.StreamingCode_STREAMING_CODE_IGNORED_OPERATION, pbErr.Code)
|
|
|
|
streamingErr = NewInner("test")
|
|
assert.Contains(t, streamingErr.Error(), "code: STREAMING_CODE_INNER, cause: test")
|
|
assert.False(t, streamingErr.IsWrongStreamingNode())
|
|
pbErr = streamingErr.AsPBError()
|
|
assert.Equal(t, streamingpb.StreamingCode_STREAMING_CODE_INNER, pbErr.Code)
|
|
|
|
streamingErr = NewOnShutdownError("test, %d", 1)
|
|
assert.Contains(t, streamingErr.Error(), "code: STREAMING_CODE_ON_SHUTDOWN, cause: test, 1")
|
|
assert.False(t, streamingErr.IsWrongStreamingNode())
|
|
pbErr = streamingErr.AsPBError()
|
|
assert.Equal(t, streamingpb.StreamingCode_STREAMING_CODE_ON_SHUTDOWN, pbErr.Code)
|
|
}
|