mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-05 05:18:52 +08:00
bef06e5acf
issue: #33285 - register streaming coord service into datacoord. - add new streaming node role. - add global static switch to enable streaming service or not. Signed-off-by: chyezh <chyezh@outlook.com>
47 lines
1.5 KiB
Go
47 lines
1.5 KiB
Go
package componentutil
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
|
|
)
|
|
|
|
func TestComponentStateService(t *testing.T) {
|
|
ctx := context.Background()
|
|
s := NewComponentStateService("role")
|
|
resp, err := s.GetComponentStates(ctx, &milvuspb.GetComponentStatesRequest{})
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, commonpb.StateCode_StandBy, resp.State.StateCode)
|
|
|
|
s.OnInitializing()
|
|
resp, err = s.GetComponentStates(ctx, &milvuspb.GetComponentStatesRequest{})
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, commonpb.StateCode_Initializing, resp.State.StateCode)
|
|
|
|
s.OnInitialized(1)
|
|
resp, err = s.GetComponentStates(ctx, &milvuspb.GetComponentStatesRequest{})
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, commonpb.StateCode_Healthy, resp.State.StateCode)
|
|
assert.Equal(t, "role", resp.State.Role)
|
|
assert.Equal(t, int64(1), resp.State.NodeID)
|
|
|
|
s.OnAbnormal()
|
|
resp, err = s.GetComponentStates(ctx, &milvuspb.GetComponentStatesRequest{})
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, commonpb.StateCode_Abnormal, resp.State.StateCode)
|
|
|
|
s.OnHealthy()
|
|
resp, err = s.GetComponentStates(ctx, &milvuspb.GetComponentStatesRequest{})
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, commonpb.StateCode_Healthy, resp.State.StateCode)
|
|
|
|
s.OnStopping()
|
|
resp, err = s.GetComponentStates(ctx, &milvuspb.GetComponentStatesRequest{})
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, commonpb.StateCode_Stopping, resp.State.StateCode)
|
|
}
|