Skip to content

Commit

Permalink
update unit testing - p2wq
Browse files Browse the repository at this point in the history
  • Loading branch information
shajmakh committed Oct 17, 2023
1 parent 741b4c4 commit 9564ae0
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions controllers/numaresourcesoperator_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,24 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() {
args := ds.Spec.Template.Spec.Containers[0].Args
Expect(args).ToNot(ContainElement(ContainSubstring("--notify-file")), "malformed args: %v", args)
})

It("should find default behavior of RTE pause disabled", func() {
conf := nropv1.DefaultNodeGroupConfig()

nro := testobjs.NewNUMAResourcesOperatorWithNodeGroupConfig(objectnames.DefaultNUMAResourcesOperatorCrName, &labSel, &conf)

reconciler := reconcileObjects(nro, mcp)

key := client.ObjectKeyFromObject(nro)

nroCurrent := &nropv1.NUMAResourcesOperator{}
Expect(reconciler.Client.Get(context.TODO(), key, nroCurrent)).NotTo(HaveOccurred())
Expect(nroCurrent.Spec.NodeGroups[0].Config.RTEPause).To(Equal(conf.RTEPause))

//we do not check the ds here because we don't want to update ds and cause a restart of the pods,
// we only pause the pods sync with NRTs
})

It("should allow to disable RTE update machanism", func() {
rteMode := nropv1.RTEPauseEnabled
conf := nropv1.NodeGroupConfig{
Expand All @@ -807,12 +825,14 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() {

reconciler := reconcileObjects(nro, mcp)

mcpDSKey := client.ObjectKey{
Name: objectnames.GetComponentName(nro.Name, mcp.Name),
Namespace: testNamespace,
}
ds := &appsv1.DaemonSet{}
Expect(reconciler.Client.Get(context.TODO(), mcpDSKey, ds)).ToNot(HaveOccurred())
key := client.ObjectKeyFromObject(nro)

nroCurrent := &nropv1.NUMAResourcesOperator{}
Expect(reconciler.Client.Get(context.TODO(), key, nroCurrent)).NotTo(HaveOccurred())
Expect(nroCurrent.Spec.NodeGroups[0].Config.RTEPause).To(Equal(&rteMode))

// we do not check the ds here because we don't want to update ds and cause a restart of the pods,
// we only pause the pods sync with NRTs
})
It("should allow to update all the settings of the DS objects", func() {
conf := nropv1.DefaultNodeGroupConfig()
Expand All @@ -838,9 +858,11 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() {
Duration: d,
}
refMode := nropv1.InfoRefreshPeriodic
rteMode := nropv1.RTEPauseEnabled
confUpdated := nropv1.NodeGroupConfig{
InfoRefreshPeriod: &period,
InfoRefreshMode: &refMode,
RTEPause: &rteMode,
}

key := client.ObjectKeyFromObject(nro)
Expand Down

0 comments on commit 9564ae0

Please sign in to comment.