Skip to content

Commit e3b1833

Browse files
committed
updates to files
1 parent f030970 commit e3b1833

File tree

3 files changed

+50
-15
lines changed

3 files changed

+50
-15
lines changed

support/client.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ import (
2626
"k8s.io/client-go/tools/clientcmd"
2727

2828
imagev1 "github.com/openshift/client-go/image/clientset/versioned"
29+
machinev1 "github.com/openshift/client-go/machine/clientset/versioned"
2930
routev1 "github.com/openshift/client-go/route/clientset/versioned"
3031
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
3132
// to ensure that exec-entrypoint and run can make use of them.
3233
)
3334

3435
type Client interface {
3536
Core() kubernetes.Interface
37+
Machine() machinev1.Interface
3638
Route() routev1.Interface
3739
Image() imagev1.Interface
3840
MCAD() mcadclient.Interface
@@ -42,6 +44,7 @@ type Client interface {
4244

4345
type testClient struct {
4446
core kubernetes.Interface
47+
machine machinev1.Interface
4548
route routev1.Interface
4649
image imagev1.Interface
4750
mcad mcadclient.Interface
@@ -55,6 +58,10 @@ func (t *testClient) Core() kubernetes.Interface {
5558
return t.core
5659
}
5760

61+
func (t *testClient) Machine() machinev1.Interface {
62+
return t.machine
63+
}
64+
5865
func (t *testClient) Route() routev1.Interface {
5966
return t.route
6067
}
@@ -88,6 +95,11 @@ func newTestClient() (Client, error) {
8895
return nil, err
8996
}
9097

98+
machineClient, err := machinev1.NewForConfig(cfg)
99+
if err != nil {
100+
return nil, err
101+
}
102+
91103
routeClient, err := routev1.NewForConfig(cfg)
92104
if err != nil {
93105
return nil, err
@@ -115,6 +127,7 @@ func newTestClient() (Client, error) {
115127

116128
return &testClient{
117129
core: kubeClient,
130+
machine: machineClient,
118131
route: routeClient,
119132
image: imageClient,
120133
mcad: mcadClient,

support/environment.go

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ 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+
ClusterTypeEnvVar = "CLUSTER_TYPE"
44+
)
45+
46+
type ClusterType string
47+
48+
const (
49+
OsdCluster ClusterType = "OSD"
50+
OcpCluster ClusterType = "OCP"
51+
HypershiftCluster ClusterType = "HYPERSHIFT"
52+
UndefinedCluster ClusterType = "UNDEFINED"
4153
)
4254

4355
func GetCodeFlareSDKVersion() string {
@@ -65,12 +77,23 @@ func GetOsdClusterId() (string, bool) {
6577
return os.LookupEnv(OsdClusterID)
6678
}
6779

68-
func IsOsd() bool {
69-
osdClusterId, found := GetOsdClusterId()
70-
if found && osdClusterId != "" {
71-
return true
80+
func GetClusterType(t Test) ClusterType {
81+
clusterType, ok := os.LookupEnv(ClusterTypeEnvVar)
82+
if !ok {
83+
t.T().Logf("Expected environment variable %s not found, cluster type is not defined.", ClusterTypeEnvVar)
84+
return UndefinedCluster
85+
}
86+
switch clusterType {
87+
case "OSD":
88+
return OsdCluster
89+
case "OCP":
90+
return OcpCluster
91+
case "HYPERSHIFT":
92+
return HypershiftCluster
93+
default:
94+
t.T().Logf("Expected environment variable %s contains unexpected value: '%s'", ClusterTypeEnvVar, clusterType)
95+
return UndefinedCluster
7296
}
73-
return false
7497
}
7598

7699
func lookupEnvOrDefault(key, value string) string {

support/ray.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,27 @@ package support
1818

1919
import (
2020
"github.com/onsi/gomega"
21-
v1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
22-
rayv1alpha1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1alpha1"
21+
rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
2322

2423
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2524
)
2625

2726
const RayJobDefaultClusterSelectorKey = "ray.io/cluster"
2827

29-
func RayJob(t Test, namespace, name string) func(g gomega.Gomega) *v1.RayJob {
30-
return func(g gomega.Gomega) *v1.RayJob {
28+
func RayJob(t Test, namespace, name string) func(g gomega.Gomega) *rayv1.RayJob {
29+
return func(g gomega.Gomega) *rayv1.RayJob {
3130
job, err := t.Client().Ray().RayV1().RayJobs(namespace).Get(t.Ctx(), name, metav1.GetOptions{})
3231
g.Expect(err).NotTo(gomega.HaveOccurred())
3332
return job
3433
}
3534
}
3635

37-
func GetRayJob(t Test, namespace, name string) *v1.RayJob {
36+
func GetRayJob(t Test, namespace, name string) *rayv1.RayJob {
3837
t.T().Helper()
3938
return RayJob(t, namespace, name)(t)
4039
}
4140

42-
func RayJobStatus(job *rayv1alpha1.RayJob) rayv1alpha1.JobStatus {
41+
func RayJobStatus(job *rayv1.RayJob) rayv1.JobStatus {
4342
return job.Status.JobStatus
4443
}
4544

@@ -49,20 +48,20 @@ func GetRayJobId(t Test, namespace, name string) string {
4948
return job.Status.JobId
5049
}
5150

52-
func RayCluster(t Test, namespace, name string) func(g gomega.Gomega) *v1.RayCluster {
53-
return func(g gomega.Gomega) *v1.RayCluster {
51+
func RayCluster(t Test, namespace, name string) func(g gomega.Gomega) *rayv1.RayCluster {
52+
return func(g gomega.Gomega) *rayv1.RayCluster {
5453
cluster, err := t.Client().Ray().RayV1().RayClusters(namespace).Get(t.Ctx(), name, metav1.GetOptions{})
5554
g.Expect(err).NotTo(gomega.HaveOccurred())
5655
return cluster
5756
}
5857
}
5958

60-
func GetRayCluster(t Test, namespace, name string) *v1.RayCluster {
59+
func GetRayCluster(t Test, namespace, name string) *rayv1.RayCluster {
6160
t.T().Helper()
6261
return RayCluster(t, namespace, name)(t)
6362
}
6463

65-
func RayClusterState(cluster *rayv1alpha1.RayCluster) rayv1alpha1.ClusterState {
64+
func RayClusterState(cluster *rayv1.RayCluster) rayv1.ClusterState {
6665
return cluster.Status.State
6766
}
6867

0 commit comments

Comments
 (0)