Skip to content

Commit 3e187a3

Browse files
committed
determining cluster type
1 parent c8ec148 commit 3e187a3

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

test/e2e/instascale_machineset_test.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import (
66
. "github.com/onsi/gomega"
77
mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1"
88

9-
"k8s.io/apimachinery/pkg/api/errors"
10-
119
. "github.com/project-codeflare/codeflare-operator/test/support"
1210
)
1311

@@ -16,9 +14,9 @@ func TestInstascaleMachineSet(t *testing.T) {
1614
test.T().Parallel()
1715

1816
// skip test if not using machine sets
19-
ms, err := MachineSetsExist(test)
20-
if !ms || err != nil && errors.IsNotFound(err) {
21-
test.T().Skip("Skipping test as machine sets don't exist")
17+
clusterType := DetermineClusterType()
18+
if clusterType != OcpCluster {
19+
test.T().Skip("Skipping test as not running on an OCP cluster")
2220
}
2321

2422
namespace := test.NewTestNamespace()

test/support/environment.go

+30
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ const (
3838

3939
// Cluster ID for OSD cluster used in tests, used for testing InstaScale
4040
OsdClusterID = "CLUSTERID"
41+
42+
// Type of cluster test is run on
43+
ClusterType = "CLUSTER_TYPE"
44+
// OpenShift Dedicated Cluster
45+
OsdCluster = "OSD"
46+
// OpenShift Container Platform Cluster
47+
OcpCluster = "OCP"
48+
// ROSA Hosted Hypershift Cluster
49+
HypershiftCluster = "HYPERSHIFT"
4150
)
4251

4352
func GetCodeFlareSDKVersion() string {
@@ -65,6 +74,10 @@ func GetOsdClusterId() (string, bool) {
6574
return os.LookupEnv(OsdClusterID)
6675
}
6776

77+
func GetClusterType() (string, bool) {
78+
return os.LookupEnv(ClusterType)
79+
}
80+
6881
func IsOsd() bool {
6982
osdClusterId, found := GetOsdClusterId()
7083
if found && osdClusterId != "" {
@@ -79,3 +92,20 @@ func lookupEnvOrDefault(key, value string) string {
7992
}
8093
return value
8194
}
95+
96+
func DetermineClusterType() string {
97+
clusterType, ok := GetClusterType()
98+
if !ok {
99+
return ""
100+
}
101+
switch clusterType {
102+
case "OSD":
103+
return OsdCluster
104+
case "OCP":
105+
return OcpCluster
106+
case "HYPERSHIFT":
107+
return HypershiftCluster
108+
default:
109+
return ""
110+
}
111+
}

0 commit comments

Comments
 (0)