From 812f13fbec0b66344325b8d730c9f56d98ceb775 Mon Sep 17 00:00:00 2001 From: yue9944882 <291271447@qq.com> Date: Mon, 23 Nov 2020 15:12:26 +0800 Subject: [PATCH] matches specific usernames instead of "*" --- test/e2e/apimachinery/flowcontrol.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/test/e2e/apimachinery/flowcontrol.go b/test/e2e/apimachinery/flowcontrol.go index 0c396485f7c..baab8561893 100644 --- a/test/e2e/apimachinery/flowcontrol.go +++ b/test/e2e/apimachinery/flowcontrol.go @@ -159,7 +159,7 @@ var _ = SIGDescribe("API priority and fairness", func() { defer cleanup() framework.Logf("creating FlowSchema %q", flowSchemaName) - _, cleanup = createFlowSchema(f, flowSchemaName, 1000, priorityLevelName, "*") + _, cleanup = createFlowSchema(f, flowSchemaName, 1000, priorityLevelName, "highqps", "lowqps") defer cleanup() type client struct { @@ -265,9 +265,9 @@ func getPriorityLevelConcurrency(f *framework.Framework, priorityLevelName strin // createFlowSchema creates a flow schema referring to a particular priority // level and matching the username provided. -func createFlowSchema(f *framework.Framework, flowSchemaName string, matchingPrecedence int32, priorityLevelName string, matchingUsername string) (*flowcontrol.FlowSchema, func()) { +func createFlowSchema(f *framework.Framework, flowSchemaName string, matchingPrecedence int32, priorityLevelName string, matchingUsernames ...string) (*flowcontrol.FlowSchema, func()) { var subjects []flowcontrol.Subject - if matchingUsername == "*" { + if len(matchingUsernames) == 1 && matchingUsernames[0] == "*" { subjects = append(subjects, flowcontrol.Subject{ Kind: flowcontrol.SubjectKindGroup, Group: &flowcontrol.GroupSubject{ @@ -275,12 +275,14 @@ func createFlowSchema(f *framework.Framework, flowSchemaName string, matchingPre }, }) } else { - subjects = append(subjects, flowcontrol.Subject{ - Kind: flowcontrol.SubjectKindUser, - User: &flowcontrol.UserSubject{ - Name: matchingUsername, - }, - }) + for _, matchingUsername := range matchingUsernames { + subjects = append(subjects, flowcontrol.Subject{ + Kind: flowcontrol.SubjectKindUser, + User: &flowcontrol.UserSubject{ + Name: matchingUsername, + }, + }) + } } createdFlowSchema, err := f.ClientSet.FlowcontrolV1beta1().FlowSchemas().Create(