Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
testutils "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils"
"github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/cgroup/runtime"
testclient "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/client"
"github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/cluster"
"github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/discovery"
"github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/hypershift"
"github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/label"
Expand Down Expand Up @@ -404,6 +405,12 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance
if len(nonPerformancesWorkers) > 1 {
newCnfNode = &nonPerformancesWorkers[0]
}
ok, err := cluster.IsControlPlaneSchedulable(context.TODO())
Expect(err).ToNot(HaveOccurred(), "Unable to fetch schedulable information of control plane nodes: %v", err)
if ok {
Skip("Skipping the test - Control plane nodes are schedulable")
}

if newCnfNode == nil {
Skip("Skipping the test - cluster does not have another available worker node ")
}
Expand Down
22 changes: 20 additions & 2 deletions test/e2e/performanceprofile/functests/utils/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import (
"context"
"time"

clientconfigv1 "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1"
testclient "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/client"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

testclient "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/client"
"sigs.k8s.io/controller-runtime/pkg/client/config"
)

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

return testTimeout
}

// Check if the control plane nodes are schedulable, returns true if schedulable else false
func IsControlPlaneSchedulable(ctx context.Context) (bool, error) {
// Get the rest.Config using the helper function
cfg, err := config.GetConfig()
if err != nil {
return false, err
}

openshiftConfigClient := clientconfigv1.NewForConfigOrDie(cfg)
schedulerInfo, err := openshiftConfigClient.Schedulers().Get(ctx, "cluster", metav1.GetOptions{})
if err != nil {
return false, err
}
return schedulerInfo.Spec.MastersSchedulable, nil
}