Skip to content

Commit 4ba15ae

Browse files
Use ResourceName generic function for raycluster_webhook tests
1 parent 5b4a41f commit 4ba15ae

File tree

3 files changed

+27
-47
lines changed

3 files changed

+27
-47
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/openshift/api v0.0.0-20230823114715-5fdd7511b790
1111
github.com/openshift/client-go v0.0.0-20221019143426-16aed247da5c
1212
github.com/project-codeflare/appwrapper v0.12.0
13-
github.com/project-codeflare/codeflare-common v0.0.0-20240422163521-380101642c8f
13+
github.com/project-codeflare/codeflare-common v0.0.0-20240528061920-68eadc29b5b0
1414
github.com/ray-project/kuberay/ray-operator v1.1.0
1515
go.uber.org/zap v1.26.0
1616
golang.org/x/exp v0.0.0-20230905200255-921286631fa9

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
244244
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
245245
github.com/project-codeflare/appwrapper v0.12.0 h1:QMxryBPK6ir3VK6Qx4NWOA05/s4xU6uDHI/nXmLznvw=
246246
github.com/project-codeflare/appwrapper v0.12.0/go.mod h1:sH9j/rXX6WIlZzFXUOuqK5pagASPZNhuCtdFK+3BDkw=
247-
github.com/project-codeflare/codeflare-common v0.0.0-20240422163521-380101642c8f h1:9Uron4ej4Tt5ULX5CMzjmPqIZu3q/m07d4jhbNSwdPY=
248-
github.com/project-codeflare/codeflare-common v0.0.0-20240422163521-380101642c8f/go.mod h1:tlPi2e1HZQuf7AAFc7keWdVUNcxV+Gfh6Ss4KAQs1O0=
247+
github.com/project-codeflare/codeflare-common v0.0.0-20240528061920-68eadc29b5b0 h1:3Vz7D9/TwzrBNujHQZGb4L6UKu3siAWwVP4Bj3ByUrU=
248+
github.com/project-codeflare/codeflare-common v0.0.0-20240528061920-68eadc29b5b0/go.mod h1:tlPi2e1HZQuf7AAFc7keWdVUNcxV+Gfh6Ss4KAQs1O0=
249249
github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk=
250250
github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA=
251251
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=

