diff --git a/Makefile b/Makefile index a2a295647..66b9a16e2 100644 --- a/Makefile +++ b/Makefile @@ -133,7 +133,7 @@ vet: ## Run go vet against code. go vet ./... .PHONY: test -test: generate fmt vet envtest image-build verify-crds ## Run tests. +test: generate fmt vet envtest image-build verify-crds verify-helm-charts ## Run tests. CGO_ENABLED=1 KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e | grep -v /conformance) -race -coverprofile cover.out .PHONY: test-unit @@ -174,6 +174,10 @@ verify: vet fmt-verify generate ci-lint api-lint verify-all verify-crds: kubectl-validate hack/verify-manifests.sh +.PHONY: verify-helm-charts +verify-helm-charts: helm-install + hack/verify-helm.sh + # Run static analysis. .PHONY: verify-all verify-all: @@ -423,8 +427,9 @@ $(GOLANGCI_API_LINT): yq: ## Download yq locally if necessary. GOBIN=$(PROJECT_DIR)/bin GO111MODULE=on go install github.com/mikefarah/yq/v4@$(YQ_VERSION) -.PHONY: helm -helm: ## Download helm locally if necessary. +.PHONY: helm-install +helm-install: $(HELM) ## Download helm locally if necessary. +$(HELM): $(LOCALBIN) GOBIN=$(PROJECT_DIR)/bin GO111MODULE=on go install helm.sh/helm/v3/cmd/helm@$(HELM_VERSION) .PHONY: kubectl-validate diff --git a/hack/verify-helm.sh b/hack/verify-helm.sh new file mode 100755 index 000000000..0388b6e24 --- /dev/null +++ b/hack/verify-helm.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright 2025 The Kubernetes Authors. +# +# 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. + +SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/.. + +declare -A test_cases_inference_pool + +# InferencePool Helm Chart test cases +test_cases_inference_pool["basic"]="--set inferencePool.modelServers.matchLabels.app=llm-instance-gateway" +test_cases_inference_pool["gke-provider"]="--set provider.name=gke --set inferencePool.modelServers.matchLabels.app=llm-instance-gateway" +test_cases_inference_pool["multiple-replicas"]="--set inferencePool.replicas=3 --set inferencePool.modelServers.matchLabels.app=llm-instance-gateway" + +# Run the install command in case this script runs from a different bash +# source (such as in the verify-all script) +make helm-install + +# Running tests cases +echo "Running helm template command for inferencePool chart..." +# Loop through the keys of the associative array +for key in "${!test_cases_inference_pool[@]}"; do + echo "Running test: $key" + ${SCRIPT_ROOT}/bin/helm template ${SCRIPT_ROOT}/config/charts/inferencepool ${test_cases_inference_pool[$key]} --output-dir="${SCRIPT_ROOT}/bin" + if [ $? -ne 0 ]; then + echo "Helm template command failed for test: $key" + exit 1 + fi +done + + + diff --git a/hack/verify-manifests.sh b/hack/verify-manifests.sh index dff4170ff..d74c27701 100755 --- a/hack/verify-manifests.sh +++ b/hack/verify-manifests.sh @@ -45,6 +45,8 @@ main() { fetch_crds "https://raw.githubusercontent.com/GoogleCloudPlatform/gke-gateway-api/refs/tags/${GKE_GATEWAY_API_VERSION}/config/crd/networking.gke.io_healthcheckpolicies.yaml" fetch_crds "https://raw.githubusercontent.com/istio/istio/refs/tags/${ISTIO_VERSION}/manifests/charts/base/files/crd-all.gen.yaml" + # Run the install command in case this script runs from a different bash + # source (such as in the verify-all script) make kubectl-validate ${SCRIPT_ROOT}/bin/kubectl-validate "${TEMP_DIR}"