Skip to content

Commit 06a8659

Browse files
committed
test: Parameterize Ray image and version
1 parent 08ed883 commit 06a8659

File tree

5 files changed

+62
-13
lines changed

5 files changed

+62
-13
lines changed

Makefile

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ MCAD_REF ?= release-${MCAD_VERSION}
2121
MCAD_REPO ?= github.com/project-codeflare/multi-cluster-app-dispatcher
2222
MCAD_CRD ?= ${MCAD_REPO}/config/crd?ref=${MCAD_REF}
2323

24-
# KUBERAY_VERSION defines the default version of the KubeRay operator
24+
# KUBERAY_VERSION defines the default version of the KubeRay operator (used for testing)
2525
KUBERAY_VERSION ?= v0.5.0
2626

27+
# RAY_VERSION defines the default version of Ray (used for testing)
28+
RAY_VERSION ?= 2.5.0
29+
2730
# CODEFLARE_SDK_VERSION defines the default version of the CodeFlare SDK
2831
CODEFLARE_SDK_VERSION ?= 0.4.4
2932

@@ -67,6 +70,9 @@ MCAD_IMAGE ?= $(IMAGE_ORG_BASE)/mcad-controller:$(MCAD_REF)
6770
# INSTASCALE_IMAGE defines the default container image for the InstaScale controller
6871
INSTASCALE_IMAGE ?= $(IMAGE_ORG_BASE)/instascale-controller:$(INSTASCALE_VERSION)
6972

73+
# RAY_IMAGE defines the default container image for Ray (used for testing)
74+
RAY_IMAGE ?= rayproject/ray:$(RAY_VERSION)
75+
7076
# BUNDLE_IMG defines the image:tag used for the bundle.
7177
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
7278
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:$(VERSION)
@@ -122,6 +128,7 @@ help: ## Display this help.
122128
##@ Development
123129

124130
DEFAULTS_FILE := controllers/defaults.go
131+
DEFAULTS_TEST_FILE := test/support/defaults.go
125132

126133
.PHONY: defaults
127134
defaults:
@@ -135,12 +142,26 @@ defaults:
135142
@echo "const (" >> $(DEFAULTS_FILE)
136143
@echo " MCADImage = \"$(MCAD_IMAGE)\"" >> $(DEFAULTS_FILE)
137144
@echo " InstaScaleImage = \"$(INSTASCALE_IMAGE)\"" >> $(DEFAULTS_FILE)
138-
@echo " CodeFlareSDKVersion = \"$(CODEFLARE_SDK_VERSION)\"" >> $(DEFAULTS_FILE)
139145
@echo "" >> $(DEFAULTS_FILE)
140146
@echo ")" >> $(DEFAULTS_FILE)
141147
@echo "" >> $(DEFAULTS_FILE)
142148

143-
gofmt -w $(DEFAULTS_FILE)
149+
$(info Regenerating $(DEFAULTS_TEST_FILE))
150+
@echo "package support" > $(DEFAULTS_TEST_FILE)
151+
@echo "" >> $(DEFAULTS_TEST_FILE)
152+
@echo "// ***********************" >> $(DEFAULTS_TEST_FILE)
153+
@echo "// DO NOT EDIT THIS FILE" >> $(DEFAULTS_TEST_FILE)
154+
@echo "// ***********************" >> $(DEFAULTS_TEST_FILE)
155+
@echo "" >> $(DEFAULTS_TEST_FILE)
156+
@echo "const (" >> $(DEFAULTS_TEST_FILE)
157+
@echo " CodeFlareSDKVersion = \"$(CODEFLARE_SDK_VERSION)\"" >> $(DEFAULTS_TEST_FILE)
158+
@echo " RayVersion = \"$(RAY_VERSION)\"" >> $(DEFAULTS_TEST_FILE)
159+
@echo " RayImage = \"$(RAY_IMAGE)\"" >> $(DEFAULTS_TEST_FILE)
160+
@echo "" >> $(DEFAULTS_TEST_FILE)
161+
@echo ")" >> $(DEFAULTS_TEST_FILE)
162+
@echo "" >> $(DEFAULTS_TEST_FILE)
163+
164+
gofmt -w $(DEFAULTS_FILE) $(DEFAULTS_TEST_FILE)
144165

