@@ -18,6 +18,7 @@ package config
1818
1919import (
2020 "context"
21+ "encoding/json"
2122 "fmt"
2223 "os"
2324 "sync"
@@ -32,11 +33,14 @@ import (
3233 nrtv1alpha2 "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/topology/v1alpha2"
3334
3435 nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
36+ "github.com/openshift-kni/numaresources-operator/internal/api/features"
3537 "github.com/openshift-kni/numaresources-operator/internal/nodegroups"
38+ "github.com/openshift-kni/numaresources-operator/internal/remoteexec"
3639 "github.com/openshift-kni/numaresources-operator/internal/wait"
3740 "github.com/openshift-kni/numaresources-operator/pkg/objectnames"
3841 numacellapi "github.com/openshift-kni/numaresources-operator/test/deviceplugin/pkg/numacell/api"
3942 numacellmanifests "github.com/openshift-kni/numaresources-operator/test/deviceplugin/pkg/numacell/manifests"
43+ "github.com/openshift-kni/numaresources-operator/test/internal/deploy"
4044 e2efixture "github.com/openshift-kni/numaresources-operator/test/internal/fixture"
4145 "github.com/openshift-kni/numaresources-operator/test/internal/images"
4246
@@ -211,3 +215,38 @@ func unlabelNodeByName(cli client.Client, nodeName string) {
211215 g .Expect (err ).ToNot (HaveOccurred ())
212216 }).WithTimeout (3 * time .Minute ).WithPolling (30 * time .Second ).Should (Succeed (), "failed to unlabel node %q: %v" , nodeName , err )
213217}
218+
219+ func FetchClusterTopics (ctx context.Context , fxt * e2efixture.Fixture , nropObj * nropv1.NUMAResourcesOperator ) (features.TopicInfo , error ) {
220+ pod , err := deploy .FindNUMAResourcesOperatorPod (ctx , fxt .Client , nropObj )
221+ if err != nil {
222+ return features .NewTopicInfo (), err
223+ }
224+
225+ cmdline := []string {
226+ "/bin/numaresources-operator" ,
227+ "--inspect-features" ,
228+ }
229+ stdout , stderr , err := remoteexec .CommandOnPod (ctx , fxt .K8sClient , pod , cmdline ... )
230+ // older version may miss introspection support that's fine
231+ if err != nil {
232+ return features .NewTopicInfo (), nil
233+ }
234+
235+ if len (stderr ) > 0 {
236+ klog .InfoS ("while fetching cluster topics" , "stderr" , stderr )
237+ }
238+
239+ var tp features.TopicInfo
240+ err = json .Unmarshal (stdout , & tp )
241+ if err != nil {
242+ return features .NewTopicInfo (), err
243+ }
244+ klog .InfoS ("active features from the deployed operator" , "features" , string (stdout ))
245+
246+ tp .Metadata .Version = features .Version
247+ err = tp .Validate ()
248+ if err != nil {
249+ return features .NewTopicInfo (), err
250+ }
251+ return tp , nil
252+ }
0 commit comments