pkg/controllers/raycluster_webhook_test.go

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func TestRayClusterWebhookDefault(t *testing.T) {
103103
To(
104104
And(
105105
HaveLen(1),
106-
ContainElement(WithTransform(ContainerName, Equal(oauthProxyContainerName))),
106+
ContainElement(WithTransform(support.ResourceName, Equal(oauthProxyContainerName))),
107107
),
108108
"Expected the OAuth proxy container to be present in the head group",
109109
)
@@ -114,9 +114,9 @@ func TestRayClusterWebhookDefault(t *testing.T) {
114114
To(
115115
And(
116116
HaveLen(3),
117-
ContainElement(WithTransform(VolumeName, Equal(oauthProxyVolumeName))),
118-
ContainElement(WithTransform(VolumeName, Equal("ca-vol"))),
119-
ContainElement(WithTransform(VolumeName, Equal("server-cert"))),
117+
ContainElement(WithTransform(support.ResourceName, Equal(oauthProxyVolumeName))),
118+
ContainElement(WithTransform(support.ResourceName, Equal("ca-vol"))),
119+
ContainElement(WithTransform(support.ResourceName, Equal("server-cert"))),
120120
),
121121
"Expected the OAuth proxy TLS secret and CA volumes to be present in the head group",
122122
)
@@ -133,12 +133,12 @@ func TestRayClusterWebhookDefault(t *testing.T) {
133133
To(
134134
And(
135135
HaveLen(6),
136-
ContainElement(WithTransform(EnvVarName, Equal("COOKIE_SECRET"))),
137-
ContainElement(WithTransform(EnvVarName, Equal("MY_POD_IP"))),
138-
ContainElement(WithTransform(EnvVarName, Equal("RAY_USE_TLS"))),
139-
ContainElement(WithTransform(EnvVarName, Equal("RAY_TLS_SERVER_CERT"))),
140-
ContainElement(WithTransform(EnvVarName, Equal("RAY_TLS_SERVER_KEY"))),
141-
ContainElement(WithTransform(EnvVarName, Equal("RAY_TLS_CA_CERT"))),
136+
ContainElement(WithTransform(support.ResourceName, Equal("COOKIE_SECRET"))),
137+
ContainElement(WithTransform(support.ResourceName, Equal("MY_POD_IP"))),
138+
ContainElement(WithTransform(support.ResourceName, Equal("RAY_USE_TLS"))),
139+
ContainElement(WithTransform(support.ResourceName, Equal("RAY_TLS_SERVER_CERT"))),
140+
ContainElement(WithTransform(support.ResourceName, Equal("RAY_TLS_SERVER_KEY"))),
141+
ContainElement(WithTransform(support.ResourceName, Equal("RAY_TLS_CA_CERT"))),
142142
),
143143
"Expected the required environment variables to be present in the head group",
144144
)
@@ -149,7 +149,7 @@ func TestRayClusterWebhookDefault(t *testing.T) {
149149
To(
150150
And(
151151
HaveLen(1),
152-
ContainElement(WithTransform(ContainerName, Equal(initContainerName))),
152+
ContainElement(WithTransform(support.ResourceName, Equal(initContainerName))),
153153
),
154154
"Expected the create-cert init container to be present in the head group",
155155
)
@@ -160,9 +160,9 @@ func TestRayClusterWebhookDefault(t *testing.T) {
160160
To(
161161
And(
162162
HaveLen(3),
163-
ContainElement(WithTransform(VolumeMountName, Equal(oauthProxyVolumeName))),
164-
ContainElement(WithTransform(VolumeMountName, Equal("ca-vol"))),
165-
ContainElement(WithTransform(VolumeMountName, Equal("server-cert"))),
163+
ContainElement(WithTransform(support.ResourceName, Equal(oauthProxyVolumeName))),
164+
ContainElement(WithTransform(support.ResourceName, Equal("ca-vol"))),
165+
ContainElement(WithTransform(support.ResourceName, Equal("server-cert"))),
166166
),
167167
"Expected the OAuth proxy TLS secret and CA volume mounts to be present in the head group",
168168
)
@@ -174,11 +174,11 @@ func TestRayClusterWebhookDefault(t *testing.T) {
174174
To(
175175
And(
176176
HaveLen(5),
177-
ContainElement(WithTransform(EnvVarName, Equal("MY_POD_IP"))),
178-
ContainElement(WithTransform(EnvVarName, Equal("RAY_USE_TLS"))),
179-
ContainElement(WithTransform(EnvVarName, Equal("RAY_TLS_SERVER_CERT"))),
180-
ContainElement(WithTransform(EnvVarName, Equal("RAY_TLS_SERVER_KEY"))),
181-
ContainElement(WithTransform(EnvVarName, Equal("RAY_TLS_CA_CERT"))),
177+
ContainElement(WithTransform(support.ResourceName, Equal("MY_POD_IP"))),
178+
ContainElement(WithTransform(support.ResourceName, Equal("RAY_USE_TLS"))),
179+
ContainElement(WithTransform(support.ResourceName, Equal("RAY_TLS_SERVER_CERT"))),
180+
ContainElement(WithTransform(support.ResourceName, Equal("RAY_TLS_SERVER_KEY"))),
181+
ContainElement(WithTransform(support.ResourceName, Equal("RAY_TLS_CA_CERT"))),
182182
),
183183
"Expected the required environment variables to be present in each worker group",
184184
)
@@ -191,8 +191,8 @@ func TestRayClusterWebhookDefault(t *testing.T) {
191191
To(
192192
And(
193193
HaveLen(2),
194-
ContainElement(WithTransform(VolumeName, Equal("ca-vol"))),
195-
ContainElement(WithTransform(VolumeName, Equal("server-cert"))),
194+
ContainElement(WithTransform(support.ResourceName, Equal("ca-vol"))),
195+
ContainElement(WithTransform(support.ResourceName, Equal("server-cert"))),
196196
),
197197
"Expected the required CA volumes to be present in each worker group",
198198
)
@@ -205,8 +205,8 @@ func TestRayClusterWebhookDefault(t *testing.T) {
205205
To(
206206
And(
207207
HaveLen(2),
208-
ContainElement(WithTransform(VolumeMountName, Equal("ca-vol"))),
209-
ContainElement(WithTransform(VolumeMountName, Equal("server-cert"))),
208+
ContainElement(WithTransform(support.ResourceName, Equal("ca-vol"))),
209+
ContainElement(WithTransform(support.ResourceName, Equal("server-cert"))),
210210
),
211211
"Expected the required certificate volume mounts to be present in each worker group",
212212
)
@@ -219,7 +219,7 @@ func TestRayClusterWebhookDefault(t *testing.T) {
219219
To(
220220
And(
221221
HaveLen(1),
222-
ContainElement(WithTransform(ContainerName, Equal(initContainerName))),
222+
ContainElement(WithTransform(support.ResourceName, Equal(initContainerName))),
223223
),
224224
"Expected the required init container to be present in each worker group",
225225
)
@@ -645,23 +645,3 @@ func TestValidateUpdate(t *testing.T) {
645645
test.Expect(err).Should(HaveOccurred(), "Expected errors on call to ValidateUpdate function due to manipulated env vars in the worker group")
646646
})
647647
}
648-
649-
func ContainerName(container corev1.Container) string {
650-
return container.Name
651-
}
652-
653-
func VolumeName(volume corev1.Volume) string {
654-
return volume.Name
655-
}
656-
657-
func ServiceAccountName(serviceAccount corev1.ServiceAccount) string {
658-
return serviceAccount.Name
659-
}
660-
661-
func VolumeMountName(volumeMount corev1.VolumeMount) string {
662-
return volumeMount.Name
663-
}
664-
665-
func EnvVarName(envVar corev1.EnvVar) string {
666-
return envVar.Name
667-
}

0 commit comments

Comments
 (0)