@@ -2969,6 +2969,96 @@ func TestService_InitializeHPA(t *testing.T) {
2969
2969
},
2970
2970
},
2971
2971
},
2972
+ {
2973
+ name : "set tortoise hpa to existing even if all autoscaling policy is vertical" ,
2974
+ args : args {
2975
+ tortoise : & v1beta3.Tortoise {
2976
+ ObjectMeta : metav1.ObjectMeta {
2977
+ Name : "tortoise" ,
2978
+ Namespace : "default" ,
2979
+ },
2980
+ Spec : v1beta3.TortoiseSpec {
2981
+ TargetRefs : v1beta3.TargetRefs {
2982
+ ScaleTargetRef : v1beta3.CrossVersionObjectReference {
2983
+ Kind : "Deployment" ,
2984
+ Name : "deployment" ,
2985
+ APIVersion : "apps/v1" ,
2986
+ },
2987
+ },
2988
+ },
2989
+ Status : v1beta3.TortoiseStatus {
2990
+ AutoscalingPolicy : []v1beta3.ContainerAutoscalingPolicy {
2991
+ {
2992
+ ContainerName : "app" ,
2993
+ Policy : map [v1.ResourceName ]v1beta3.AutoscalingType {
2994
+ v1 .ResourceMemory : v1beta3 .AutoscalingTypeVertical ,
2995
+ },
2996
+ },
2997
+ {
2998
+ ContainerName : "istio-proxy" ,
2999
+ Policy : map [v1.ResourceName ]v1beta3.AutoscalingType {
3000
+ v1 .ResourceMemory : v1beta3 .AutoscalingTypeVertical ,
3001
+ },
3002
+ },
3003
+ },
3004
+ },
3005
+ },
3006
+ replicaNum : 4 ,
3007
+ },
3008
+ initialHPA : & v2.HorizontalPodAutoscaler {
3009
+ ObjectMeta : metav1.ObjectMeta {
3010
+ Name : "existing-hpa" ,
3011
+ Namespace : "default" ,
3012
+ Annotations : map [string ]string {},
3013
+ },
3014
+ Spec : v2.HorizontalPodAutoscalerSpec {
3015
+ MinReplicas : ptrInt32 (1 ),
3016
+ MaxReplicas : 2 ,
3017
+ ScaleTargetRef : v2.CrossVersionObjectReference {
3018
+ Kind : "Deployment" ,
3019
+ Name : "deployment" ,
3020
+ APIVersion : "apps/v1" ,
3021
+ },
3022
+ Behavior : & v2.HorizontalPodAutoscalerBehavior {
3023
+ ScaleDown : & v2.HPAScalingRules {
3024
+ Policies : []v2.HPAScalingPolicy {
3025
+ {
3026
+ Type : v2 .PercentScalingPolicy ,
3027
+ Value : 2 ,
3028
+ PeriodSeconds : 90 ,
3029
+ },
3030
+ },
3031
+ },
3032
+ },
3033
+ },
3034
+ },
3035
+ afterHPA : & v2.HorizontalPodAutoscaler {
3036
+ ObjectMeta : metav1.ObjectMeta {
3037
+ Name : "existing-hpa" ,
3038
+ Namespace : "default" ,
3039
+ },
3040
+ Spec : v2.HorizontalPodAutoscalerSpec {
3041
+ MinReplicas : ptrInt32 (1 ),
3042
+ MaxReplicas : 2 ,
3043
+ ScaleTargetRef : v2.CrossVersionObjectReference {
3044
+ Kind : "Deployment" ,
3045
+ Name : "deployment" ,
3046
+ APIVersion : "apps/v1" ,
3047
+ },
3048
+ Behavior : & v2.HorizontalPodAutoscalerBehavior {
3049
+ ScaleDown : & v2.HPAScalingRules {
3050
+ Policies : []v2.HPAScalingPolicy {
3051
+ {
3052
+ Type : v2 .PercentScalingPolicy ,
3053
+ Value : 2 ,
3054
+ PeriodSeconds : 90 ,
3055
+ },
3056
+ },
3057
+ },
3058
+ },
3059
+ },
3060
+ },
3061
+ },
2972
3062
}
2973
3063
for _ , tt := range tests {
2974
3064
t .Run (tt .name , func (t * testing.T ) {
0 commit comments