@@ -781,6 +781,7 @@ func getResourceList(cpu, memory string) corev1.ResourceList {
781
781
782
782
func TestDescribeService (t * testing.T ) {
783
783
singleStack := corev1 .IPFamilyPolicySingleStack
784
+ preferClose := corev1 .ServiceTrafficDistributionPreferClose
784
785
testCases := []struct {
785
786
name string
786
787
service * corev1.Service
@@ -1139,6 +1140,54 @@ func TestDescribeService(t *testing.T) {
1139
1140
Events: <none>
1140
1141
` )[1 :],
1141
1142
},
1143
+ {
1144
+ name : "test-TrafficDistribution" ,
1145
+ service : & corev1.Service {
1146
+ ObjectMeta : metav1.ObjectMeta {
1147
+ Name : "bar" ,
1148
+ Namespace : "foo" ,
1149
+ },
1150
+ Spec : corev1.ServiceSpec {
1151
+ Type : corev1 .ServiceTypeLoadBalancer ,
1152
+ Ports : []corev1.ServicePort {{
1153
+ Name : "port-tcp" ,
1154
+ Port : 8080 ,
1155
+ Protocol : corev1 .ProtocolTCP ,
1156
+ TargetPort : intstr .FromString ("targetPort" ),
1157
+ NodePort : 31111 ,
1158
+ }},
1159
+ Selector : map [string ]string {"blah" : "heh" },
1160
+ ClusterIP : "1.2.3.4" ,
1161
+ IPFamilies : []corev1.IPFamily {corev1 .IPv4Protocol },
1162
+ LoadBalancerIP : "5.6.7.8" ,
1163
+ SessionAffinity : corev1 .ServiceAffinityNone ,
1164
+ ExternalTrafficPolicy : corev1 .ServiceExternalTrafficPolicyLocal ,
1165
+ TrafficDistribution : & preferClose ,
1166
+ HealthCheckNodePort : 32222 ,
1167
+ },
1168
+ },
1169
+ expected : dedent .Dedent (`
1170
+ Name: bar
1171
+ Namespace: foo
1172
+ Labels: <none>
1173
+ Annotations: <none>
1174
+ Selector: blah=heh
1175
+ Type: LoadBalancer
1176
+ IP Families: IPv4
1177
+ IP: 1.2.3.4
1178
+ IPs: <none>
1179
+ Desired LoadBalancer IP: 5.6.7.8
1180
+ Port: port-tcp 8080/TCP
1181
+ TargetPort: targetPort/TCP
1182
+ NodePort: port-tcp 31111/TCP
1183
+ Endpoints: <none>
1184
+ Session Affinity: None
1185
+ External Traffic Policy: Local
1186
+ HealthCheck NodePort: 32222
1187
+ Traffic Distribution: PreferClose
1188
+ Events: <none>
1189
+ ` )[1 :],
1190
+ },
1142
1191
}
1143
1192
for _ , tc := range testCases {
1144
1193
t .Run (tc .name , func (t * testing.T ) {
0 commit comments