From dfcd9d4a34fe94ad69b1ed4c633faf81b1142a2d Mon Sep 17 00:00:00 2001 From: Shereen Haj Date: Thu, 21 Nov 2024 17:01:53 +0200 Subject: [PATCH 1/2] ctrl: test empty string as PoolName Add missing test for PoolName as kempty string. Signed-off-by: Shereen Haj --- controllers/numaresourcesoperator_controller_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/controllers/numaresourcesoperator_controller_test.go b/controllers/numaresourcesoperator_controller_test.go index b5d880ceb..834e3d173 100644 --- a/controllers/numaresourcesoperator_controller_test.go +++ b/controllers/numaresourcesoperator_controller_test.go @@ -121,6 +121,17 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() { }) }) + Context("with PoolName set to empty string", func() { + It("should update the CR condition to degraded", func() { + pn := "" + ng := nropv1.NodeGroup{ + PoolName: &pn, + } + nro := testobjs.NewNUMAResourcesOperator(objectnames.DefaultNUMAResourcesOperatorCrName, ng) + verifyDegradedCondition(nro, validation.NodeGroupsError, platf) + }) + }) + Context("with NRO mutiple pool specifiers set on same node group", func() { It("should update the CR condition to degraded", func() { pn := "test" From 35c11a157b86ba9b8958e59db6e0c012bd7ca7d2 Mon Sep 17 00:00:00 2001 From: Shereen Haj Date: Thu, 21 Nov 2024 17:02:28 +0200 Subject: [PATCH 2/2] ctrl test: verify Avialable condition is true Extend the current test to verify the available condition of the operator for extra verification. Signed-off-by: Shereen Haj --- controllers/numaresourcesoperator_controller_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/controllers/numaresourcesoperator_controller_test.go b/controllers/numaresourcesoperator_controller_test.go index 834e3d173..a9d0c1ac1 100644 --- a/controllers/numaresourcesoperator_controller_test.go +++ b/controllers/numaresourcesoperator_controller_test.go @@ -222,6 +222,12 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() { result, err := reconciler.Reconcile(context.TODO(), reconcile.Request{NamespacedName: nroKey}) Expect(err).ToNot(HaveOccurred()) Expect(result).To(Equal(reconcile.Result{})) + + Expect(reconciler.Client.Get(context.TODO(), client.ObjectKeyFromObject(nro), nro)).ToNot(HaveOccurred()) + + availableCondition := getConditionByType(nro.Status.Conditions, status.ConditionAvailable) + Expect(availableCondition).ToNot(BeNil()) + Expect(availableCondition.Status).To(Equal(metav1.ConditionTrue)) }) It("should create all CRDs and objects and operator status are updated from the first reconcile iteration", func() {