Fix the unstable resource manager testcase (#28033)

Signed-off-by: SimFG <bang.fu@zilliz.com>
This commit is contained in:
SimFG 2023-11-03 11:00:17 +08:00 committed by GitHub
parent b596d8e75b
commit ef68680639
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -6,7 +6,9 @@ import (
"strings" "strings"
"go.uber.org/zap" "go.uber.org/zap"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"github.com/milvus-io/milvus/pkg/log" "github.com/milvus-io/milvus/pkg/log"
"github.com/milvus-io/milvus/pkg/metrics" "github.com/milvus-io/milvus/pkg/metrics"
@ -86,8 +88,8 @@ func AuthenticationInterceptor(ctx context.Context) (context.Context, error) {
// username+password authentication // username+password authentication
username, password := parseMD(rawToken) username, password := parseMD(rawToken)
if !passwordVerify(ctx, username, password, globalMetaCache) { if !passwordVerify(ctx, username, password, globalMetaCache) {
msg := fmt.Sprintf("username: %s, password: %s", username, password) // NOTE: don't use the merr, because it will cause the wrong retry behavior in the sdk
return nil, merr.WrapErrParameterInvalid("vaild username and password", msg, "auth check failure, please check username and password are correct") return nil, status.Errorf(codes.Unauthenticated, "auth check failure, please check username [%s] and password [%s] are correct", username, password)
} }
metrics.UserRPCCounter.WithLabelValues(username).Inc() metrics.UserRPCCounter.WithLabelValues(username).Inc()
} }

View File

@ -63,7 +63,9 @@ func TestResourceManager(t *testing.T) {
assert.Equal(t, "foo2", res.Get()) assert.Equal(t, "foo2", res.Get())
res = manager.Delete("test", "foo") res = manager.Delete("test", "foo")
assert.Equal(t, "foo2", res.Get()) assert.Equal(t, "foo2", res.Get())
time.Sleep(time.Second) assert.Eventually(t, func() bool {
return manager.Delete("test", "foo") == nil
}, time.Second*5, time.Millisecond*500)
res, err := manager.Get("test", "foo", func() (Resource, error) { res, err := manager.Get("test", "foo", func() (Resource, error) {
return NewSimpleResource("foo3", "test", "foo", 0, nil), nil return NewSimpleResource("foo3", "test", "foo", 0, nil), nil