Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: update case for resource group declarative api #850

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions test/base/milvus_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,9 @@ func (mc *MilvusClient) ListResourceGroups(ctx context.Context) ([]string, error
}

// CreateResourceGroup
func (mc *MilvusClient) CreateResourceGroup(ctx context.Context, rgName string) error {
func (mc *MilvusClient) CreateResourceGroup(ctx context.Context, rgName string, opts ...client.CreateResourceGroupOption) error {
preRequest("CreateResourceGroup", ctx, rgName)
err := mc.mClient.CreateResourceGroup(ctx, rgName)
err := mc.mClient.CreateResourceGroup(ctx, rgName, opts...)
postResponse("CreateResourceGroup", err)
return err
}
Expand All @@ -624,6 +624,14 @@ func (mc *MilvusClient) DropResourceGroup(ctx context.Context, rgName string) er
return err
}

// UpdateResourceGroups drop resource group
func (mc *MilvusClient) UpdateResourceGroups(ctx context.Context, opt ...client.UpdateResourceGroupsOption) error {
preRequest("UpdateResourceGroups", ctx, opt)
err := mc.mClient.UpdateResourceGroups(ctx, opt...)
postResponse("UpdateResourceGroups", err)
return err
}

// TransferNode transfer node
func (mc *MilvusClient) TransferNode(ctx context.Context, sourceRg, targetRg string, nodesNum int32) error {
preRequest("TransferNode", ctx, sourceRg, targetRg, nodesNum)
Expand Down
59 changes: 53 additions & 6 deletions test/common/response_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ func CheckNotContainsCollection(t *testing.T, collections []*entity.Collection,
}

// CheckInsertResult check insert result, ids len (insert count), ids data (pks, but no auto ids)
func CheckInsertResult(t *testing.T, actualIds entity.Column, expIds entity.Column) {
require.Equal(t, actualIds.Len(), expIds.Len())
switch expIds.Type() {
func CheckInsertResult(t *testing.T, actualIDs entity.Column, expIDs entity.Column) {
require.Equal(t, actualIDs.Len(), expIDs.Len())
switch expIDs.Type() {
// pk field support int64 and varchar type
case entity.FieldTypeInt64:
require.ElementsMatch(t, actualIds.(*entity.ColumnInt64).Data(), expIds.(*entity.ColumnInt64).Data())
require.ElementsMatch(t, actualIDs.(*entity.ColumnInt64).Data(), expIDs.(*entity.ColumnInt64).Data())
case entity.FieldTypeVarChar:
require.ElementsMatch(t, actualIds.(*entity.ColumnVarChar).Data(), expIds.(*entity.ColumnVarChar).Data())
require.ElementsMatch(t, actualIDs.(*entity.ColumnVarChar).Data(), expIDs.(*entity.ColumnVarChar).Data())
default:
log.Printf("The primary field only support type: [%v, %v]", entity.FieldTypeInt64, entity.FieldTypeVarChar)
}
Expand Down Expand Up @@ -322,8 +322,55 @@ func CheckPersistentSegments(t *testing.T, actualSegments []*entity.Segment, exp
require.Equal(t, actualNb, expNb)
}

func CheckTransfer(t *testing.T, actualRgs []*entity.ResourceGroupTransfer, expRgs []*entity.ResourceGroupTransfer) {
if len(expRgs) == 0 {
require.Len(t, actualRgs, 0)
} else {
_expRgs := make([]string, 0, len(expRgs))
_actualRgs := make([]string, 0, len(actualRgs))
for _, rg := range expRgs {
_expRgs = append(_expRgs, rg.ResourceGroup)
}
for _, rg := range actualRgs {
_actualRgs = append(_actualRgs, rg.ResourceGroup)
}
require.ElementsMatch(t, _expRgs, _actualRgs)
}

}

func checkResourceGroupConfig(t *testing.T, actualConfig *entity.ResourceGroupConfig, expConfig *entity.ResourceGroupConfig) {
if expConfig.Requests != nil {
require.EqualValuesf(t, expConfig.Requests.NodeNum, actualConfig.Requests.NodeNum, "Requests.NodeNum mismatch")
}

if expConfig.Limits != nil {
require.EqualValuesf(t, expConfig.Limits.NodeNum, actualConfig.Limits.NodeNum, "Limits.NodeNum mismatch")
}

if expConfig.TransferFrom != nil {
CheckTransfer(t, expConfig.TransferFrom, actualConfig.TransferFrom)
}

if expConfig.TransferTo != nil {
CheckTransfer(t, expConfig.TransferTo, actualConfig.TransferTo)
}
}

func CheckResourceGroup(t *testing.T, actualRg *entity.ResourceGroup, expRg *entity.ResourceGroup) {
require.EqualValues(t, expRg, actualRg)
require.EqualValues(t, expRg.Name, actualRg.Name, "ResourceGroup name mismatch")
require.EqualValues(t, expRg.Capacity, actualRg.Capacity, "ResourceGroup capacity mismatch")
if expRg.AvailableNodesNumber >= 0 {
require.EqualValues(t, expRg.AvailableNodesNumber, len(actualRg.Nodes), "AvailableNodesNumber mismatch")
}

if expRg.Config != nil {
checkResourceGroupConfig(t, actualRg.Config, expRg.Config)
}

if expRg.Nodes != nil {
require.EqualValues(t, len(expRg.Nodes), len(actualRg.Nodes), "Nodes count mismatch")
}
}

func getDbNames(dbs []entity.Database) []string {
Expand Down
2 changes: 1 addition & 1 deletion test/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ var InvalidExpressions = []InvalidExprStruct{
// {Expr: fmt.Sprintf("json_contains_aby (%s['list'], 2)", DefaultJSONFieldName), ErrNil: false, ErrMsg: "invalid expression: json_contains_aby"},
// {Expr: fmt.Sprintf("json_contains_aby (%s['list'], 2)", DefaultJSONFieldName), ErrNil: false, ErrMsg: "invalid expression: json_contains_aby"},
{Expr: fmt.Sprintf("%s[-1] > %d", DefaultInt8ArrayField, TestCapacity), ErrNil: false, ErrMsg: "cannot parse expression"}, // array[-1] >
{Expr: fmt.Sprintf(fmt.Sprintf("%s[-1] > 1", DefaultJSONFieldName)), ErrNil: false, ErrMsg: "invalid expression"}, // json[-1] >
{Expr: fmt.Sprintf("%s[-1] > 1", DefaultJSONFieldName), ErrNil: false, ErrMsg: "invalid expression"}, // json[-1] >
}

func GenBatchSizes(limit int, batch int) []int {
Expand Down
6 changes: 3 additions & 3 deletions test/testcases/configure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ func TestCompactAfterDelete(t *testing.T) {
errFlush := mc.Flush(ctx, collName, false)
common.CheckErr(t, errFlush, true)

segments, _ := mc.GetPersistentSegmentInfo(ctx, collName)
require.Len(t, segments, 1)

// index
indexHnsw, _ := entity.NewIndexHNSW(entity.L2, 8, 96)
err := mc.CreateIndex(ctx, collName, common.DefaultFloatVecFieldName, indexHnsw, false)
common.CheckErr(t, err, true)

segments, _ := mc.GetPersistentSegmentInfo(ctx, collName)
require.Len(t, segments, 1)

// delete half ids
deleteIds := ids.Slice(0, common.DefaultNb/2)
errDelete := mc.DeleteByPks(ctx, collName, "", deleteIds)
Expand Down
2 changes: 1 addition & 1 deletion test/testcases/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func TestDeletePartitionIdsNotMatch(t *testing.T) {
partitionName, vecColumnDefault, _ := createInsertTwoPartitions(ctx, t, mc, collName, common.DefaultNb)

// delete [0:10) from new partition -> delete nothing
deleteIds := vecColumnDefault.IdsColumn.Slice(0, 10)
deleteIds := vecColumnDefault.IDsColumn.Slice(0, 10)
errDelete := mc.DeleteByPks(ctx, collName, partitionName, deleteIds)
common.CheckErr(t, errDelete, true)

Expand Down
8 changes: 4 additions & 4 deletions test/testcases/insert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,9 @@ func TestInsertRepeatedDynamicField(t *testing.T) {
}

type dataRows struct {
Int64 int64 `json:"int64" milvus:"name:int64"`
Float float32 `json:"float" milvus:"name:float"`
FloatVec []float32 `json:"floatVec" milvus:"name:floatVec"`
Int64 int64 `json:"int64" milvus:"name:int64"`
Float float32 `json:"float" milvus:"name:float"`
FloatVec []float32 `json:"floatVec" milvus:"name:floatVec"`
DynamicRows
}
rows := make([]interface{}, 0, 100)
Expand All @@ -450,7 +450,7 @@ func TestInsertRepeatedDynamicField(t *testing.T) {
Int64: int64(i),
Float: float32(i),
FloatVec: common.GenFloatVector(common.DefaultDim),
DynamicRows: DynamicRows{
DynamicRows: DynamicRows{
Float: 0.0,
},
}
Expand Down
4 changes: 2 additions & 2 deletions test/testcases/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,13 @@ func createInsertTwoPartitions(ctx context.Context, t *testing.T, mc *base.Milvu

defaultPartition = HelpPartitionColumns{
PartitionName: common.DefaultPartition,
IdsColumn: idsDefault,
IDsColumn: idsDefault,
VectorColumn: vecColumn,
}

newPartition = HelpPartitionColumns{
PartitionName: partitionName,
IdsColumn: idsPartition,
IDsColumn: idsPartition,
VectorColumn: vecColumnNew,
}

Expand Down
2 changes: 1 addition & 1 deletion test/testcases/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

type HelpPartitionColumns struct {
PartitionName string
IdsColumn entity.Column
IDsColumn entity.Column
VectorColumn entity.Column
}

Expand Down
Loading
Loading