Skip to content

Commit 31970e6

Browse files
authored
add more case in playground webhook (#470)
1 parent 82e66e3 commit 31970e6

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pkg/webhook/playground_webhook.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ func (w *PlaygroundWebhook) generateValidate(obj runtime.Object) field.ErrorList
103103
if playground.Spec.ModelClaim == nil && playground.Spec.ModelClaims == nil {
104104
allErrs = append(allErrs, field.Forbidden(specPath, "modelClaim and modelClaims couldn't be both nil"))
105105
}
106+
if playground.Spec.ModelClaim != nil && playground.Spec.ModelClaims != nil {
107+
allErrs = append(allErrs, field.Forbidden(specPath, "modelClaim and modelClaims couldn't be both not nil"))
108+
}
106109
if playground.Spec.ModelClaims != nil {
107110
mainModelCount := 0
108111

test/integration/webhook/playground_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ var _ = ginkgo.Describe("Playground default and validation", func() {
8787
},
8888
failed: true,
8989
}),
90+
ginkgo.Entry("both model claim and claims be set", &testValidatingCase{
91+
playground: func() *inferenceapi.Playground {
92+
return wrapper.MakePlayground("playground", ns.Name).Replicas(1).ModelClaim("llama3-8b").
93+
ModelClaims([]string{"llama3-405b", "llama3-2b"}, []string{"main", "draft", "draft"}).Obj()
94+
},
95+
failed: true,
96+
}),
9097
ginkgo.Entry("any kind of backendRuntime should be supported", &testValidatingCase{
9198
playground: func() *inferenceapi.Playground {
9299
return wrapper.MakePlayground("playground", ns.Name).Replicas(1).ModelClaim("llama3-8b").BackendRuntime(string("unknown")).Obj()
@@ -141,7 +148,7 @@ var _ = ginkgo.Describe("Playground default and validation", func() {
141148
playground func() *inferenceapi.Playground
142149
wantPlayground func() *inferenceapi.Playground
143150
}
144-
ginkgo.DescribeTable("test validating",
151+
ginkgo.DescribeTable("test Defaulting",
145152
func(tc *testDefaultingCase) {
146153
playground := tc.playground()
147154
gomega.Expect(k8sClient.Create(ctx, playground)).To(gomega.Succeed())

0 commit comments

Comments
 (0)