@@ -36,10 +36,10 @@ import (
3636//
3737// sudo go test -v -run TestVGPU -timeout 5m ./integration/...
3838//
39- // Note: This test verifies vGPU assignment, stop behavior (mdev releases and
40- // reacquires on start; vendor VFIO retains the assignment), and PCI device
41- // visibility inside the VM. It does NOT test nvidia-smi or CUDA functionality
42- // since that requires NVIDIA guest drivers pre-installed in the image.
39+ // Note: This test verifies vGPU assignment, release on stop, reacquisition on
40+ // start, and PCI device visibility inside the VM. It does NOT test nvidia-smi
41+ // or CUDA functionality since that requires NVIDIA guest drivers pre-installed
42+ // in the image.
4343func TestVGPU (t * testing.T ) {
4444 t .Parallel ()
4545 if testing .Short () {
@@ -94,17 +94,10 @@ func TestVGPU(t *testing.T) {
9494 if _ , err := instanceManager .StopInstance (ctx , instanceID ); err != nil {
9595 t .Logf ("Cleanup: stop instance: %v" , err )
9696 }
97- if inst , err := instanceManager .GetInstance (ctx , instanceID ); err == nil && inst .GPUFramework == devices .VGPUFrameworkVendorVFIO && inst .GPUDevicePath != "" {
98- if err := devices .DestroyVGPU (ctx , devices.VGPUAssignment {
99- Framework : inst .GPUFramework ,
100- DevicePath : inst .GPUDevicePath ,
101- InstanceID : instanceID ,
102- }); err != nil {
103- t .Errorf ("cleanup: release vendor VFIO vGPU: %v" , err )
104- }
105- }
10697 t .Log ("Cleanup: Deleting instance..." )
107- instanceManager .DeleteInstance (ctx , instanceID )
98+ if err := instanceManager .DeleteInstance (ctx , instanceID ); err != nil {
99+ t .Errorf ("cleanup: delete instance: %v" , err )
100+ }
108101 })
109102
110103 // Step 1: Ensure system files (kernel, initrd)
@@ -260,34 +253,22 @@ func TestVGPU(t *testing.T) {
260253 _ , err = instanceManager .StopInstance (ctx , inst .Id )
261254 require .NoError (t , err , "stop should succeed" )
262255
263- switch inst .GPUFramework {
264- case devices .VGPUFrameworkMdev :
265- t .Run ("VGPUReleasedOnStop" , func (t * testing.T ) {
266- stopped , err := instanceManager .GetInstance (ctx , inst .Id )
267- require .NoError (t , err )
268- assert .Empty (t , stopped .GPUDevicePath , "assignment metadata should be cleared on stop" )
269- assertVGPUReleased (t , inst .GPUFramework , inst .GPUDevicePath )
270- })
256+ t .Run ("VGPUReleasedOnStop" , func (t * testing.T ) {
257+ stopped , err := instanceManager .GetInstance (ctx , inst .Id )
258+ require .NoError (t , err )
259+ assert .Empty (t , stopped .GPUDevicePath , "assignment metadata should be cleared on stop" )
260+ assertVGPUReleased (t , inst .GPUFramework , inst .GPUDevicePath )
261+ })
271262
272- t .Log ("Step 11: Starting instance to reacquire a vGPU..." )
273- started , err := instanceManager .StartInstance (ctx , inst .Id , instances.StartInstanceRequest {})
274- require .NoError (t , err , "start should succeed" )
263+ t .Log ("Step 11: Starting instance to reacquire a vGPU..." )
264+ started , err := instanceManager .StartInstance (ctx , inst .Id , instances.StartInstanceRequest {})
265+ require .NoError (t , err , "start should succeed" )
275266
276- t .Run ("VGPUReacquiredOnStart" , func (t * testing.T ) {
277- require .NotEmpty (t , started .GPUDevicePath , "start should assign a vGPU" )
278- assert .Equal (t , inst .GPUFramework , started .GPUFramework , "framework should match" )
279- assertVGPUAssigned (t , started .GPUFramework , started .GPUDevicePath )
280- })
281- case devices .VGPUFrameworkVendorVFIO :
282- t .Run ("VGPUAssignmentRetainedOnStop" , func (t * testing.T ) {
283- stopped , err := instanceManager .GetInstance (ctx , inst .Id )
284- require .NoError (t , err )
285- // Release requires an instance-owned assignment, so stop retains it.
286- assert .Equal (t , inst .GPUFramework , stopped .GPUFramework , "assignment framework should be retained on stop" )
287- assert .Equal (t , inst .GPUDevicePath , stopped .GPUDevicePath , "assignment metadata should be retained on stop" )
288- assertVGPUAssigned (t , stopped .GPUFramework , stopped .GPUDevicePath )
289- })
290- }
267+ t .Run ("VGPUReacquiredOnStart" , func (t * testing.T ) {
268+ require .NotEmpty (t , started .GPUDevicePath , "start should assign a vGPU" )
269+ assert .Equal (t , inst .GPUFramework , started .GPUFramework , "framework should match" )
270+ assertVGPUAssigned (t , started .GPUFramework , started .GPUDevicePath )
271+ })
291272
292273 t .Log ("✅ vGPU test PASSED!" )
293274}
@@ -343,6 +324,11 @@ func checkVGPUTestPrerequisites() (string, string) {
343324 if framework == devices .VGPUFrameworkNone {
344325 return "vGPU test requires SR-IOV VFs with an mdev or vendor VFIO vGPU framework" , ""
345326 }
327+ if framework == devices .VGPUFrameworkVendorVFIO {
328+ // CreateVGPU rejects vendor VFIO until the instance lifecycle
329+ // integration lands.
330+ return "vGPU test requires the vendor VFIO instance lifecycle integration" , ""
331+ }
346332
347333 // Check for available profiles
348334 profiles , err := devices .ListGPUProfiles ()
0 commit comments