Skip to content

Commit c6b4aca

Browse files
committed
Add common functions for SDK test
1 parent 5463537 commit c6b4aca

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

support/core.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,23 @@ func CreatePersistentVolumeClaim(t Test, namespace string, storageSize string, a
164164

165165
return pvc
166166
}
167+
168+
func GetNodes(t Test) []corev1.Node {
169+
t.T().Helper()
170+
nodes, err := t.Client().Core().CoreV1().Nodes().List(t.Ctx(), metav1.ListOptions{})
171+
t.Expect(err).NotTo(gomega.HaveOccurred())
172+
return nodes.Items
173+
}
174+
175+
func GetNodeInternalIP(t Test, node corev1.Node) (IP string) {
176+
t.T().Helper()
177+
178+
for _, address := range node.Status.Addresses {
179+
if address.Type == "InternalIP" {
180+
IP = address.Address
181+
}
182+
}
183+
t.Expect(IP).Should(gomega.Not(gomega.BeEmpty()), "Node internal IP address not found")
184+
185+
return
186+
}

support/defaults.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package support
55
// ***********************
66

77
const (
8-
CodeFlareSDKVersion = "0.9.0"
8+
CodeFlareSDKVersion = "0.12.0"
99
RayVersion = "2.5.0"
1010
RayImage = "rayproject/ray:2.5.0"
1111
)

support/environment.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ const (
4141

4242
// Type of cluster test is run on
4343
ClusterTypeEnvVar = "CLUSTER_TYPE"
44+
45+
// Hostname of the Kubernetes cluster
46+
ClusterHostname = "CLUSTER_HOSTNAME"
4447
)
4548

4649
type ClusterType string
@@ -49,6 +52,7 @@ const (
4952
OsdCluster ClusterType = "OSD"
5053
OcpCluster ClusterType = "OCP"
5154
HypershiftCluster ClusterType = "HYPERSHIFT"
55+
KindCluster ClusterType = "KIND"
5256
UndefinedCluster ClusterType = "UNDEFINED"
5357
)
5458

@@ -90,12 +94,22 @@ func GetClusterType(t Test) ClusterType {
9094
return OcpCluster
9195
case "HYPERSHIFT":
9296
return HypershiftCluster
97+
case "KIND":
98+
return KindCluster
9399
default:
94100
t.T().Logf("Expected environment variable %s contains unexpected value: '%s'", ClusterTypeEnvVar, clusterType)
95101
return UndefinedCluster
96102
}
97103
}
98104

105+
func GetClusterHostname(t Test) string {
106+
hostname, ok := os.LookupEnv(ClusterHostname)
107+
if !ok {
108+
t.T().Fatalf("Expected environment variable %s not found, please define cluster hostname.", ClusterHostname)
109+
}
110+
return hostname
111+
}
112+
99113
func lookupEnvOrDefault(key, value string) string {
100114
if v, ok := os.LookupEnv(key); ok {
101115
return v

0 commit comments

Comments
 (0)