@@ -23,7 +23,6 @@ import (
23
23
"github.com/stretchr/testify/assert"
24
24
25
25
corev1 "k8s.io/api/core/v1"
26
- v1 "k8s.io/api/core/v1"
27
26
discovery "k8s.io/api/discovery/v1alpha1"
28
27
apiequality "k8s.io/apimachinery/pkg/api/equality"
29
28
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -52,7 +51,7 @@ func TestReconcileEmpty(t *testing.T) {
52
51
assert .Len (t , slices , 1 , "Expected 1 endpoint slices" )
53
52
54
53
assert .Regexp (t , "^" + svc .Name , slices [0 ].Name )
55
- assert .Equal (t , svc .Name , slices [0 ].Labels [serviceNameLabel ])
54
+ assert .Equal (t , svc .Name , slices [0 ].Labels [discovery . LabelServiceName ])
56
55
assert .EqualValues (t , []discovery.EndpointPort {}, slices [0 ].Ports )
57
56
assert .EqualValues (t , []discovery.Endpoint {}, slices [0 ].Endpoints )
58
57
}
@@ -83,7 +82,7 @@ func TestReconcile1Pod(t *testing.T) {
83
82
slices := fetchEndpointSlices (t , client , namespace )
84
83
assert .Len (t , slices , 1 , "Expected 1 endpoint slices" )
85
84
assert .Regexp (t , "^" + svc .Name , slices [0 ].Name )
86
- assert .Equal (t , svc .Name , slices [0 ].Labels [serviceNameLabel ])
85
+ assert .Equal (t , svc .Name , slices [0 ].Labels [discovery . LabelServiceName ])
87
86
assert .Equal (t , slices [0 ].Annotations , map [string ]string {
88
87
"endpoints.kubernetes.io/last-change-trigger-time" : triggerTime .Format (time .RFC3339Nano ),
89
88
})
@@ -125,7 +124,7 @@ func TestReconcile1EndpointSlice(t *testing.T) {
125
124
assert .Len (t , slices , 1 , "Expected 1 endpoint slices" )
126
125
127
126
assert .Regexp (t , "^" + svc .Name , slices [0 ].Name )
128
- assert .Equal (t , svc .Name , slices [0 ].Labels [serviceNameLabel ])
127
+ assert .Equal (t , svc .Name , slices [0 ].Labels [discovery . LabelServiceName ])
129
128
assert .EqualValues (t , []discovery.EndpointPort {}, slices [0 ].Ports )
130
129
assert .EqualValues (t , []discovery.Endpoint {}, slices [0 ].Endpoints )
131
130
}
@@ -362,9 +361,9 @@ func TestReconcileEndpointSlicesUpdatePacking(t *testing.T) {
362
361
// ensure that endpoints in each slice will be marked for update.
363
362
for i , pod := range pods {
364
363
if i % 10 == 0 {
365
- pod .Status .Conditions = []v1 .PodCondition {{
366
- Type : v1 .PodReady ,
367
- Status : v1 .ConditionFalse ,
364
+ pod .Status .Conditions = []corev1 .PodCondition {{
365
+ Type : corev1 .PodReady ,
366
+ Status : corev1 .ConditionFalse ,
368
367
}}
369
368
}
370
369
}
@@ -397,10 +396,10 @@ func TestReconcileEndpointSlicesNamedPorts(t *testing.T) {
397
396
398
397
svc := corev1.Service {
399
398
ObjectMeta : metav1.ObjectMeta {Name : "named-port-example" , Namespace : namespace },
400
- Spec : v1 .ServiceSpec {
401
- Ports : []v1 .ServicePort {{
399
+ Spec : corev1 .ServiceSpec {
400
+ Ports : []corev1 .ServicePort {{
402
401
TargetPort : portNameIntStr ,
403
- Protocol : v1 .ProtocolTCP ,
402
+ Protocol : corev1 .ProtocolTCP ,
404
403
}},
405
404
Selector : map [string ]string {"foo" : "bar" },
406
405
},
@@ -412,10 +411,10 @@ func TestReconcileEndpointSlicesNamedPorts(t *testing.T) {
412
411
ready := ! (i % 3 == 0 )
413
412
portOffset := i % 5
414
413
pod := newPod (i , namespace , ready , 1 )
415
- pod .Spec .Containers [0 ].Ports = []v1 .ContainerPort {{
414
+ pod .Spec .Containers [0 ].Ports = []corev1 .ContainerPort {{
416
415
Name : portNameIntStr .StrVal ,
417
416
ContainerPort : int32 (8080 + portOffset ),
418
- Protocol : v1 .ProtocolTCP ,
417
+ Protocol : corev1 .ProtocolTCP ,
419
418
}}
420
419
pods = append (pods , pod )
421
420
}
@@ -433,7 +432,7 @@ func TestReconcileEndpointSlicesNamedPorts(t *testing.T) {
433
432
expectUnorderedSlicesWithLengths (t , fetchedSlices , []int {60 , 60 , 60 , 60 , 60 })
434
433
435
434
// generate data structures for expected slice ports and address types
436
- protoTCP := v1 .ProtocolTCP
435
+ protoTCP := corev1 .ProtocolTCP
437
436
ipAddressType := discovery .AddressTypeIP
438
437
expectedSlices := []discovery.EndpointSlice {}
439
438
for i := range fetchedSlices {
0 commit comments