Skip to content

Commit c5069a5

Browse files
committed
e2e: DRA manage resources test
The test apply DRA management annotation and checks that NTO disables all managers. After that, it reverts changes in the profile and checks that NTO applies the managers configuration back to their original configuration. Signed-off-by: Talor Itzhak <[email protected]>
1 parent 19ced4d commit c5069a5

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

test/e2e/performanceprofile/functests/1_performance/topology_manager.go

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ package __performance
22

33
import (
44
"context"
5+
"fmt"
6+
57
. "github.com/onsi/ginkgo/v2"
68
. "github.com/onsi/gomega"
79

810
performancev2 "github.com/openshift/cluster-node-tuning-operator/pkg/apis/performanceprofile/v2"
911
testutils "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils"
1012
"github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/discovery"
1113
"github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/nodes"
14+
"github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/poolname"
1215
"github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/profiles"
16+
"github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/profilesupdate"
1317

1418
corev1 "k8s.io/api/core/v1"
1519
kubeletconfigv1beta1 "k8s.io/kubelet/config/v1beta1"
@@ -45,4 +49,88 @@ var _ = Describe("[rfe_id:27350][performance]Topology Manager", Ordered, func()
4549
Expect(kubeletConfig.TopologyManagerPolicy).To(Equal(kubeletconfigv1beta1.BestEffortTopologyManagerPolicy), "Topology Manager policy mismatch got %q expected %q", kubeletconfigv1beta1.BestEffortTopologyManagerPolicy)
4650
}
4751
})
52+
53+
Context("Deactivating topology and resource managers", func() {
54+
var initialProfile *performancev2.PerformanceProfile
55+
var targetNode *corev1.Node
56+
57+
BeforeEach(func() {
58+
var err error
59+
profile, err = profiles.GetByNodeLabels(testutils.NodeSelectorLabels)
60+
Expect(err).ToNot(HaveOccurred())
61+
62+
workerRTNodes, err := nodes.GetByLabels(testutils.NodeSelectorLabels)
63+
Expect(err).ToNot(HaveOccurred())
64+
65+
workerRTNodes, err = nodes.MatchingOptionalSelector(workerRTNodes)
66+
Expect(err).ToNot(HaveOccurred(), "Error looking for the optional selector: %v", err)
67+
Expect(workerRTNodes).ToNot(BeEmpty(), "No RT worker node found!")
68+
targetNode = &workerRTNodes[0]
69+
70+
initialProfile = profile.DeepCopy()
71+
72+
By("Adding the DRA resource management annotation to the profile")
73+
if profile.Annotations == nil {
74+
profile.Annotations = make(map[string]string)
75+
}
76+
profile.Annotations[performancev2.PerformanceProfileDRAResourceManagementAnnotation] = "true"
77+
78+
By("Updating the performance profile")
79+
profiles.UpdateWithRetry(profile)
80+
81+
poolName := poolname.GetByProfile(context.TODO(), profile)
82+
By(fmt.Sprintf("Applying changes in performance profile and waiting until %s will start updating", poolName))
83+
profilesupdate.WaitForTuningUpdating(context.TODO(), profile)
84+
85+
By(fmt.Sprintf("Waiting when %s finishes updates", poolName))
86+
profilesupdate.WaitForTuningUpdated(context.TODO(), profile)
87+
88+
DeferCleanup(func() {
89+
By("Reverting the performance profile")
90+
profiles.UpdateWithRetry(initialProfile)
91+
92+
poolName := poolname.GetByProfile(context.TODO(), initialProfile)
93+
By(fmt.Sprintf("Applying changes in performance profile and waiting until %s will start updating", poolName))
94+
profilesupdate.WaitForTuningUpdating(context.TODO(), initialProfile)
95+
96+
By(fmt.Sprintf("Waiting when %s finishes updates", poolName))
97+
profilesupdate.WaitForTuningUpdated(context.TODO(), initialProfile)
98+
99+
By("Verifying managers are restored to their original configuration")
100+
kubeletConfig, err := nodes.GetKubeletConfig(context.TODO(), targetNode)
101+
Expect(err).ToNot(HaveOccurred())
102+
103+
By("Verifying CPU manager policy is restored to static")
104+
Expect(kubeletConfig.CPUManagerPolicy).To(Equal("static"), "CPUManagerPolicy should be 'static' after revert, got %q", kubeletConfig.CPUManagerPolicy)
105+
106+
By("Verifying Topology manager policy is restored")
107+
expectedTopologyPolicy := kubeletconfigv1beta1.BestEffortTopologyManagerPolicy
108+
if initialProfile.Spec.NUMA != nil && initialProfile.Spec.NUMA.TopologyPolicy != nil {
109+
expectedTopologyPolicy = *initialProfile.Spec.NUMA.TopologyPolicy
110+
}
111+
Expect(kubeletConfig.TopologyManagerPolicy).To(Equal(expectedTopologyPolicy), "TopologyManagerPolicy should be %q after revert, got %q", expectedTopologyPolicy, kubeletConfig.TopologyManagerPolicy)
112+
113+
By("Verifying Memory manager policy is restored")
114+
// Memory manager is set to Static only for restricted or single-numa-node topology policies
115+
if expectedTopologyPolicy == kubeletconfigv1beta1.RestrictedTopologyManagerPolicy ||
116+
expectedTopologyPolicy == kubeletconfigv1beta1.SingleNumaNodeTopologyManagerPolicy {
117+
Expect(kubeletConfig.MemoryManagerPolicy).To(Equal("Static"), "MemoryManagerPolicy should be 'Static' after revert, got %q", kubeletConfig.MemoryManagerPolicy)
118+
}
119+
})
120+
})
121+
122+
It("should disable CPU, Memory, and Topology managers when DRA annotation is set", func() {
123+
kubeletConfig, err := nodes.GetKubeletConfig(context.TODO(), targetNode)
124+
Expect(err).ToNot(HaveOccurred())
125+
126+
By("Verifying CPU manager policy is set to none")
127+
Expect(kubeletConfig.CPUManagerPolicy).To(Equal("none"), "CPUManagerPolicy should be 'none' when DRA is enabled, got %q", kubeletConfig.CPUManagerPolicy)
128+
129+
By("Verifying Topology manager policy is set to none")
130+
Expect(kubeletConfig.TopologyManagerPolicy).To(Equal(kubeletconfigv1beta1.NoneTopologyManagerPolicy), "TopologyManagerPolicy should be 'none' when DRA is enabled, got %q", kubeletConfig.TopologyManagerPolicy)
131+
132+
By("Verifying Memory manager policy is set to None")
133+
Expect(kubeletConfig.MemoryManagerPolicy).To(Equal(kubeletconfigv1beta1.NoneMemoryManagerPolicy), "MemoryManagerPolicy should be 'None' when DRA is enabled, got %q", kubeletConfig.MemoryManagerPolicy)
134+
})
135+
})
48136
})

0 commit comments

Comments
 (0)