diff --git a/Makefile b/Makefile index 97f3c4c82..072b0fb3e 100644 --- a/Makefile +++ b/Makefile @@ -126,6 +126,9 @@ test-unit-pkgs: test-controllers: envtest KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" hack/run-test-controllers.sh +test-controllers-plaftform: envtest + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./controllers/... + test-e2e: build-e2e-all ENABLE_SCHED_TESTS=true hack/run-test-e2e.sh diff --git a/controllers/numaresourcesoperator_controller_test.go b/controllers/numaresourcesoperator_controller_test.go index fce6d0369..7e90dbe20 100644 --- a/controllers/numaresourcesoperator_controller_test.go +++ b/controllers/numaresourcesoperator_controller_test.go @@ -306,7 +306,12 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() { // on the first iteration we expect the CRDs and MCPs to be created, yet, it will wait one minute to update MC, thus RTE daemonsets and complete status update is not going to be achieved at this point firstLoopResult, err := reconciler.Reconcile(context.TODO(), reconcile.Request{NamespacedName: key}) Expect(err).ToNot(HaveOccurred()) - Expect(firstLoopResult).To(Equal(reconcile.Result{RequeueAfter: time.Minute})) + expectedRes := reconcile.Result{RequeueAfter: time.Minute} + if testPlatform == platform.HyperShift { + // because there is no resource MC to wait for on hypershift + expectedRes = reconcile.Result{} + } + Expect(firstLoopResult).To(Equal(expectedRes)) // Ensure mcp1 is ready Expect(reconciler.Client.Get(context.TODO(), client.ObjectKeyFromObject(mcp1), mcp1)).To(Succeed()) @@ -856,7 +861,12 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() { It("should create CRD, machine configs and wait for MCPs updates", func() { // check reconcile loop result // wait one minute to update MCP, thus RTE daemonsets and complete status update is not going to be achieved at this point - Expect(firstLoopResult).To(Equal(reconcile.Result{RequeueAfter: time.Minute})) + expectedRes := reconcile.Result{RequeueAfter: time.Minute} + if testPlatform == platform.HyperShift { + // because there is no resource MC to wait for on hypershift + expectedRes = reconcile.Result{} + } + Expect(firstLoopResult).To(Equal(expectedRes)) // check CRD is created crd := &apiextensionsv1.CustomResourceDefinition{} @@ -892,7 +902,12 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() { It("should wait", func() { // check reconcile first loop result // wait one minute to update MCP, thus RTE daemonsets and complete status update is not going to be achieved at this point - Expect(result).To(Equal(reconcile.Result{RequeueAfter: time.Minute})) + expectedRes := reconcile.Result{RequeueAfter: time.Minute} + if testPlatform == platform.HyperShift { + // because there is no resource MC to wait for on hypershift + expectedRes = reconcile.Result{} + } + Expect(result).To(Equal(expectedRes)) key := client.ObjectKeyFromObject(nro) Expect(reconciler.Client.Get(context.TODO(), key, nro)).ToNot(HaveOccurred()) @@ -1098,13 +1113,20 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() { // on the first iteration we expect the CRDs and MCPs to be created, yet, it will wait one minute to update MC, thus RTE daemonsets and complete status update is not going to be achieved at this point firstLoopResult, err := reconciler.Reconcile(context.TODO(), reconcile.Request{NamespacedName: key}) Expect(err).ToNot(HaveOccurred()) - Expect(firstLoopResult).To(Equal(reconcile.Result{RequeueAfter: time.Minute})) + expectedRes := reconcile.Result{RequeueAfter: time.Minute} + if testPlatform == platform.HyperShift { + // because there is no resource MC to wait for on hypershift + expectedRes = reconcile.Result{} + } + Expect(firstLoopResult).To(Equal(expectedRes)) - mc := &machineconfigv1.MachineConfig{} - key = client.ObjectKey{ - Name: objectnames.GetMachineConfigName(nro.Name, mcpWithComplexMachineConfigSelector.Name), + if testPlatform == platform.OpenShift { + mc := &machineconfigv1.MachineConfig{} + key = client.ObjectKey{ + Name: objectnames.GetMachineConfigName(nro.Name, mcpWithComplexMachineConfigSelector.Name), + } + Expect(reconciler.Client.Get(context.TODO(), key, mc)).ToNot(HaveOccurred()) } - Expect(reconciler.Client.Get(context.TODO(), key, mc)).ToNot(HaveOccurred()) }) }) @@ -1206,9 +1228,11 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() { nroUpdated := &nropv1.NUMAResourcesOperator{} Expect(reconciler.Client.Get(context.TODO(), client.ObjectKeyFromObject(nro), nroUpdated)).ToNot(HaveOccurred()) - Expect(len(nroUpdated.Status.MachineConfigPools)).To(Equal(1)) - Expect(nroUpdated.Status.MachineConfigPools[0].Name).To(Equal(mcp.Name)) - Expect(*nroUpdated.Status.MachineConfigPools[0].Config).To(Equal(conf), "operator status was not updated") + if testPlatform == platform.OpenShift { + Expect(len(nroUpdated.Status.MachineConfigPools)).To(Equal(1)) + Expect(nroUpdated.Status.MachineConfigPools[0].Name).To(Equal(mcp.Name)) + Expect(*nroUpdated.Status.MachineConfigPools[0].Config).To(Equal(conf), "operator status was not updated") + } Expect(nroUpdated.Status.NodeGroups[0].Config).To(Equal(conf), "operator status was not updated under NodeGroupStatus field") }) @@ -1703,7 +1727,12 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() { // on the first iteration we expect the CRDs and MCPs to be created, yet, it will wait one minute to update MC, thus RTE daemonsets and complete status update is not going to be achieved at this point firstLoopResult, err := reconciler.Reconcile(context.TODO(), reconcile.Request{NamespacedName: key}) Expect(err).ToNot(HaveOccurred()) - Expect(firstLoopResult).To(Equal(reconcile.Result{RequeueAfter: time.Minute})) + expectedRes := reconcile.Result{RequeueAfter: time.Minute} + if testPlatform == platform.HyperShift { + // because there is no resource MC to wait for on hypershift + expectedRes = reconcile.Result{} + } + Expect(firstLoopResult).To(Equal(expectedRes)) // Ensure mcp1 is ready Expect(reconciler.Client.Get(context.TODO(), client.ObjectKeyFromObject(mcp1), mcp1)).To(Succeed()) @@ -1762,7 +1791,12 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() { // removing the annotation will trigger reboot which requires resync after 1 min thirdLoopResult, err := reconciler.Reconcile(context.TODO(), reconcile.Request{NamespacedName: key}) Expect(err).ToNot(HaveOccurred()) - Expect(thirdLoopResult).To(Equal(reconcile.Result{RequeueAfter: time.Minute})) + expectedRes = reconcile.Result{RequeueAfter: time.Minute} + if testPlatform == platform.HyperShift { + // because there is no resource MC to wait for its updates on hypershift + expectedRes = reconcile.Result{} + } + Expect(thirdLoopResult).To(Equal(expectedRes)) }) It("should delete existing mc", func() { mc1Key := client.ObjectKey{ @@ -1803,7 +1837,12 @@ func reconcileObjects(nro *nropv1.NUMAResourcesOperator, mcp *machineconfigv1.Ma // we need to do the first iteration here because the DS object is created in the second firstLoopResult, err := reconciler.Reconcile(context.TODO(), reconcile.Request{NamespacedName: key}) Expect(err).ToNot(HaveOccurred()) - Expect(firstLoopResult).To(Equal(reconcile.Result{RequeueAfter: 1 * time.Minute})) + expectedRes := reconcile.Result{RequeueAfter: time.Minute} + if testPlatform == platform.HyperShift { + // because there is no resource MC to wait for on hypershift + expectedRes = reconcile.Result{} + } + Expect(firstLoopResult).To(Equal(expectedRes)) By("Ensure MachineConfigPools is ready") Expect(reconciler.Client.Get(context.TODO(), client.ObjectKeyFromObject(mcp), mcp)).ToNot(HaveOccurred())