Skip to content

Commit e74de3d

Browse files
committed
Fix test
1 parent 9b8501a commit e74de3d

File tree

3 files changed

+13
-29
lines changed

3 files changed

+13
-29
lines changed

operator/deploy/chart/templates/rbac/role.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@ metadata:
77
{{- include "chart.labels" . | nindent 4 }}
88
name: operator-manager-role
99
rules:
10-
- apiGroups:
11-
- ""
12-
resources:
13-
- configmaps
14-
verbs:
15-
- create
16-
- delete
17-
- get
18-
- list
19-
- patch
20-
- update
21-
- watch
2210
- apiGroups:
2311
- apps
2412
resources:

operator/internal/controller/function_controller_test.go

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ var _ = Describe("Function Controller", func() {
104104
patch := client.MergeFrom(function.DeepCopy())
105105
function.Spec.Package = "test-pkg"
106106
function.Spec.Module = "mod"
107-
function.Spec.Sink = fsv1alpha1.SinkSpec{Pulsar: &fsv1alpha1.PulsarSinkSpec{Topic: "out"}}
108-
function.Spec.RequestSource = fsv1alpha1.SourceSpec{Pulsar: &fsv1alpha1.PulsarSourceSpec{Topic: "in"}}
107+
function.Spec.Sink = &fsv1alpha1.SinkSpec{Pulsar: &fsv1alpha1.PulsarSinkSpec{Topic: "out"}}
108+
function.Spec.RequestSource = &fsv1alpha1.SourceSpec{Pulsar: &fsv1alpha1.PulsarSourceSpec{Topic: "in"}}
109109
Expect(k8sClient.Patch(ctx, function, patch)).To(Succeed())
110110

111111
_, err := controllerReconciler.Reconcile(ctx, reconcile.Request{
@@ -154,7 +154,6 @@ var _ = Describe("Function Controller", func() {
154154

155155
// Verify labels
156156
Expect(deploy.Labels).To(HaveKey("function"))
157-
Expect(deploy.Labels).To(HaveKey("configmap-hash"))
158157
Expect(deploy.Labels["function"]).To(Equal(typeNamespacedName.Name))
159158

160159
// Simulate Deployment status update
@@ -180,10 +179,8 @@ var _ = Describe("Function Controller", func() {
180179
Expect(fn.Status.UpdatedReplicas).To(Equal(int32(1)))
181180
Expect(fn.Status.ObservedGeneration).To(Equal(int64(2)))
182181

183-
// Test config hash update when function spec changes
184-
oldHash := deploy.Labels["configmap-hash"]
185-
186-
// Update function spec to trigger hash change
182+
// Test deployment update when function spec changes
183+
// Update function spec to trigger deployment update
187184
patchFn := client.MergeFrom(fn.DeepCopy())
188185
fn.Spec.Description = "Updated description"
189186
Expect(k8sClient.Patch(ctx, fn, patchFn)).To(Succeed())
@@ -193,10 +190,10 @@ var _ = Describe("Function Controller", func() {
193190
})
194191
Expect(err).NotTo(HaveOccurred())
195192

196-
// Verify deployment hash has changed
193+
// Verify deployment was updated
197194
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: deployName, Namespace: typeNamespacedName.Namespace}, deploy)).To(Succeed())
198-
newHash := deploy.Labels["configmap-hash"]
199-
Expect(newHash).NotTo(Equal(oldHash))
195+
// The deployment should still exist and be updated
196+
Expect(deploy).NotTo(BeNil())
200197
})
201198

202199
It("should only reconcile when Deployment has 'function' label", func() {
@@ -233,10 +230,11 @@ var _ = Describe("Function Controller", func() {
233230
Namespace: "default",
234231
},
235232
Spec: fsv1alpha1.FunctionSpec{
236-
Package: "test-pkg-label",
237-
Module: "mod",
238-
Sink: fsv1alpha1.SinkSpec{Pulsar: &fsv1alpha1.PulsarSinkSpec{Topic: "out"}},
239-
RequestSource: fsv1alpha1.SourceSpec{Pulsar: &fsv1alpha1.PulsarSourceSpec{Topic: "in", SubscriptionName: "sub"}},
233+
Package: "test-pkg-label",
234+
Module: "mod",
235+
SubscriptionName: "sub",
236+
Sink: &fsv1alpha1.SinkSpec{Pulsar: &fsv1alpha1.PulsarSinkSpec{Topic: "out"}},
237+
RequestSource: &fsv1alpha1.SourceSpec{Pulsar: &fsv1alpha1.PulsarSourceSpec{Topic: "in"}},
240238
},
241239
}
242240
Expect(k8sClient.Create(ctx, fn)).To(Succeed())
@@ -250,7 +248,6 @@ var _ = Describe("Function Controller", func() {
250248
deployName := "function-" + fn.Name
251249
deploy := &appsv1.Deployment{}
252250
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: deployName, Namespace: fn.Namespace}, deploy)).To(Succeed())
253-
oldHash := deploy.Labels["configmap-hash"]
254251

255252
// Create a Deployment without 'function' label
256253
unlabeledDeploy := &appsv1.Deployment{
@@ -287,7 +284,6 @@ var _ = Describe("Function Controller", func() {
287284

288285
// Get Deployment again, the hash should remain unchanged
289286
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: deployName, Namespace: fn.Namespace}, deploy)).To(Succeed())
290-
Expect(deploy.Labels["configmap-hash"]).To(Equal(oldHash))
291287
})
292288
})
293289
})

operator/internal/controller/packages_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var _ = Describe("Package Controller", func() {
5555
DisplayName: "test",
5656
Description: "desc",
5757
FunctionType: fsv1alpha1.FunctionType{},
58-
Modules: map[string]fsv1alpha1.Module{},
58+
Modules: map[string]fsv1alpha1.Module{"mod": {DisplayName: "mod", Description: "desc"}},
5959
},
6060
}
6161
Expect(k8sClient.Create(ctx, resource)).To(Succeed())

0 commit comments

Comments
 (0)