-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add segment,pipeline, replica and resourcegroup api for WebUI
Signed-off-by: jaime <[email protected]>
- Loading branch information
Showing
24 changed files
with
987 additions
and
48 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
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,99 @@ | ||
package meta | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb" | ||
"github.com/milvus-io/milvus/internal/proto/datapb" | ||
"github.com/milvus-io/milvus/internal/proto/querypb" | ||
"github.com/milvus-io/milvus/pkg/util/metricsinfo" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetDistributionJSON(t *testing.T) { | ||
// Initialize DistributionManager | ||
manager := NewDistributionManager() | ||
|
||
// Add some segments to the SegmentDistManager | ||
segment1 := SegmentFromInfo(&datapb.SegmentInfo{ | ||
ID: 1, | ||
CollectionID: 100, | ||
PartitionID: 10, | ||
InsertChannel: "channel-1", | ||
NumOfRows: 1000, | ||
State: commonpb.SegmentState_Flushed, | ||
}) | ||
segment1.Node = 1 | ||
segment1.Version = 1 | ||
|
||
segment2 := SegmentFromInfo(&datapb.SegmentInfo{ | ||
ID: 2, | ||
CollectionID: 200, | ||
PartitionID: 20, | ||
InsertChannel: "channel-2", | ||
NumOfRows: 2000, | ||
State: commonpb.SegmentState_Flushed, | ||
}) | ||
segment2.Node = 2 | ||
segment2.Version = 1 | ||
|
||
manager.SegmentDistManager.Update(1, segment1) | ||
manager.SegmentDistManager.Update(2, segment2) | ||
|
||
// Add some channels to the ChannelDistManager | ||
channel1 := DmChannelFromVChannel(&datapb.VchannelInfo{ | ||
CollectionID: 100, | ||
ChannelName: "channel-1", | ||
}) | ||
channel1.Node = 1 | ||
channel1.Version = 1 | ||
|
||
channel2 := DmChannelFromVChannel(&datapb.VchannelInfo{ | ||
CollectionID: 200, | ||
ChannelName: "channel-2", | ||
}) | ||
channel2.Node = 2 | ||
channel2.Version = 1 | ||
|
||
manager.ChannelDistManager.Update(1, channel1) | ||
manager.ChannelDistManager.Update(2, channel2) | ||
|
||
// Add some leader views to the LeaderViewManager | ||
leaderView1 := &LeaderView{ | ||
ID: 1, | ||
CollectionID: 100, | ||
Channel: "channel-1", | ||
Version: 1, | ||
Segments: map[int64]*querypb.SegmentDist{1: {NodeID: 1}}, | ||
} | ||
|
||
leaderView2 := &LeaderView{ | ||
ID: 2, | ||
CollectionID: 200, | ||
Channel: "channel-2", | ||
Version: 1, | ||
Segments: map[int64]*querypb.SegmentDist{2: {NodeID: 2}}, | ||
} | ||
|
||
manager.LeaderViewManager.Update(1, leaderView1) | ||
manager.LeaderViewManager.Update(2, leaderView2) | ||
|
||
// Call GetDistributionJSON | ||
jsonOutput := manager.GetDistributionJSON() | ||
|
||
// Verify JSON output | ||
var dist metricsinfo.QueryCoordCollectionDistribution | ||
err := json.Unmarshal([]byte(jsonOutput), &dist) | ||
assert.NoError(t, err) | ||
assert.Len(t, dist.Segments, 2) | ||
assert.Len(t, dist.DMChannels, 2) | ||
assert.Len(t, dist.LeaderViews, 2) | ||
|
||
assert.Equal(t, int64(1), dist.Segments[0].SegmentID) | ||
assert.Equal(t, int64(2), dist.Segments[1].SegmentID) | ||
assert.Equal(t, "channel-1", dist.DMChannels[0].ChannelName) | ||
assert.Equal(t, "channel-2", dist.DMChannels[1].ChannelName) | ||
assert.Equal(t, int64(1), dist.LeaderViews[0].LeaderID) | ||
assert.Equal(t, int64(2), dist.LeaderViews[1].LeaderID) | ||
} |
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
Oops, something went wrong.