@@ -2017,7 +2017,7 @@ func TestReconcile_TrafficDistribution(t *testing.T) {
2017
2017
desc string
2018
2018
2019
2019
trafficDistributionFeatureGateEnabled bool
2020
- trafficDistribution string
2020
+ trafficDistribution * string
2021
2021
topologyAnnotation string
2022
2022
2023
2023
// Defines how many hints belong to a particular zone.
@@ -2031,7 +2031,7 @@ func TestReconcile_TrafficDistribution(t *testing.T) {
2031
2031
name : "trafficDistribution=PreferClose, topologyAnnotation=Disabled" ,
2032
2032
desc : "When trafficDistribution is enabled and topologyAnnotation is disabled, hints should be distributed as per the trafficDistribution field" ,
2033
2033
trafficDistributionFeatureGateEnabled : true ,
2034
- trafficDistribution : corev1 .ServiceTrafficDistributionPreferClose ,
2034
+ trafficDistribution : ptr . To ( corev1 .ServiceTrafficDistributionPreferClose ) ,
2035
2035
topologyAnnotation : "Disabled" ,
2036
2036
wantHintsDistributionByZone : map [string ]int {
2037
2037
"zone-a" : 1 , // {pod-0}
@@ -2059,7 +2059,7 @@ func TestReconcile_TrafficDistribution(t *testing.T) {
2059
2059
name : "feature gate disabled; trafficDistribution=PreferClose, topologyAnnotation=Disabled" ,
2060
2060
desc : "When feature gate is disabled, trafficDistribution should be ignored" ,
2061
2061
trafficDistributionFeatureGateEnabled : false ,
2062
- trafficDistribution : corev1 .ServiceTrafficDistributionPreferClose ,
2062
+ trafficDistribution : ptr . To ( corev1 .ServiceTrafficDistributionPreferClose ) ,
2063
2063
topologyAnnotation : "Disabled" ,
2064
2064
wantHintsDistributionByZone : map [string ]int {"" : 6 }, // Equivalent to no hints.
2065
2065
wantMetrics : expectedMetrics {
@@ -2080,7 +2080,7 @@ func TestReconcile_TrafficDistribution(t *testing.T) {
2080
2080
name : "trafficDistribution=PreferClose, topologyAnnotation=Auto" ,
2081
2081
desc : "When trafficDistribution and topologyAnnotation are both enabled, precedence should be given to topologyAnnotation" ,
2082
2082
trafficDistributionFeatureGateEnabled : true ,
2083
- trafficDistribution : corev1 .ServiceTrafficDistributionPreferClose ,
2083
+ trafficDistribution : ptr . To ( corev1 .ServiceTrafficDistributionPreferClose ) ,
2084
2084
topologyAnnotation : "Auto" ,
2085
2085
wantHintsDistributionByZone : map [string ]int {
2086
2086
"zone-a" : 2 , // {pod-0, pod-3} (pod-3 is just an example, it could have also been either of the other two)
@@ -2103,10 +2103,10 @@ func TestReconcile_TrafficDistribution(t *testing.T) {
2103
2103
},
2104
2104
},
2105
2105
{
2106
- name : "trafficDistribution=<empty> , topologyAnnotation=<empty>" ,
2107
- desc : "When trafficDistribution and topologyAnnotation are both disabled, no hints should be added, but the servicesCountByTrafficDistribution metric should reflect this " ,
2106
+ name : "trafficDistribution=nil , topologyAnnotation=<empty>" ,
2107
+ desc : "When trafficDistribution and topologyAnnotation are both disabled, no hints should be added" ,
2108
2108
trafficDistributionFeatureGateEnabled : true ,
2109
- trafficDistribution : "" ,
2109
+ trafficDistribution : nil ,
2110
2110
topologyAnnotation : "" ,
2111
2111
wantHintsDistributionByZone : map [string ]int {"" : 6 }, // Equivalent to no hints.
2112
2112
wantMetrics : expectedMetrics {
@@ -2121,9 +2121,6 @@ func TestReconcile_TrafficDistribution(t *testing.T) {
2121
2121
slicesChangedPerSync : 1 , // 1 means both topologyAnnotation and trafficDistribution were not used.
2122
2122
slicesChangedPerSyncTopology : 0 , // 0 means topologyAnnotation was not used.
2123
2123
slicesChangedPerSyncTrafficDist : 0 , // 0 means trafficDistribution was not used.
2124
- servicesCountByTrafficDistribution : map [string ]int {
2125
- "ImplementationSpecific" : 1 ,
2126
- },
2127
2124
},
2128
2125
},
2129
2126
}
@@ -2142,7 +2139,7 @@ func TestReconcile_TrafficDistribution(t *testing.T) {
2142
2139
r .topologyCache .SetNodes (logger , nodes )
2143
2140
2144
2141
service := svc .DeepCopy ()
2145
- service .Spec .TrafficDistribution = & tc .trafficDistribution
2142
+ service .Spec .TrafficDistribution = tc .trafficDistribution
2146
2143
service .Annotations = map [string ]string {
2147
2144
corev1 .DeprecatedAnnotationTopologyAwareHints : tc .topologyAnnotation ,
2148
2145
}
0 commit comments