Skip to content

Commit

Permalink
ctrl-test: adjust tests expectations on Hypershift
Browse files Browse the repository at this point in the history
TBD

Signed-off-by: Shereen Haj <[email protected]>
  • Loading branch information
shajmakh committed Nov 14, 2024
1 parent 7e6c538 commit 09b336e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 14 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
67 changes: 53 additions & 14 deletions controllers/numaresourcesoperator_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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{}
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
})
})

Expand Down Expand Up @@ -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")

})
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 09b336e

Please sign in to comment.