88 "strings"
99 "time"
1010
11+ "github.com/docker/go-units"
1112 . "github.com/onsi/ginkgo/v2"
1213 . "github.com/onsi/gomega"
1314
@@ -26,6 +27,7 @@ import (
2627 "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/discovery"
2728 "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/images"
2829 "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/label"
30+ testlog "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/log"
2931 "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/nodes"
3032 "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/pods"
3133 "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/profiles"
@@ -155,29 +157,31 @@ var _ = Describe("[performance]Hugepages", Ordered, func() {
155157 }
156158 Expect (usageHugepages ).To (Equal (0 ), "Found used hugepages, expected 0" )
157159
158- By ("running the POD and waiting while it's installing testing tools" )
159160 testpod = getCentosPod (workerRTNode .Name )
160161 testpod .Namespace = testutils .NamespaceTesting
161162 testpod .Spec .Containers [0 ].Resources .Limits = map [corev1.ResourceName ]resource.Quantity {
162163 corev1 .ResourceName (fmt .Sprintf ("hugepages-%si" , hpSize )): resource .MustParse (fmt .Sprintf ("%si" , hpSize )),
163164 corev1 .ResourceMemory : resource .MustParse ("1Gi" ),
164165 }
166+ szInBytes , err := units .RAMInBytes (string (hpSize ))
167+ Expect (err ).ToNot (HaveOccurred ())
168+ cmd2 := []string {"/bin/bash" , "-c" , fmt .Sprintf ("/usr/bin/hugepages-allocator --hugepage-size=%d" , szInBytes )}
169+ testpod .Spec .Containers [0 ].Command = cmd2
170+
171+ By ("creating a pod with HugePages allocation request" )
165172 err = testclient .DataPlaneClient .Create (context .TODO (), testpod )
166173 Expect (err ).ToNot (HaveOccurred ())
167174 testpod , err = pods .WaitForCondition (context .TODO (), client .ObjectKeyFromObject (testpod ), corev1 .PodReady , corev1 .ConditionTrue , 10 * time .Minute )
168175 Expect (err ).ToNot (HaveOccurred ())
176+ testlog .Infof ("pod %s executed with command: %s" , testpod .Name , cmd2 )
169177
170- cmd2 := []string {"/bin/bash" , "-c" , "tmux new -d 'LD_PRELOAD=libhugetlbfs.so HUGETLB_MORECORE=yes top -b > /dev/null'" }
171- _ , err = pods .ExecCommandOnPod (testclient .K8sClient , testpod , "" , cmd2 )
172- Expect (err ).ToNot (HaveOccurred ())
173-
174- By ("checking free hugepages - one should be used by pod" )
175178 availableHugepagesFile := fmt .Sprintf ("/sys/kernel/mm/hugepages/hugepages-%skB/nr_hugepages" , hpSizeKb )
176179 availableHugepages := checkHugepagesStatus (context .TODO (), availableHugepagesFile , workerRTNode )
177-
178180 freeHugepagesFile := fmt .Sprintf ("/sys/kernel/mm/hugepages/hugepages-%skB/free_hugepages" , hpSizeKb )
181+ By ("checking hugepages allocation updated correctly" )
179182 Eventually (func () int {
180183 freeHugepages := checkHugepagesStatus (context .TODO (), freeHugepagesFile , workerRTNode )
184+ testlog .Infof ("available hugepages %d, free hugepages %d" , availableHugepages , freeHugepages )
181185 return availableHugepages - freeHugepages
182186 }, cluster .ComputeTestTimeout (30 * time .Second , RunningOnSingleNode ), time .Second ).Should (Equal (1 ))
183187
0 commit comments