@@ -814,6 +814,19 @@ func BenchmarkWithOneCELExpressions(b *testing.B) {
814
814
benchmarkWebhookAuthorize (b , expressions , true )
815
815
})
816
816
}
817
+ func BenchmarkWithOneCELExpressionsFalse (b * testing.B ) {
818
+ expressions := []apiserver.WebhookMatchCondition {
819
+ {
820
+ Expression : "request.user == 'alice2'" ,
821
+ },
822
+ }
823
+ b .Run ("compile" , func (b * testing.B ) {
824
+ benchmarkNewWebhookAuthorizer (b , expressions , true )
825
+ })
826
+ b .Run ("authorize" , func (b * testing.B ) {
827
+ benchmarkWebhookAuthorize (b , expressions , true )
828
+ })
829
+ }
817
830
func BenchmarkWithTwoCELExpressions (b * testing.B ) {
818
831
expressions := []apiserver.WebhookMatchCondition {
819
832
{
@@ -830,13 +843,13 @@ func BenchmarkWithTwoCELExpressions(b *testing.B) {
830
843
benchmarkWebhookAuthorize (b , expressions , true )
831
844
})
832
845
}
833
- func BenchmarkWithTwoComplexCELExpressions (b * testing.B ) {
846
+ func BenchmarkWithTwoCELExpressionsFalse (b * testing.B ) {
834
847
expressions := []apiserver.WebhookMatchCondition {
835
848
{
836
849
Expression : "request.user == 'alice'" ,
837
850
},
838
851
{
839
- Expression : "has( request.resourceAttributes) && request.resourceAttributes.namespace == 'kittensandponies '" ,
852
+ Expression : "request.uid == '2 '" ,
840
853
},
841
854
}
842
855
b .Run ("compile" , func (b * testing.B ) {
@@ -880,6 +893,40 @@ func BenchmarkWithManyCELExpressions(b *testing.B) {
880
893
benchmarkWebhookAuthorize (b , expressions , true )
881
894
})
882
895
}
896
+ func BenchmarkWithManyCELExpressionsFalse (b * testing.B ) {
897
+ expressions := []apiserver.WebhookMatchCondition {
898
+ {
899
+ Expression : "request.user == 'alice'" ,
900
+ },
901
+ {
902
+ Expression : "request.uid == '1'" ,
903
+ },
904
+ {
905
+ Expression : "('group1' in request.groups)" ,
906
+ },
907
+ {
908
+ Expression : "('key1' in request.extra)" ,
909
+ },
910
+ {
911
+ Expression : "!('key2' in request.extra)" ,
912
+ },
913
+ {
914
+ Expression : "('a' in request.extra['key1'])" ,
915
+ },
916
+ {
917
+ Expression : "!('z' in request.extra['key1'])" ,
918
+ },
919
+ {
920
+ Expression : "has(request.resourceAttributes) && request.resourceAttributes.namespace == 'kittensandponies1'" ,
921
+ },
922
+ }
923
+ b .Run ("compile" , func (b * testing.B ) {
924
+ benchmarkNewWebhookAuthorizer (b , expressions , true )
925
+ })
926
+ b .Run ("authorize" , func (b * testing.B ) {
927
+ benchmarkWebhookAuthorize (b , expressions , true )
928
+ })
929
+ }
883
930
884
931
func benchmarkNewWebhookAuthorizer (b * testing.B , expressions []apiserver.WebhookMatchCondition , featureEnabled bool ) {
885
932
service := new (mockV1Service )
0 commit comments