145166
.PHONY: manifests
146167
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.

controllers/defaults.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package controllers
55
// ***********************
66

77
const (
8-
MCADImage = "quay.io/project-codeflare/mcad-controller:release-v1.31.0"
9-
InstaScaleImage = "quay.io/project-codeflare/instascale-controller:v0.0.4"
10-
CodeFlareSDKVersion = "0.4.4"
8+
MCADImage = "quay.io/project-codeflare/mcad-controller:release-v1.31.0"
9+
InstaScaleImage = "quay.io/project-codeflare/instascale-controller:v0.0.4"
1110
)

test/e2e/mnist_rayjob_mcad_raycluster_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestMNISTRayJobMCADRayCluster(t *testing.T) {
6868
Namespace: namespace.Name,
6969
},
7070
Spec: rayv1alpha1.RayClusterSpec{
71-
RayVersion: "2.0.0",
71+
RayVersion: GetRayVersion(),
7272
HeadGroupSpec: rayv1alpha1.HeadGroupSpec{
7373
RayStartParams: map[string]string{
7474
"dashboard-host": "0.0.0.0",
@@ -78,7 +78,7 @@ func TestMNISTRayJobMCADRayCluster(t *testing.T) {
7878
Containers: []corev1.Container{
7979
{
8080
Name: "ray-head",
81-
Image: "rayproject/ray:2.0.0",
81+
Image: GetRayImage(),
8282
Ports: []corev1.ContainerPort{
8383
{
8484
ContainerPort: 6379,
@@ -152,7 +152,7 @@ func TestMNISTRayJobMCADRayCluster(t *testing.T) {
152152
Containers: []corev1.Container{
153153
{
154154
Name: "ray-worker",
155-
Image: "rayproject/ray:2.0.0",
155+
Image: GetRayImage(),
156156
Lifecycle: &corev1.Lifecycle{
157157
PreStop: &corev1.LifecycleHandler{
158158
Exec: &corev1.ExecAction{

test/support/codeflare.go

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,31 @@ package support
1818

1919
import (
2020
"os"
21+
)
2122

22-
"github.com/project-codeflare/codeflare-operator/controllers"
23+
// The environment variables hereafter can be used to change the components
24+
// used for testing.
25+
const (
26+
CodeFlareTestSdkVersion = "CODEFLARE_TEST_SDK_VERSION"
27+
CodeFlareTestRayVersion = "CODEFLARE_TEST_RAY_VERSION"
28+
CodeFlareTestRayImage = "CODEFLARE_TEST_RAY_IMAGE"
2329
)
2430

2531
func GetCodeFlareSDKVersion() string {
26-
if value, ok := os.LookupEnv("CODEFLARE_SDK_VERSION"); ok {
27-
return value
32+
return lookupEnvOrDefault(CodeFlareTestSdkVersion, CodeFlareSDKVersion)
33+
}
34+
35+
func GetRayVersion() string {
36+
return lookupEnvOrDefault(CodeFlareTestRayVersion, RayVersion)
37+
}
38+
39+
func GetRayImage() string {
40+
return lookupEnvOrDefault(CodeFlareTestRayImage, RayImage)
41+
}
42+
43+
func lookupEnvOrDefault(key, value string) string {
44+
if v, ok := os.LookupEnv(key); ok {
45+
return v
2846
}
29-
return controllers.CodeFlareSDKVersion
47+
return value
3048
}

test/support/defaults.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package support
2+
3+
// ***********************
4+
// DO NOT EDIT THIS FILE
5+
// ***********************
6+
7+
const (
8+
CodeFlareSDKVersion = "0.4.4"
9+
RayVersion = "2.5.0"
10+
RayImage = "rayproject/ray:2.5.0"
11+
)

0 commit comments

Comments
 (0)