mirror of
https://github.com/milvus-io/milvus.git
synced 2026-07-21 18:25:44 +00:00
## Summary - Add `GetCollectionName()` method to 12 RESTful API request types that were missing it - Ensures `ProxyFunctionCall` metrics report the correct collection name label for all RESTful endpoints - Affected types: `RenameCollectionReq`, `QueryReqV2`, `CollectionIDReq`, `CollectionFilterReq`, `CollectionDataReq`, `SearchReqV2`, `HybridSearchReq`, `PartitionsReq`, `GrantV2Req`, `IndexParamReq`, `CollectionReq`, `RunAnalyzerReq` issue: #48461 ## Test plan - [ ] Verify existing unit tests pass - [ ] Confirm RESTful API metrics now include collection name for search/query/hybrid_search endpoints 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: MrPresent-Han <chun.han@gmail.com> Co-authored-by: MrPresent-Han <chun.han@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
53 lines
2.0 KiB
Go
53 lines
2.0 KiB
Go
// Licensed to the LF AI & Data foundation under one
|
|
// or more contributor license agreements. See the NOTICE file
|
|
// distributed with this work for additional information
|
|
// regarding copyright ownership. The ASF licenses this file
|
|
// to you under the Apache License, Version 2.0 (the
|
|
// "License"); you may not use this file except in compliance
|
|
// with the License. You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package httpserver
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/milvus-io/milvus/pkg/v2/util/requestutil"
|
|
)
|
|
|
|
func TestRequestV2_GetCollectionName(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
req requestutil.CollectionNameGetter
|
|
want string
|
|
}{
|
|
{"RenameCollectionReq", &RenameCollectionReq{CollectionName: "col1"}, "col1"},
|
|
{"QueryReqV2", &QueryReqV2{CollectionName: "col2"}, "col2"},
|
|
{"CollectionIDReq", &CollectionIDReq{CollectionName: "col3"}, "col3"},
|
|
{"CollectionFilterReq", &CollectionFilterReq{CollectionName: "col4"}, "col4"},
|
|
{"CollectionDataReq", &CollectionDataReq{CollectionName: "col5"}, "col5"},
|
|
{"SearchReqV2", &SearchReqV2{CollectionName: "col6"}, "col6"},
|
|
{"HybridSearchReq", &HybridSearchReq{CollectionName: "col7"}, "col7"},
|
|
{"PartitionsReq", &PartitionsReq{CollectionName: "col8"}, "col8"},
|
|
{"GrantV2Req", &GrantV2Req{CollectionName: "col9"}, "col9"},
|
|
{"IndexParamReq", &IndexParamReq{CollectionName: "col10"}, "col10"},
|
|
{"CollectionReq", &CollectionReq{CollectionName: "col11"}, "col11"},
|
|
{"RunAnalyzerReq", &RunAnalyzerReq{CollectionName: "col12"}, "col12"},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
assert.Equal(t, tt.want, tt.req.GetCollectionName())
|
|
})
|
|
}
|
|
}
|