@@ -23,7 +23,7 @@ import (
23
23
"time"
24
24
25
25
v1 "k8s.io/api/core/v1"
26
- discoveryv1beta1 "k8s.io/api/discovery/v1beta1 "
26
+ discoveryv1 "k8s.io/api/discovery/v1 "
27
27
apierrors "k8s.io/apimachinery/pkg/api/errors"
28
28
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
29
29
"k8s.io/apimachinery/pkg/util/intstr"
@@ -48,7 +48,15 @@ var _ = common.SIGDescribe("EndpointSlice", func() {
48
48
podClient = f .PodClient ()
49
49
})
50
50
51
- ginkgo .It ("should have Endpoints and EndpointSlices pointing to API Server" , func () {
51
+ /*
52
+ Release: v1.21
53
+ Testname: EndpointSlice API
54
+ Description: The discovery.k8s.io API group MUST exist in the /apis discovery document.
55
+ The discovery.k8s.io/v1 API group/version MUST exist in the /apis/discovery.k8s.io discovery document.
56
+ The endpointslices resource MUST exist in the /apis/discovery.k8s.io/v1 discovery document.
57
+ API Server should create self referential Endpoints and EndpointSlices named "kubernetes" in the default namespace.
58
+ */
59
+ framework .ConformanceIt ("should have Endpoints and EndpointSlices pointing to API Server" , func () {
52
60
namespace := "default"
53
61
name := "kubernetes"
54
62
endpoints , err := cs .CoreV1 ().Endpoints (namespace ).Get (context .TODO (), name , metav1.GetOptions {})
@@ -58,7 +66,7 @@ var _ = common.SIGDescribe("EndpointSlice", func() {
58
66
}
59
67
60
68
endpointSubset := endpoints .Subsets [0 ]
61
- endpointSlice , err := cs .DiscoveryV1beta1 ().EndpointSlices (namespace ).Get (context .TODO (), name , metav1.GetOptions {})
69
+ endpointSlice , err := cs .DiscoveryV1 ().EndpointSlices (namespace ).Get (context .TODO (), name , metav1.GetOptions {})
62
70
framework .ExpectNoError (err , "error creating EndpointSlice resource" )
63
71
if len (endpointSlice .Ports ) != len (endpointSubset .Ports ) {
64
72
framework .Failf ("Expected EndpointSlice to have %d ports, got %d: %#v" , len (endpointSubset .Ports ), len (endpointSlice .Ports ), endpointSlice .Ports )
@@ -70,7 +78,15 @@ var _ = common.SIGDescribe("EndpointSlice", func() {
70
78
71
79
})
72
80
73
- ginkgo .It ("should create and delete Endpoints and EndpointSlices for a Service with a selector specified" , func () {
81
+ /*
82
+ Release: v1.21
83
+ Testname: EndpointSlice API
84
+ Description: The discovery.k8s.io API group MUST exist in the /apis discovery document.
85
+ The discovery.k8s.io/v1 API group/version MUST exist in the /apis/discovery.k8s.io discovery document.
86
+ The endpointslices resource MUST exist in the /apis/discovery.k8s.io/v1 discovery document.
87
+ The endpointslice controller should create and delete EndpointSlices for Pods matching a Service.
88
+ */
89
+ framework .ConformanceIt ("should create and delete Endpoints and EndpointSlices for a Service with a selector specified" , func () {
74
90
svc := createServiceReportErr (cs , f .Namespace .Name , & v1.Service {
75
91
ObjectMeta : metav1.ObjectMeta {
76
92
Name : "example-empty-selector" ,
@@ -99,9 +115,9 @@ var _ = common.SIGDescribe("EndpointSlice", func() {
99
115
}
100
116
101
117
// Expect EndpointSlice resource to be created.
102
- var endpointSlice discoveryv1beta1 .EndpointSlice
118
+ var endpointSlice discoveryv1 .EndpointSlice
103
119
if err := wait .PollImmediate (2 * time .Second , wait .ForeverTestTimeout , func () (bool , error ) {
104
- endpointSliceList , err := cs .DiscoveryV1beta1 ().EndpointSlices (svc .Namespace ).List (context .TODO (), metav1.ListOptions {
120
+ endpointSliceList , err := cs .DiscoveryV1 ().EndpointSlices (svc .Namespace ).List (context .TODO (), metav1.ListOptions {
105
121
LabelSelector : "kubernetes.io/service-name=" + svc .Name ,
106
122
})
107
123
if err != nil {
@@ -117,12 +133,12 @@ var _ = common.SIGDescribe("EndpointSlice", func() {
117
133
}
118
134
119
135
// Ensure EndpointSlice has expected values.
120
- managedBy , ok := endpointSlice .Labels [discoveryv1beta1 .LabelManagedBy ]
136
+ managedBy , ok := endpointSlice .Labels [discoveryv1 .LabelManagedBy ]
121
137
expectedManagedBy := "endpointslice-controller.k8s.io"
122
138
if ! ok {
123
- framework .Failf ("Expected EndpointSlice to have %s label, got %#v" , discoveryv1beta1 .LabelManagedBy , endpointSlice .Labels )
139
+ framework .Failf ("Expected EndpointSlice to have %s label, got %#v" , discoveryv1 .LabelManagedBy , endpointSlice .Labels )
124
140
} else if managedBy != expectedManagedBy {
125
- framework .Failf ("Expected EndpointSlice to have %s label with %s value, got %s" , discoveryv1beta1 .LabelManagedBy , expectedManagedBy , managedBy )
141
+ framework .Failf ("Expected EndpointSlice to have %s label with %s value, got %s" , discoveryv1 .LabelManagedBy , expectedManagedBy , managedBy )
126
142
}
127
143
if len (endpointSlice .Endpoints ) != 0 {
128
144
framework .Failf ("Expected EndpointSlice to have 0 endpoints, got %d: %#v" , len (endpointSlice .Endpoints ), endpointSlice .Endpoints )
@@ -150,7 +166,7 @@ var _ = common.SIGDescribe("EndpointSlice", func() {
150
166
// and may need to retry informer resync at some point during an e2e
151
167
// run.
152
168
if err := wait .PollImmediate (2 * time .Second , 90 * time .Second , func () (bool , error ) {
153
- endpointSliceList , err := cs .DiscoveryV1beta1 ().EndpointSlices (svc .Namespace ).List (context .TODO (), metav1.ListOptions {
169
+ endpointSliceList , err := cs .DiscoveryV1 ().EndpointSlices (svc .Namespace ).List (context .TODO (), metav1.ListOptions {
154
170
LabelSelector : "kubernetes.io/service-name=" + svc .Name ,
155
171
})
156
172
if err != nil {
@@ -165,7 +181,15 @@ var _ = common.SIGDescribe("EndpointSlice", func() {
165
181
}
166
182
})
167
183
168
- ginkgo .It ("should create Endpoints and EndpointSlices for Pods matching a Service" , func () {
184
+ /*
185
+ Release: v1.21
186
+ Testname: EndpointSlice API
187
+ Description: The discovery.k8s.io API group MUST exist in the /apis discovery document.
188
+ The discovery.k8s.io/v1 API group/version MUST exist in the /apis/discovery.k8s.io discovery document.
189
+ The endpointslices resource MUST exist in the /apis/discovery.k8s.io/v1 discovery document.
190
+ The endpointslice controller must create EndpointSlices for Pods mataching a Service.
191
+ */
192
+ framework .ConformanceIt ("should create Endpoints and EndpointSlices for Pods matching a Service" , func () {
169
193
labelPod1 := "pod1"
170
194
labelPod2 := "pod2"
171
195
labelPod3 := "pod3"
@@ -313,7 +337,7 @@ var _ = common.SIGDescribe("EndpointSlice", func() {
313
337
// and takes some shortcuts with the assumption that those test cases will be
314
338
// the only caller of this function.
315
339
func expectEndpointsAndSlices (cs clientset.Interface , ns string , svc * v1.Service , pods []* v1.Pod , numSubsets , numSlices int , namedPort bool ) {
316
- endpointSlices := []discoveryv1beta1 .EndpointSlice {}
340
+ endpointSlices := []discoveryv1 .EndpointSlice {}
317
341
if err := wait .PollImmediate (5 * time .Second , 2 * time .Minute , func () (bool , error ) {
318
342
endpointSlicesFound , hasMatchingSlices := hasMatchingEndpointSlices (cs , ns , svc .Name , len (pods ), numSlices )
319
343
if ! hasMatchingSlices {
@@ -479,27 +503,27 @@ func expectEndpointsAndSlices(cs clientset.Interface, ns string, svc *v1.Service
479
503
480
504
// deleteEndpointSlices deletes EndpointSlices for the specified Service.
481
505
func deleteEndpointSlices (cs clientset.Interface , ns string , svc * v1.Service ) {
482
- listOptions := metav1.ListOptions {LabelSelector : fmt .Sprintf ("%s=%s" , discoveryv1beta1 .LabelServiceName , svc .Name )}
483
- esList , err := cs .DiscoveryV1beta1 ().EndpointSlices (ns ).List (context .TODO (), listOptions )
506
+ listOptions := metav1.ListOptions {LabelSelector : fmt .Sprintf ("%s=%s" , discoveryv1 .LabelServiceName , svc .Name )}
507
+ esList , err := cs .DiscoveryV1 ().EndpointSlices (ns ).List (context .TODO (), listOptions )
484
508
framework .ExpectNoError (err , "Error fetching EndpointSlices for %s/%s Service" , ns , svc .Name )
485
509
486
510
for _ , endpointSlice := range esList .Items {
487
- err := cs .DiscoveryV1beta1 ().EndpointSlices (ns ).Delete (context .TODO (), endpointSlice .Name , metav1.DeleteOptions {})
511
+ err := cs .DiscoveryV1 ().EndpointSlices (ns ).Delete (context .TODO (), endpointSlice .Name , metav1.DeleteOptions {})
488
512
framework .ExpectNoError (err , "Error deleting %s/%s EndpointSlice" , ns , endpointSlice .Name )
489
513
}
490
514
}
491
515
492
516
// hasMatchingEndpointSlices returns any EndpointSlices that match the
493
517
// conditions along with a boolean indicating if all the conditions have been
494
518
// met.
495
- func hasMatchingEndpointSlices (cs clientset.Interface , ns , svcName string , numEndpoints , numSlices int ) ([]discoveryv1beta1 .EndpointSlice , bool ) {
496
- listOptions := metav1.ListOptions {LabelSelector : fmt .Sprintf ("%s=%s" , discoveryv1beta1 .LabelServiceName , svcName )}
497
- esList , err := cs .DiscoveryV1beta1 ().EndpointSlices (ns ).List (context .TODO (), listOptions )
519
+ func hasMatchingEndpointSlices (cs clientset.Interface , ns , svcName string , numEndpoints , numSlices int ) ([]discoveryv1 .EndpointSlice , bool ) {
520
+ listOptions := metav1.ListOptions {LabelSelector : fmt .Sprintf ("%s=%s" , discoveryv1 .LabelServiceName , svcName )}
521
+ esList , err := cs .DiscoveryV1 ().EndpointSlices (ns ).List (context .TODO (), listOptions )
498
522
framework .ExpectNoError (err , "Error fetching EndpointSlice for Service %s/%s" , ns , svcName )
499
523
500
524
if len (esList .Items ) == 0 {
501
525
framework .Logf ("EndpointSlice for Service %s/%s not found" , ns , svcName )
502
- return []discoveryv1beta1 .EndpointSlice {}, false
526
+ return []discoveryv1 .EndpointSlice {}, false
503
527
}
504
528
// In some cases the EndpointSlice controller will create more
505
529
// EndpointSlices than necessary resulting in some duplication. This is
0 commit comments