-
Notifications
You must be signed in to change notification settings - Fork 92
✨ Document and test client-only install pattern (controller.enabled=false) #747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| /* | ||
| Copyright 2025. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package chart_test | ||
|
|
||
| import ( | ||
| "os" | ||
| "os/exec" | ||
| "strings" | ||
| "testing" | ||
| ) | ||
|
|
||
| const chartPath = "../../charts/workload-variant-autoscaler" | ||
|
|
||
| // helmTemplate runs "helm template" with the given set values and returns the rendered output. | ||
| func helmTemplate(t *testing.T, releaseName string, setValues map[string]string) string { | ||
| t.Helper() | ||
|
|
||
| args := []string{"template", releaseName, chartPath} | ||
| for k, v := range setValues { | ||
| args = append(args, "--set", k+"="+v) | ||
| } | ||
|
|
||
| cmd := exec.Command("helm", args...) | ||
| cmd.Stderr = os.Stderr | ||
| out, err := cmd.Output() | ||
| if err != nil { | ||
| t.Fatalf("helm template failed: %v", err) | ||
| } | ||
| return string(out) | ||
| } | ||
|
|
||
| // TestClientOnlyInstall verifies that controller.enabled=false produces only | ||
| // workload-specific resources (VA, HPA, Service, ServiceMonitor, RBAC ClusterRoles) | ||
| // and excludes all controller infrastructure. | ||
| func TestClientOnlyInstall(t *testing.T) { | ||
| output := helmTemplate(t, "wva-model-b", map[string]string{ | ||
| "controller.enabled": "false", | ||
| "va.enabled": "true", | ||
| "hpa.enabled": "true", | ||
| "llmd.namespace": "team-b", | ||
| "llmd.modelName": "my-model", | ||
| "llmd.modelID": "meta-llama/Llama-3.1-8B", | ||
| "vllmService.enabled": "true", | ||
| }) | ||
|
|
||
| // Resources that MUST be present in client-only mode | ||
| mustContain := []string{ | ||
| "kind: VariantAutoscaling", | ||
| "kind: HorizontalPodAutoscaler", | ||
| "kind: Service", | ||
| "kind: ServiceMonitor", | ||
| } | ||
| for _, resource := range mustContain { | ||
| if !strings.Contains(output, resource) { | ||
| t.Errorf("client-only install should contain %q", resource) | ||
| } | ||
| } | ||
|
|
||
| // Resources that MUST NOT be present (controller infrastructure). | ||
| // Note: "kind: Deployment" appears inside scaleTargetRef blocks (VA, HPA), | ||
| // so we check for controller-specific markers instead. | ||
| mustNotContain := []struct { | ||
| marker string | ||
| reason string | ||
| }{ | ||
| {"kind: ServiceAccount", "controller service account should be excluded"}, | ||
| {"leader-election", "leader election RBAC should be excluded"}, | ||
| {"controller-manager", "controller manager resources should be excluded"}, | ||
| {"prometheus-ca", "prometheus CA configmaps should be excluded"}, | ||
| } | ||
| for _, check := range mustNotContain { | ||
| if strings.Contains(output, check.marker) { | ||
| t.Errorf("client-only install should NOT contain %q: %s", check.marker, check.reason) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // TestFullInstall verifies that controller.enabled=true (default) produces | ||
| // controller infrastructure in addition to workload resources. | ||
| func TestFullInstall(t *testing.T) { | ||
| output := helmTemplate(t, "wva-full", map[string]string{ | ||
| "controller.enabled": "true", | ||
| "va.enabled": "true", | ||
| "hpa.enabled": "true", | ||
| }) | ||
|
|
||
| mustContain := []string{ | ||
| "kind: Deployment", | ||
| "kind: ServiceAccount", | ||
| "kind: VariantAutoscaling", | ||
| "kind: HorizontalPodAutoscaler", | ||
| "leader-election", | ||
| "controller-manager", | ||
| } | ||
| for _, resource := range mustContain { | ||
| if !strings.Contains(output, resource) { | ||
| t.Errorf("full install should contain %q", resource) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // TestClientOnlyNoVA verifies that controller.enabled=false with va.enabled=false | ||
| // and hpa.enabled=false produces minimal output (only service/servicemonitor/RBAC). | ||
| func TestClientOnlyNoVA(t *testing.T) { | ||
| output := helmTemplate(t, "wva-minimal", map[string]string{ | ||
| "controller.enabled": "false", | ||
| "va.enabled": "false", | ||
| "hpa.enabled": "false", | ||
| "vllmService.enabled": "true", | ||
| }) | ||
|
|
||
| if strings.Contains(output, "kind: VariantAutoscaling") { | ||
| t.Error("should not contain VariantAutoscaling when va.enabled=false") | ||
| } | ||
| if strings.Contains(output, "kind: HorizontalPodAutoscaler") { | ||
| t.Error("should not contain HPA when hpa.enabled=false") | ||
| } | ||
| if strings.Contains(output, "kind: Deployment") { | ||
| t.Error("should not contain Deployment when controller.enabled=false") | ||
| } | ||
| } | ||
|
|
||
| // TestClientOnlyControllerInstance verifies that controllerInstance label | ||
| // is applied to VA resources in client-only mode. | ||
| func TestClientOnlyControllerInstance(t *testing.T) { | ||
| output := helmTemplate(t, "wva-model-c", map[string]string{ | ||
| "controller.enabled": "false", | ||
| "va.enabled": "true", | ||
| "hpa.enabled": "true", | ||
| "wva.controllerInstance": "my-team", | ||
| "llmd.namespace": "team-c", | ||
| "llmd.modelName": "my-model", | ||
| }) | ||
|
|
||
| if !strings.Contains(output, "kind: VariantAutoscaling") { | ||
| t.Fatal("should contain VariantAutoscaling") | ||
| } | ||
| if !strings.Contains(output, "wva.llmd.ai/controller-instance: \"my-team\"") { | ||
| t.Error("VA should have controller-instance label matching controllerInstance value") | ||
| } | ||
| if !strings.Contains(output, `controller_instance: "my-team"`) { | ||
| t.Error("HPA metric selector should filter by controller_instance") | ||
| } | ||
| if strings.Contains(output, "controller-manager") { | ||
| t.Error("should not contain controller Deployment in client-only mode") | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing Apache 2.0 license header. All Go files in this repository include a copyright and license header. Add the standard Apache 2.0 license header with "Copyright 2025." at the top of the file, consistent with other test files in the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bad AI. It's not missing, and you missed the fact that we are in 2026