Skip to content

Commit 72aa290

Browse files
committed
e2e: serial: config: get cluster topics at startup
cluster topics are expected not to change mid-run of the serial tests, so collecting them once at startup seems like a good compromise. The topics will be available through the shared serial config object. Signed-off-by: Francesco Romani <fromani@redhat.com>
1 parent 173152b commit 72aa290

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

test/e2e/serial/config/fixture.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
nrtv1alpha2 "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/topology/v1alpha2"
2525

2626
nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
27+
"github.com/openshift-kni/numaresources-operator/internal/api/features"
2728
intnrt "github.com/openshift-kni/numaresources-operator/internal/noderesourcetopology"
2829
e2efixture "github.com/openshift-kni/numaresources-operator/test/internal/fixture"
2930
"github.com/openshift-kni/numaresources-operator/test/internal/objects"
@@ -35,6 +36,7 @@ type E2EConfig struct {
3536
NROOperObj *nropv1.NUMAResourcesOperator
3637
NROSchedObj *nropv1.NUMAResourcesScheduler
3738
SchedulerName string
39+
ClusterTopics features.TopicInfo
3840
infraNRTList nrtv1alpha2.NodeResourceTopologyList
3941
}
4042

@@ -102,5 +104,10 @@ func NewFixtureWithOptions(ctx context.Context, nsName string, options e2efixtur
102104
cfg.SchedulerName = cfg.NROSchedObj.Status.SchedulerName
103105
klog.InfoS("detected scheduler name", "schedulerName", cfg.SchedulerName)
104106

107+
cfg.ClusterTopics, err = FetchClusterTopics(ctx, cfg.Fixture, cfg.NROOperObj)
108+
if err != nil {
109+
return nil, err
110+
}
111+
105112
return &cfg, nil
106113
}

test/e2e/serial/config/infra.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package config
1818

1919
import (
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

Comments
 (0)