mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-11 13:02:14 +00:00
add false matchCondition benchmark
Signed-off-by: Rita Zhang <rita.z.zhang@gmail.com>
This commit is contained in:
parent
11cdb8fd01
commit
7c5dfceff8
@ -814,6 +814,19 @@ func BenchmarkWithOneCELExpressions(b *testing.B) {
|
||||
benchmarkWebhookAuthorize(b, expressions, true)
|
||||
})
|
||||
}
|
||||
func BenchmarkWithOneCELExpressionsFalse(b *testing.B) {
|
||||
expressions := []apiserver.WebhookMatchCondition{
|
||||
{
|
||||
Expression: "request.user == 'alice2'",
|
||||
},
|
||||
}
|
||||
b.Run("compile", func(b *testing.B) {
|
||||
benchmarkNewWebhookAuthorizer(b, expressions, true)
|
||||
})
|
||||
b.Run("authorize", func(b *testing.B) {
|
||||
benchmarkWebhookAuthorize(b, expressions, true)
|
||||
})
|
||||
}
|
||||
func BenchmarkWithTwoCELExpressions(b *testing.B) {
|
||||
expressions := []apiserver.WebhookMatchCondition{
|
||||
{
|
||||
@ -830,13 +843,13 @@ func BenchmarkWithTwoCELExpressions(b *testing.B) {
|
||||
benchmarkWebhookAuthorize(b, expressions, true)
|
||||
})
|
||||
}
|
||||
func BenchmarkWithTwoComplexCELExpressions(b *testing.B) {
|
||||
func BenchmarkWithTwoCELExpressionsFalse(b *testing.B) {
|
||||
expressions := []apiserver.WebhookMatchCondition{
|
||||
{
|
||||
Expression: "request.user == 'alice'",
|
||||
},
|
||||
{
|
||||
Expression: "has(request.resourceAttributes) && request.resourceAttributes.namespace == 'kittensandponies'",
|
||||
Expression: "request.uid == '2'",
|
||||
},
|
||||
}
|
||||
b.Run("compile", func(b *testing.B) {
|
||||
@ -880,6 +893,40 @@ func BenchmarkWithManyCELExpressions(b *testing.B) {
|
||||
benchmarkWebhookAuthorize(b, expressions, true)
|
||||
})
|
||||
}
|
||||
func BenchmarkWithManyCELExpressionsFalse(b *testing.B) {
|
||||
expressions := []apiserver.WebhookMatchCondition{
|
||||
{
|
||||
Expression: "request.user == 'alice'",
|
||||
},
|
||||
{
|
||||
Expression: "request.uid == '1'",
|
||||
},
|
||||
{
|
||||
Expression: "('group1' in request.groups)",
|
||||
},
|
||||
{
|
||||
Expression: "('key1' in request.extra)",
|
||||
},
|
||||
{
|
||||
Expression: "!('key2' in request.extra)",
|
||||
},
|
||||
{
|
||||
Expression: "('a' in request.extra['key1'])",
|
||||
},
|
||||
{
|
||||
Expression: "!('z' in request.extra['key1'])",
|
||||
},
|
||||
{
|
||||
Expression: "has(request.resourceAttributes) && request.resourceAttributes.namespace == 'kittensandponies1'",
|
||||
},
|
||||
}
|
||||
b.Run("compile", func(b *testing.B) {
|
||||
benchmarkNewWebhookAuthorizer(b, expressions, true)
|
||||
})
|
||||
b.Run("authorize", func(b *testing.B) {
|
||||
benchmarkWebhookAuthorize(b, expressions, true)
|
||||
})
|
||||
}
|
||||
|
||||
func benchmarkNewWebhookAuthorizer(b *testing.B, expressions []apiserver.WebhookMatchCondition, featureEnabled bool) {
|
||||
service := new(mockV1Service)
|
||||
|
Loading…
Reference in New Issue
Block a user