Skip to content

Commit a104886

Browse files
author
eliranb
committed
Update LightrunJavaAgent controller tests to reflect changes in workload status and field names, replacing DeploymentStatus with WorkloadStatus and updating related assertions for consistency with recent refactorings.
1 parent 21978cb commit a104886

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

internal/controller/lightrunjavaagent_controller_test.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ var _ = Describe("LightrunJavaAgent controller", func() {
217217
Namespace: testNamespace,
218218
},
219219
Spec: agentsv1beta.LightrunJavaAgentSpec{
220-
StatefulSetName: statefulset,
220+
WorkloadName: statefulset,
221+
WorkloadType: agentsv1beta.WorkloadTypeStatefulSet,
221222
SecretName: secretName,
222223
ServerHostname: server,
223224
AgentName: agentName,
@@ -243,7 +244,8 @@ var _ = Describe("LightrunJavaAgent controller", func() {
243244
},
244245
Spec: agentsv1beta.LightrunJavaAgentSpec{
245246
DeploymentName: deployment,
246-
StatefulSetName: statefulset,
247+
WorkloadName: statefulset,
248+
WorkloadType: agentsv1beta.WorkloadTypeStatefulSet,
247249
SecretName: secretName,
248250
ServerHostname: server,
249251
AgentName: agentName,
@@ -429,7 +431,8 @@ var _ = Describe("LightrunJavaAgent controller", func() {
429431
})
430432
It("Should not change hash of the configmap in the deployment metadata", func() {
431433
Eventually(func() bool {
432-
return patchedDepl.Spec.Template.Annotations[annotationConfigMapHash] == fmt.Sprint(hash(cm.Data["config"]+cm.Data["metadata"]))
434+
expectedHash := configMapDataHash(cm.Data)
435+
return patchedDepl.Spec.Template.Annotations[annotationConfigMapHash] == fmt.Sprint(expectedHash)
433436
}).Should(BeTrue())
434437
})
435438

@@ -714,7 +717,7 @@ var _ = Describe("LightrunJavaAgent controller", func() {
714717
if err := k8sClient.Get(ctx, lrAgentRequest2, &lrAgent2); err != nil {
715718
return false
716719
}
717-
return lrAgent2.Status.DeploymentStatus == "Ready"
720+
return lrAgent2.Status.WorkloadStatus == "Ready"
718721
}).Should(BeTrue())
719722
})
720723

@@ -749,7 +752,7 @@ var _ = Describe("LightrunJavaAgent controller", func() {
749752
if err := k8sClient.Get(ctx, lrAgentRequest3, &lrAgent3); err != nil {
750753
return false
751754
}
752-
return lrAgent3.Status.DeploymentStatus == "ReconcileFailed"
755+
return lrAgent3.Status.WorkloadStatus == "ReconcileFailed"
753756
}).Should(BeTrue())
754757
})
755758
It("Should not add finalizer to the duplicate CR", func() {
@@ -845,7 +848,7 @@ var _ = Describe("LightrunJavaAgent controller", func() {
845848
if err := k8sClient.Get(ctx, lrAgentRequest4, &lrAgent4); err != nil {
846849
return false
847850
}
848-
return lrAgent4.Status.DeploymentStatus == "" && lrAgent4.Status.Conditions == nil
851+
return lrAgent4.Status.WorkloadStatus == "" && lrAgent4.Status.Conditions == nil
849852
}).Should(BeTrue())
850853
})
851854
It("Should not patch the deployment", func() {
@@ -1124,15 +1127,15 @@ var _ = Describe("LightrunJavaAgent controller", func() {
11241127

11251128
for _, condition := range lrAgentResult.Status.Conditions {
11261129
if condition.Type == reconcileTypeNotProgressing && condition.Status == metav1.ConditionTrue &&
1127-
condition.Reason == "reconcileFailed" && strings.Contains(condition.Message, "both deployment and statefulset specified") {
1130+
condition.Reason == "reconcileFailed" && strings.Contains(condition.Message, "DeploymentName and WorkloadName are both set but differ") {
11281131
return true
11291132
}
11301133
}
11311134
return false
11321135
}, timeout, interval).Should(BeTrue())
11331136

11341137
// Also verify the workload status is set correctly
1135-
Expect(lrAgentResult.Status.DeploymentStatus).To(Equal(reconcileTypeNotProgressing))
1138+
Expect(lrAgentResult.Status.WorkloadStatus).To(Equal(reconcileTypeNotProgressing))
11361139
})
11371140
})
11381141

0 commit comments

Comments
 (0)