77 "os/exec"
88 "path/filepath"
99 "runtime"
10+ "strings"
1011 "time"
1112
1213 "k8s.io/client-go/kubernetes"
@@ -30,11 +31,22 @@ const (
3031)
3132
3233type Profile struct {
33- verbose bool
34+ verbose bool
35+ useExisting bool
36+ skipSetup bool
37+ versions struct {
38+ istio string
39+ gateway string
40+ inference string
41+ }
3442}
3543
3644func NewProfile () * Profile {
37- return & Profile {}
45+ p := & Profile {}
46+ p .versions .istio = istioVersion
47+ p .versions .gateway = gatewayCRDURL
48+ p .versions .inference = inferenceCRDURL
49+ return p
3850}
3951
4052func (p * Profile ) Name () string {
@@ -47,47 +59,121 @@ func (p *Profile) Description() string {
4759
4860func (p * Profile ) Setup (ctx context.Context , opts * framework.SetupOptions ) error {
4961 p .verbose = opts .Verbose
62+ p .useExisting = strings .EqualFold (os .Getenv ("LLMD_USE_EXISTING" ), "true" ) || os .Getenv ("LLMD_USE_EXISTING" ) == "1"
63+ p .skipSetup = strings .EqualFold (os .Getenv ("LLMD_SKIP_SETUP" ), "true" ) || os .Getenv ("LLMD_SKIP_SETUP" ) == "1"
64+
65+ fmt .Printf ("[Profile] llm-d setup start (istio=%s, gatewayCRD=%s, inferenceCRD=%s, useExisting=%v, skipSetup=%v)\n " ,
66+ p .versions .istio , p .versions .gateway , p .versions .inference , p .useExisting , p .skipSetup )
67+
68+ if p .skipSetup {
69+ fmt .Println ("[Profile] LLMD_SKIP_SETUP set; skipping deploy steps, running verification only" )
70+ return p .verifyEnvironment (ctx , opts )
71+ }
72+
73+ rollback := []func (){}
74+ rollbackAll := func () {
75+ for i := len (rollback ) - 1 ; i >= 0 ; i -- {
76+ rollback [i ]()
77+ }
78+ }
79+
5080 istioctlPath , err := p .ensureIstioctl (ctx )
5181 if err != nil {
5282 return err
5383 }
84+ if p .verbose {
85+ fmt .Printf ("[Profile] istioctl ready at %s\n " , istioctlPath )
86+ }
5487
5588 if err := p .kubectlApply (ctx , gatewayCRDURL ); err != nil {
5689 return fmt .Errorf ("gateway CRDs: %w" , err )
5790 }
91+ rollback = append (rollback , func () { _ = p .kubectlDelete (ctx , gatewayCRDURL ) })
92+ if p .verbose {
93+ fmt .Println ("[Profile] applied gateway CRDs" )
94+ }
5895 if err := p .kubectlApply (ctx , inferenceCRDURL ); err != nil {
96+ rollbackAll ()
5997 return fmt .Errorf ("inference CRDs: %w" , err )
6098 }
99+ rollback = append (rollback , func () { _ = p .kubectlDelete (ctx , inferenceCRDURL ) })
100+ if p .verbose {
101+ fmt .Println ("[Profile] applied inference CRDs" )
102+ }
61103
62104 if err := p .installIstio (ctx , istioctlPath ); err != nil {
105+ rollbackAll ()
63106 return fmt .Errorf ("install istio: %w" , err )
64107 }
108+ rollback = append (rollback , func () { _ = p .uninstallIstio (ctx ) })
109+ if p .verbose {
110+ fmt .Println ("[Profile] istio installed" )
111+ }
65112
66113 if err := p .deploySemanticRouter (ctx , opts ); err != nil {
114+ rollbackAll ()
67115 return fmt .Errorf ("deploy semantic router: %w" , err )
68116 }
117+ rollback = append (rollback , func () {
118+ deployer := helm .NewDeployer (opts .KubeConfig , opts .Verbose )
119+ _ = deployer .Uninstall (ctx , "semantic-router" , semanticNamespace )
120+ })
121+ if p .verbose {
122+ fmt .Println ("[Profile] semantic-router deployed" )
123+ }
69124
70125 if err := p .deployInferenceSim (ctx , opts ); err != nil {
126+ rollbackAll ()
71127 return fmt .Errorf ("deploy inference sim: %w" , err )
72128 }
129+ rollback = append (rollback , func () { _ = p .kubectlDelete (ctx , "e2e/profiles/llm-d/manifests/inference-sim.yaml" ) })
130+ if p .verbose {
131+ fmt .Println ("[Profile] inference simulators deployed" )
132+ }
73133
74134 if err := p .deployLLMD (ctx ); err != nil {
135+ rollbackAll ()
75136 return fmt .Errorf ("deploy llm-d resources: %w" , err )
76137 }
138+ rollback = append (rollback , func () {
139+ _ = p .kubectlDelete (ctx , "e2e/profiles/llm-d/manifests/rbac.yaml" )
140+ _ = p .kubectlDelete (ctx , "deploy/kubernetes/llmd-base/dest-rule-epp-llama.yaml" )
141+ _ = p .kubectlDelete (ctx , "deploy/kubernetes/llmd-base/dest-rule-epp-phi4.yaml" )
142+ _ = p .kubectlDelete (ctx , "deploy/kubernetes/llmd-base/inferencepool-llama.yaml" )
143+ _ = p .kubectlDelete (ctx , "deploy/kubernetes/llmd-base/inferencepool-phi4.yaml" )
144+ })
145+ if p .verbose {
146+ fmt .Println ("[Profile] llm-d schedulers and pools deployed" )
147+ }
77148
78149 if err := p .deployGatewayRoutes (ctx ); err != nil {
150+ rollbackAll ()
79151 return fmt .Errorf ("deploy gateway routes: %w" , err )
80152 }
153+ rollback = append (rollback , func () {
154+ _ = p .kubectlDelete (ctx , "deploy/kubernetes/istio/envoyfilter.yaml" )
155+ _ = p .kubectlDelete (ctx , "deploy/kubernetes/istio/destinationrule.yaml" )
156+ _ = p .kubectlDelete (ctx , "e2e/profiles/llm-d/manifests/httproute-services.yaml" )
157+ _ = p .kubectlDelete (ctx , "deploy/kubernetes/istio/gateway.yaml" )
158+ })
159+ if p .verbose {
160+ fmt .Println ("[Profile] gateway routes deployed" )
161+ }
81162
82163 if err := p .verifyEnvironment (ctx , opts ); err != nil {
164+ rollbackAll ()
83165 return fmt .Errorf ("verify environment: %w" , err )
84166 }
85167
168+ if p .verbose {
169+ fmt .Println ("[Profile] llm-d setup complete" )
170+ }
86171 return nil
87172}
88173
89174func (p * Profile ) Teardown (ctx context.Context , opts * framework.TeardownOptions ) error {
90175 p .verbose = opts .Verbose
176+ fmt .Println ("[Profile] llm-d teardown start" )
91177 _ = p .kubectlDelete (ctx , "e2e/profiles/llm-d/manifests/httproute-services.yaml" )
92178 _ = p .kubectlDelete (ctx , "deploy/kubernetes/llmd-base/dest-rule-epp-llama.yaml" )
93179 _ = p .kubectlDelete (ctx , "deploy/kubernetes/llmd-base/dest-rule-epp-phi4.yaml" )
@@ -103,18 +189,35 @@ func (p *Profile) Teardown(ctx context.Context, opts *framework.TeardownOptions)
103189 deployer .Uninstall (ctx , "semantic-router" , semanticNamespace )
104190
105191 _ = p .uninstallIstio (ctx )
192+ _ = p .kubectlDelete (ctx , gatewayCRDURL )
193+ _ = p .kubectlDelete (ctx , inferenceCRDURL )
194+ fmt .Println ("[Profile] llm-d teardown complete" )
106195
107196 return nil
108197}
109198
110199func (p * Profile ) GetTestCases () []string {
111- return []string {
200+ tests := []string {
112201 "llmd-health-check" ,
113202 "llmd-distributed-inference" ,
114203 "llmd-auto-routing" ,
115204 "llmd-failover-recovery" ,
116205 "llmd-performance-baseline" ,
117206 }
207+ if strings .EqualFold (os .Getenv ("LLMD_PERF_SKIP" ), "true" ) || os .Getenv ("LLMD_PERF_SKIP" ) == "1" {
208+ var filtered []string
209+ for _ , t := range tests {
210+ if t == "llmd-performance-baseline" {
211+ continue
212+ }
213+ filtered = append (filtered , t )
214+ }
215+ if p .verbose {
216+ fmt .Println ("[Profile] LLMD_PERF_SKIP set; skipping llmd-performance-baseline test" )
217+ }
218+ return filtered
219+ }
220+ return tests
118221}
119222
120223func (p * Profile ) GetServiceConfig () framework.ServiceConfig {
0 commit comments