Skip to content

Commit b593115

Browse files
Merge pull request #1398 from openshift-cherrypick-robot/cherry-pick-1396-to-release-4.20
[release-4.20] OCPBUGS-62214: E2E: Add function to check control plane nodes are schedulable.
2 parents 4463f9b + edfbe28 commit b593115

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

test/e2e/performanceprofile/functests/2_performance_update/updating_profile.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
testutils "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils"
3232
"github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/cgroup/runtime"
3333
testclient "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/client"
34+
"github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/cluster"
3435
"github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/discovery"
3536
"github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/hypershift"
3637
"github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/label"
@@ -404,6 +405,12 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance
404405
if len(nonPerformancesWorkers) > 1 {
405406
newCnfNode = &nonPerformancesWorkers[0]
406407
}
408+
ok, err := cluster.IsControlPlaneSchedulable(context.TODO())
409+
Expect(err).ToNot(HaveOccurred(), "Unable to fetch schedulable information of control plane nodes: %v", err)
410+
if ok {
411+
Skip("Skipping the test - Control plane nodes are schedulable")
412+
}
413+
407414
if newCnfNode == nil {
408415
Skip("Skipping the test - cluster does not have another available worker node ")
409416
}

test/e2e/performanceprofile/functests/utils/cluster/cluster.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import (
44
"context"
55
"time"
66

7+
clientconfigv1 "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1"
8+
testclient "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/client"
79
corev1 "k8s.io/api/core/v1"
10+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
811
"sigs.k8s.io/controller-runtime/pkg/client"
9-
10-
testclient "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/client"
12+
"sigs.k8s.io/controller-runtime/pkg/client/config"
1113
)
1214

1315
// IsSingleNode validates if the environment is single node cluster
@@ -29,3 +31,19 @@ func ComputeTestTimeout(baseTimeout time.Duration, isSno bool) time.Duration {
2931

3032
return testTimeout
3133
}
34+
35+
// Check if the control plane nodes are schedulable, returns true if schedulable else false
36+
func IsControlPlaneSchedulable(ctx context.Context) (bool, error) {
37+
// Get the rest.Config using the helper function
38+
cfg, err := config.GetConfig()
39+
if err != nil {
40+
return false, err
41+
}
42+
43+
openshiftConfigClient := clientconfigv1.NewForConfigOrDie(cfg)
44+
schedulerInfo, err := openshiftConfigClient.Schedulers().Get(ctx, "cluster", metav1.GetOptions{})
45+
if err != nil {
46+
return false, err
47+
}
48+
return schedulerInfo.Spec.MastersSchedulable, nil
49+
}

0 commit comments

Comments
 (0)