@@ -3,11 +3,12 @@ package __performance_status
33import (
44 "context"
55 "encoding/json"
6+ "fmt"
67 "time"
78
89 "github.com/onsi/gomega/gcustom"
910 types2 "github.com/onsi/gomega/types"
10- tunedutils "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/tuned "
11+ "k8s.io/apimachinery/pkg/labels "
1112
1213 . "github.com/onsi/ginkgo/v2"
1314 . "github.com/onsi/gomega"
@@ -21,8 +22,11 @@ import (
2122
2223 ign2types "github.com/coreos/ignition/config/v2_2/types"
2324 machineconfigv1 "github.com/openshift/api/machineconfiguration/v1"
25+ performancev2 "github.com/openshift/cluster-node-tuning-operator/pkg/apis/performanceprofile/v2"
2426 tunedv1 "github.com/openshift/cluster-node-tuning-operator/pkg/apis/tuned/v1"
2527 "github.com/openshift/cluster-node-tuning-operator/pkg/performanceprofile/controller/performanceprofile/components"
28+ "github.com/openshift/cluster-node-tuning-operator/pkg/performanceprofile/controller/performanceprofile/hypershift"
29+ hypershiftconsts "github.com/openshift/cluster-node-tuning-operator/pkg/performanceprofile/controller/performanceprofile/hypershift/consts"
2630 testutils "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils"
2731 testclient "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/client"
2832 "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/discovery"
@@ -32,6 +36,7 @@ import (
3236 "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/nodepools"
3337 "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/nodes"
3438 "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/profiles"
39+ tunedutils "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/tuned"
3540 v1 "github.com/openshift/custom-resource-status/conditions/v1"
3641)
3742
@@ -139,6 +144,57 @@ var _ = Describe("Status testing of performance profile", Ordered, func() {
139144 profiles .WaitForCondition (testutils .NodeSelectorLabels , v1 .ConditionDegraded , corev1 .ConditionTrue )
140145 })
141146 })
147+
148+ Context ("Hypershift specific status validation" , func () {
149+ var profile * performancev2.PerformanceProfile
150+ ctx := context .Background ()
151+ BeforeEach (func () {
152+ profile , err = profiles .GetByNodeLabels (testutils .NodeSelectorLabels )
153+ Expect (err ).ToNot (HaveOccurred ())
154+ })
155+
156+ It ("Should have ConfigMap status when running on HyperShift platform" , Label (string (label .HyperShift )), func () {
157+ hcpNs , err := hypershiftutils .GetHostedControlPlaneNamespace ()
158+ Expect (err ).ToNot (HaveOccurred ())
159+
160+ np , err := nodepools .GetNodePool (ctx , testclient .ControlPlaneClient )
161+ Expect (err ).ToNot (HaveOccurred ())
162+
163+ cm := & corev1.ConfigMap {}
164+ cmName := hypershift .GetStatusConfigMapName (fmt .Sprintf ("%s-%s" , profile .GetName (), np .GetName ()))
165+ key := client.ObjectKey {Namespace : hcpNs , Name : cmName }
166+ Expect (testclient .ControlPlaneClient .Get (ctx , key , cm )).To (Succeed (), "failed to find ConfigMap %s/%s" , hcpNs , cmName )
167+
168+ It ("Should not create more than a single ConfigMap status per nodePool when PerformanceProfile gets replace or updated" , func () {
169+ np , err := nodepools .GetNodePool (ctx , testclient .ControlPlaneClient )
170+ Expect (err ).ToNot (HaveOccurred ())
171+
172+ newProfile := profile .DeepCopy ()
173+ newProfile .Name = fmt .Sprintf ("%s-2" , profile .Name )
174+ Expect (testclient .ControlPlaneClient .Create (ctx , newProfile )).To (Succeed ())
175+ Expect (nodepools .ReplaceTuningObject (ctx , testclient .ControlPlaneClient , newProfile , profile )).To (Succeed ())
176+
177+ By ("Waiting for node pool configuration to start updating" )
178+ Expect (nodepools .WaitForUpdatingConfig (ctx , testclient .ControlPlaneClient , np .Name , np .Namespace )).To (Succeed ())
179+
180+ Consistently (func () {
181+ cmList := & corev1.ConfigMapList {}
182+ opts := & client.ListOptions {
183+ Namespace : hcpNs ,
184+ LabelSelector : labels .SelectorFromSet (map [string ]string {
185+ hypershiftconsts .NTOGeneratedPerformanceProfileStatusConfigMapLabel : "true" ,
186+ hypershiftconsts .NodePoolNameLabel : np .GetName (),
187+ }),
188+ }
189+ Expect (testclient .ControlPlaneClient .List (ctx , cmList , opts )).To (Succeed ())
190+ Expect (cmList .Items ).To (HaveLen (1 ), "More than a single ConfigMap status was found" )
191+ }).WithPolling (time .Second * 10 ).WithTimeout (time .Minute * 2 )
192+
193+ By ("Waiting for the node pool configuration to be ready" )
194+ Expect (nodepools .WaitForConfigToBeReady (ctx , testclient .ControlPlaneClient , np .Name , np .Namespace )).To (Succeed ())
195+ })
196+ })
197+ })
142198})
143199
144200func createBadMachineConfig (name string ) * machineconfigv1.MachineConfig {
0 commit comments