Skip to content

Commit 011a53d

Browse files
committed
test: Add endpointslice-controller integration tests
1 parent 0d681ca commit 011a53d

10 files changed

Lines changed: 790 additions & 101 deletions

File tree

examples/endpointslice-controller/README.md

Lines changed: 222 additions & 54 deletions
Large diffs are not rendered by default.

examples/endpointslice-controller/endpointslice-controller-gather-spec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@ controllers:
7878
- "-"
7979
- $.id.port
8080
target:
81-
kind: EndpointSliceView
81+
kind: EndpointView

examples/endpointslice-controller/endpointslice-controller-spec.yaml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,31 @@ controllers:
4646
"@aggregate":
4747
- "@project":
4848
metadata:
49-
name: $.EndpointSlice.metadata.name
50-
namespace: $.EndpointSlice.metadata.namespace
49+
name: $.ServiceView.metadata.name
50+
namespace: $.ServiceView.metadata.namespace
5151
spec: $.ServiceView.spec
5252
endpoints: $.EndpointSlice.endpoints
53-
id:
54-
name: $.ServiceView.spec.serviceName
55-
namespace: $.ServiceView.metadata.namespace
56-
type: $.ServiceView.spec.type
57-
protocol: $.ServiceView.spec.ports.protocol
58-
port: $.ServiceView.spec.ports.port
5953
- "@unwind": $.endpoints
6054
- "@select":
6155
"@eq": ["$.endpoints.conditions.ready", true]
6256
- "@unwind": $.endpoints.addresses
6357
- "@project":
64-
# use @merge so that expressions are applied in order
58+
metadata:
59+
namespace: $.metadata.namespace
60+
spec:
61+
serviceName: $.spec.serviceName
62+
type: $.spec.type
63+
port: $.spec.ports.port
64+
targetPort: $.spec.ports.targetPort
65+
protocol: $.spec.ports.protocol
66+
address: $.endpoints.addresses
67+
- "@project":
6568
"@merge":
66-
- {metadata: $.metadata}
67-
- {spec: $.spec}
68-
- {"$.spec.address": $.endpoints.addresses}
69-
- "$.metadata.name":
69+
metadata:
70+
name:
7071
"@concat":
71-
- $.id.name
72+
- $.spec.serviceName
7273
- "-"
7374
- { "@hash": $.spec }
7475
target:
75-
kind: EndpointSliceView
76+
kind: EndpointView

examples/endpointslice-controller/main.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ import (
3030
)
3131

3232
const (
33-
OperatorSpec = "examples/endpointslice-controller/endpointslice-controller-spec.yaml"
34-
OperatorGatherSpec = "examples/endpointslice-controller/endpointslice-controller-gather-spec.yaml"
35-
EndpointSliceControllerAnnotationName = "dcontroller.io/endpointslice-controller-enabled"
33+
OperatorSpec = "examples/endpointslice-controller/endpointslice-controller-spec.yaml"
34+
OperatorGatherSpec = "examples/endpointslice-controller/endpointslice-controller-gather-spec.yaml"
35+
EndpointSliceCtrlAnnotationName = "dcontroller.io/endpointslice-controller-enabled"
3636
)
3737

3838
var (
@@ -125,7 +125,7 @@ type endpointSliceController struct {
125125
func NewEndpointSliceController(mgr manager.Manager, log logr.Logger) (*endpointSliceController, error) {
126126
r := &endpointSliceController{
127127
Client: mgr.GetClient(),
128-
log: log.WithName("endpointSlice-ctrl"),
128+
log: log.WithName("endpointslice-ctrl"),
129129
}
130130

131131
on := true
@@ -139,7 +139,7 @@ func NewEndpointSliceController(mgr manager.Manager, log logr.Logger) (*endpoint
139139

140140
src, err := dreconciler.NewSource(mgr, opv1a1.Source{
141141
Resource: opv1a1.Resource{
142-
Kind: "EndpointSliceView",
142+
Kind: "EndpointView",
143143
},
144144
}).GetSource()
145145
if err != nil {
@@ -174,12 +174,12 @@ func (r *endpointSliceController) Reconcile(ctx context.Context, req dreconciler
174174
name := obj.GetName()
175175
namespace := obj.GetNamespace()
176176

177-
r.log.Info("Add/update EndpointSliceView object", "name", name, "namespace", namespace, "spec", fmt.Sprintf("%#v", spec))
177+
r.log.Info("Add/update EndpointView object", "name", name, "namespace", namespace, "spec", fmt.Sprintf("%#v", spec))
178178

179179
// handle upsert event
180180

181181
case cache.Deleted:
182-
r.log.Info("Delete EndpointSliceView object", "name", req.Name, "namespace", req.Namespace)
182+
r.log.Info("Delete EndpointView object", "name", req.Name, "namespace", req.Namespace)
183183

184184
// handle delete event
185185

0 commit comments

Comments
 (0)