@@ -128,6 +128,126 @@ func TestConfigureCmdThinkFlag(t *testing.T) {
128128 }
129129}
130130
131+ func TestConfigureCmdGPUMemoryUtilizationFlag (t * testing.T ) {
132+ // Create the configure command
133+ cmd := newConfigureCmd ()
134+
135+ // Verify the --gpu-memory-utilization flag exists
136+ gpuMemFlag := cmd .Flags ().Lookup ("gpu-memory-utilization" )
137+ if gpuMemFlag == nil {
138+ t .Fatal ("--gpu-memory-utilization flag not found" )
139+ }
140+
141+ // Verify the default value is empty (nil pointer)
142+ if gpuMemFlag .DefValue != "" {
143+ t .Errorf ("Expected default gpu-memory-utilization value to be '' (nil), got '%s'" , gpuMemFlag .DefValue )
144+ }
145+
146+ // Verify the flag type
147+ if gpuMemFlag .Value .Type () != "float64" {
148+ t .Errorf ("Expected gpu-memory-utilization flag type to be 'float64', got '%s'" , gpuMemFlag .Value .Type ())
149+ }
150+
151+ // Test setting the flag value
152+ err := cmd .Flags ().Set ("gpu-memory-utilization" , "0.7" )
153+ if err != nil {
154+ t .Errorf ("Failed to set gpu-memory-utilization flag: %v" , err )
155+ }
156+
157+ // Verify the value was set
158+ gpuMemValue := gpuMemFlag .Value .String ()
159+ if gpuMemValue != "0.7" {
160+ t .Errorf ("Expected gpu-memory-utilization flag value to be '0.7', got '%s'" , gpuMemValue )
161+ }
162+ }
163+
164+ func TestGPUMemoryUtilizationBehavior (t * testing.T ) {
165+ // Helper to create float64 pointer
166+ float64Ptr := func (f float64 ) * float64 { return & f }
167+
168+ tests := []struct {
169+ name string
170+ gpuMemValue * float64
171+ expectError bool
172+ expectGPUMemSet bool
173+ expectedGPUMemUtil float64
174+ }{
175+ {
176+ name : "default - not set (nil)" ,
177+ gpuMemValue : nil ,
178+ expectError : false ,
179+ expectGPUMemSet : false ,
180+ },
181+ {
182+ name : "valid value 0.5" ,
183+ gpuMemValue : float64Ptr (0.5 ),
184+ expectError : false ,
185+ expectGPUMemSet : true ,
186+ expectedGPUMemUtil : 0.5 ,
187+ },
188+ {
189+ name : "edge case 0.0" ,
190+ gpuMemValue : float64Ptr (0.0 ),
191+ expectError : false ,
192+ expectGPUMemSet : true ,
193+ expectedGPUMemUtil : 0.0 ,
194+ },
195+ {
196+ name : "edge case 1.0" ,
197+ gpuMemValue : float64Ptr (1.0 ),
198+ expectError : false ,
199+ expectGPUMemSet : true ,
200+ expectedGPUMemUtil : 1.0 ,
201+ },
202+ {
203+ name : "invalid - negative value" ,
204+ gpuMemValue : float64Ptr (- 0.1 ),
205+ expectError : true ,
206+ },
207+ {
208+ name : "invalid - value > 1.0" ,
209+ gpuMemValue : float64Ptr (1.5 ),
210+ expectError : true ,
211+ },
212+ }
213+
214+ for _ , tt := range tests {
215+ t .Run (tt .name , func (t * testing.T ) {
216+ flags := ConfigureFlags {
217+ GPUMemoryUtilization : tt .gpuMemValue ,
218+ }
219+
220+ req , err := flags .BuildConfigureRequest ("test-model" )
221+
222+ if tt .expectError {
223+ if err == nil {
224+ t .Fatal ("Expected error but got none" )
225+ }
226+ return
227+ }
228+
229+ if err != nil {
230+ t .Fatalf ("Unexpected error: %v" , err )
231+ }
232+
233+ if tt .expectGPUMemSet {
234+ // GPU memory utilization should be set
235+ if req .VLLM == nil || req .VLLM .GPUMemoryUtilization == nil {
236+ t .Fatal ("Expected GPU memory utilization to be set" )
237+ }
238+ if * req .VLLM .GPUMemoryUtilization != tt .expectedGPUMemUtil {
239+ t .Errorf ("Expected GPU memory utilization to be %f, got %f" , tt .expectedGPUMemUtil , * req .VLLM .GPUMemoryUtilization )
240+ }
241+ } else {
242+ // GPU memory utilization should NOT be set
243+ if req .VLLM != nil && req .VLLM .GPUMemoryUtilization != nil {
244+ t .Errorf ("Expected GPU memory utilization to be nil when not set, got %f" , * req .VLLM .GPUMemoryUtilization )
245+ }
246+ }
247+ })
248+ }
249+ }
250+
131251func TestThinkFlagBehavior (t * testing.T ) {
132252 // Helper to create bool pointer
133253 boolPtr := func (b bool ) * bool { return & b }
0 commit comments