Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,17 @@ format: ## Format Go source files
@gofmt -l -w $(SRC)

.PHONY: test
test: test-unit
test: test-unit test-e2e

.PHONY: test-unit
test-unit: download-tokenizer download-zmq
@printf "\033[33;1m==== Running Unit Tests ====\033[0m\n"
go test -ldflags="$(LDFLAGS)" -v ./...
go test -ldflags="$(LDFLAGS)" -v $$(echo $$(go list ./... | grep -v /test/))

.PHONY: test-e2e
test-e2e: image-build
@printf "\033[33;1m==== Running End to End Tests ====\033[0m\n"
./test/scripts/run_e2e.sh

.PHONY: test-integration
test-integration: download-tokenizer download-zmq
Expand Down
15 changes: 10 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ require (
github.com/google/go-cmp v0.7.0
github.com/jellydator/ttlcache/v3 v3.4.0
github.com/llm-d/llm-d-kv-cache-manager v0.2.1
github.com/onsi/ginkgo/v2 v2.23.4
github.com/onsi/gomega v1.37.0
github.com/openai/openai-go v1.12.0
github.com/stretchr/testify v1.11.0
google.golang.org/grpc v1.73.0
k8s.io/api v0.33.4
k8s.io/apiextensions-apiserver v0.33.2
k8s.io/apimachinery v0.33.4
k8s.io/client-go v0.33.4
sigs.k8s.io/controller-runtime v0.21.0
Expand Down Expand Up @@ -60,8 +66,6 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/onsi/ginkgo/v2 v2.23.4 // indirect
github.com/onsi/gomega v1.37.0 // indirect
github.com/pebbe/zmq4 v1.4.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
Expand All @@ -74,6 +78,10 @@ require (
github.com/spf13/cobra v1.9.1 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/stoewer/go-strcase v1.3.0 // indirect
github.com/tidwall/gjson v1.14.4 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tidwall/sjson v1.2.5 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
Expand Down Expand Up @@ -103,13 +111,10 @@ require (
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250428153025-10db94c68c34 // indirect
google.golang.org/grpc v1.73.0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.33.4 // indirect
k8s.io/apiextensions-apiserver v0.33.2 // indirect
k8s.io/apiserver v0.33.2 // indirect
k8s.io/component-base v0.33.2 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
Expand Down
12 changes: 12 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus
github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8=
github.com/onsi/gomega v1.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y=
github.com/onsi/gomega v1.37.0/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0=
github.com/openai/openai-go v1.12.0 h1:NBQCnXzqOTv5wsgNC36PrFEiskGfO5wccfCWDo9S1U0=
github.com/openai/openai-go v1.12.0/go.mod h1:g461MYGXEXBVdV5SaR/5tNzNbSfwTBBefwc+LlDCK0Y=
github.com/pebbe/zmq4 v1.4.0 h1:gO5P92Ayl8GXpPZdYcD62Cwbq0slSBVVQRIXwGSJ6eQ=
github.com/pebbe/zmq4 v1.4.0/go.mod h1:nqnPueOapVhE2wItZ0uOErngczsJdLOGkebMxaO8r48=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down Expand Up @@ -164,6 +166,16 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.11.0 h1:ib4sjIrwZKxE5u/Japgo/7SJV3PvgjGiRNAvTVGqQl8=
github.com/stretchr/testify v1.11.0/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
Expand Down
183 changes: 183 additions & 0 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
package e2e

import (
"context"
"io"
"os/exec"
"strings"
"testing"
"time"

"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apimachinery/pkg/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/config"
k8slog "sigs.k8s.io/controller-runtime/pkg/log"
infextv1a2 "sigs.k8s.io/gateway-api-inference-extension/api/v1alpha2"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/util/env"
)

const (
// defaultExistsTimeout is the default timeout for a resource to exist in the api server.
defaultExistsTimeout = 30 * time.Second
// defaultReadyTimeout is the default timeout for a resource to report a ready state.
defaultReadyTimeout = 3 * time.Minute
// defaultModelReadyTimeout is the default timeout for the model server deployment to report a ready state.
defaultModelReadyTimeout = 10 * time.Minute
// defaultInterval is the default interval to check if a resource exists or ready conditions.
defaultInterval = time.Millisecond * 250
// xInferPoolManifest is the manifest for the inference pool CRD with 'inference.networking.x-k8s.io' group.
gieCrdsKustomize = "../../deploy/components/crds-gie"
// inferExtManifest is the manifest for the inference extension test resources.
inferExtManifest = "./yaml/inference-pools.yaml"
// modelName is the test model name.
modelName = "food-review"
// kvModelName is the model name used in KV tests.
kvModelName = "Qwen/Qwen2.5-1.5B-Instruct"
// safeKvModelName is the safe form of the model name used in KV tests
safeKvModelName = "qwen-qwen2-5-1-5b-instruct"
// envoyManifest is the manifest for the envoy proxy test resources.
envoyManifest = "./yaml/envoy.yaml"
// eppManifest is the manifest for the deployment of the EPP
eppManifest = "./yaml/deployments.yaml"
// rbacManifest is the manifest for the EPP's RBAC resources.
rbacManifest = "./yaml/rbac.yaml"
// serviceAccountManifest is the manifest for the EPP's service account resources.
serviceAccountManifest = "./yaml/service-accounts.yaml"
// servicesManifest is the manifest for the EPP's service resources.
servicesManifest = "./yaml/services.yaml"
// nsName is the namespace in which the K8S objects will be created
nsName = "default"
)

var (
ctx = context.Background()
k8sClient client.Client
port string
scheme = runtime.NewScheme()

eppTag = env.GetEnvString("EPP_TAG", "dev", ginkgo.GinkgoLogr)
vllmSimTag = env.GetEnvString("VLLM_SIMULATOR_TAG", "dev", ginkgo.GinkgoLogr)
routingSideCarTag = env.GetEnvString("ROUTING_SIDECAR_TAG", "v0.2.0", ginkgo.GinkgoLogr)

existsTimeout = env.GetEnvDuration("EXISTS_TIMEOUT", defaultExistsTimeout, ginkgo.GinkgoLogr)
readyTimeout = env.GetEnvDuration("READY_TIMEOUT", defaultReadyTimeout, ginkgo.GinkgoLogr)
modelReadyTimeout = env.GetEnvDuration("MODEL_READY_TIMEOUT", defaultModelReadyTimeout, ginkgo.GinkgoLogr)
interval = defaultInterval
)

func TestEndToEnd(t *testing.T) {
gomega.RegisterFailHandler(ginkgo.Fail)
ginkgo.RunSpecs(t,
"End To End Test Suite",
)
}

var _ = ginkgo.BeforeSuite(func() {
port = "30080"

setupK8sCluster()
setupK8sClient()
createCRDs()
createEnvoy()
applyYAMLFile(rbacManifest)
applyYAMLFile(serviceAccountManifest)
applyYAMLFile(servicesManifest)

infPoolYaml := readYaml(inferExtManifest)
infPoolYaml = substituteMany(infPoolYaml, map[string]string{"${POOL_NAME}": modelName + "-inference-pool"})
createObjsFromYaml(infPoolYaml)
})

var _ = ginkgo.AfterSuite(func() {
command := exec.Command("kind", "delete", "cluster", "--name", "e2e-tests")
session, err := gexec.Start(command, ginkgo.GinkgoWriter, ginkgo.GinkgoWriter)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
gomega.Eventually(session).WithTimeout(600 * time.Second).Should(gexec.Exit(0))
})

// Create the Kubernetes cluster for the E2E tests and load the local images
func setupK8sCluster() {
command := exec.Command("kind", "create", "cluster", "--name", "e2e-tests", "--config", "-")
stdin, err := command.StdinPipe()
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
go func() {
defer func() {
err := stdin.Close()
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
}()
clusterConfig := strings.ReplaceAll(kindClusterConfig, "${PORT}", port)
_, err := io.WriteString(stdin, clusterConfig)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
}()
session, err := gexec.Start(command, ginkgo.GinkgoWriter, ginkgo.GinkgoWriter)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
gomega.Eventually(session).WithTimeout(600 * time.Second).Should(gexec.Exit(0))

command = exec.Command("kind", "--name", "e2e-tests", "load", "docker-image",
"ghcr.io/llm-d/llm-d-inference-sim:"+vllmSimTag)
session, err = gexec.Start(command, ginkgo.GinkgoWriter, ginkgo.GinkgoWriter)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
gomega.Eventually(session).WithTimeout(600 * time.Second).Should(gexec.Exit(0))

command = exec.Command("kind", "--name", "e2e-tests", "load", "docker-image",
"ghcr.io/llm-d/llm-d-inference-scheduler:"+eppTag)
session, err = gexec.Start(command, ginkgo.GinkgoWriter, ginkgo.GinkgoWriter)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
gomega.Eventually(session).WithTimeout(600 * time.Second).Should(gexec.Exit(0))

command = exec.Command("kind", "--name", "e2e-tests", "load", "docker-image",
"ghcr.io/llm-d/llm-d-routing-sidecar:"+routingSideCarTag)
session, err = gexec.Start(command, ginkgo.GinkgoWriter, ginkgo.GinkgoWriter)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
gomega.Eventually(session).WithTimeout(600 * time.Second).Should(gexec.Exit(0))
}

func setupK8sClient() {
k8sCfg := config.GetConfigOrDie()
gomega.ExpectWithOffset(1, k8sCfg).NotTo(gomega.BeNil())

err := clientgoscheme.AddToScheme(scheme)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

err = apiextv1.AddToScheme(scheme)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

err = infextv1a2.Install(scheme)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

k8sClient, err = client.New(k8sCfg, client.Options{Scheme: scheme})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(k8sClient).NotTo(gomega.BeNil())

k8slog.SetLogger(ginkgo.GinkgoLogr)
}

// createCRDs creates the Inference Extension CRDs used for testing.
func createCRDs() {
crds := runKustomize(gieCrdsKustomize)
createObjsFromYaml(crds)
}

func createEnvoy() {
manifests := readYaml(envoyManifest)
ginkgo.By("Creating envoy proxy resources from manifest: " + envoyManifest)
createObjsFromYaml(manifests)
}

const kindClusterConfig = `
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- extraPortMappings:
- containerPort: 30080
hostPort: ${PORT}
protocol: TCP
- containerPort: 30081
hostPort: 30081
protocol: TCP
`
Loading