@@ -48,7 +48,6 @@ def setUpClass(self):
4848 testClient = super (TestDeployvGPUenabledVM , self ).getClsTestClient ()
4949 self .apiclient = testClient .getApiClient ()
5050 self .testdata = self .testClient .getParsedTestDataConfig ()
51- self ._cleanup = []
5251 self .unsupportedHypervisor = False
5352 self .noSuitableHost = False
5453 # Need to add check whether zone containing the xen hypervisor or not
@@ -85,89 +84,89 @@ def setUpClass(self):
8584 # No XenServer available with GPU Drivers installed
8685 self .noSuitableHost = True
8786 return
88-
89- self .domain = get_domain (self .apiclient )
90- self .zone = get_zone (self .apiclient , self .testClient .getZoneForTests ())
91- # Creating Account
92- self .account = Account .create (
93- self .apiclient ,
94- self .testdata ["account" ],
95- domainid = self .domain .id
96- )
97- self ._cleanup .append (self .account )
98-
87+
9988 def setUp (self ):
10089 self .testdata = self .testClient .getParsedTestDataConfig ()["vgpu" ]
10190 self .apiclient = self .testClient .getApiClient ()
102- self .dbclient = self .testClient .getDbConnection ()
91+ self .dbclient = self .testClient .getDbConnection ()
10392 if self .noSuitableHost or self .unsupportedHypervisor :
10493 self .hypervisor = get_hypervisor_type (self .apiclient )
10594 if self .hypervisor .lower () not in ["vmware" ]:
10695 self .skipTest ("Skipping test because suitable hypervisor/host not\
10796 present" )
10897 self .testdata = self .testClient .getParsedTestDataConfig ()
98+
99+ self .cleanup = []
109100
110101 # Get Zone, Domain and Default Built-in template
111102 self .domain = get_domain (self .apiclient )
112- self .zone = get_zone (self .apiclient , self .testClient .getZoneForTests ())
113-
114- # Before running this test for Xen Server, register a windows template with ostype as
115- # 'Windows 7 (32-bit)'
116- self .template = get_template (
117- self .apiclient ,
118- self .zone .id ,
119- self .testdata ["ostype" ])
120-
121- # create a user account
103+ self .zone = get_zone (self .apiclient , self .testClient .getZoneForTests ())
104+ # Creating Account
122105 self .account = Account .create (
123- self .apiclient ,
124- self .testdata ["account" ],
125- domainid = self .domain .id
106+ self .apiclient ,
107+ self .testdata ["account" ],
108+ domainid = self .domain .id
126109 )
127- self .cleanup = []
128-
129- if self .hypervisor .lower () in ["xenserver" ]:
130- self .testdata ["mode" ] = self .zone .networktype
131110
132- if self .template == FAILED :
111+ if self .hypervisor .lower () in ["xenserver" ]:
112+
113+ # Before running this test for Xen Server, register a windows template with ostype as
114+ # 'Windows 7 (32-bit)'
115+ self .template = get_template (
116+ self .apiclient ,
117+ self .zone .id ,
118+ self .testdata ["ostype" ])
119+ self .cleanup .append (self .template )
120+
121+ self .testdata ["mode" ] = self .zone .networktype
122+
123+ if self .template == FAILED :
133124 assert False , "get_template() failed to return template with description %s" % self .testdata [
134125 "ostype" ]
135126
136- self .testdata ["small" ]["zoneid" ] = self .zone .id
137- self .testdata ["small" ]["template" ] = self .template .id
127+ self .testdata ["small" ]["zoneid" ] = self .zone .id
128+ self .testdata ["small" ]["template" ] = self .template .id
138129
139- self .testdata ["service_offerings" ]["vgpu260qwin" ]["serviceofferingdetails" ] = [
130+ self .testdata ["service_offerings" ]["vgpu260qwin" ]["serviceofferingdetails" ] = [
140131 {
141132 'pciDevice' : 'Group of NVIDIA Corporation GK107GL [GRID K1] GPUs' }, {
142133 'vgpuType' : 'GRID K120Q' }]
143134 # create a service offering
144- self .service_offering = ServiceOffering .create (
135+ self .service_offering = ServiceOffering .create (
145136 self .apiclient ,
146137 self .testdata ["service_offerings" ]["vgpu260qwin" ],
147138 )
148- # build cleanup list
149- self .cleanup = [
150- self .service_offering ,
151- self .account
152- ]
153- elif self .hypervisor .lower () in ["vmware" ]:
154- self .testdata ["isolated_network" ]["zoneid" ] = self .zone .id
155- self .userapiclient = self .testClient .getUserApiClient (
139+ self .cleanup .append (self .service_offering )
140+
141+ elif self .hypervisor .lower () in ["vmware" ]:
142+ self .testdata ["isolated_network" ]["zoneid" ] = self .zone .id
143+
144+ self .userapiclient = self .testClient .getUserApiClient (
156145 UserName = self .account .name ,
157146 DomainName = self .account .domain
158147 )
159- self .service_offering = ServiceOffering .create (
148+ self .service_offering = ServiceOffering .create (
160149 self .apiclient ,
161150 self .testdata ["service_offering" ])
162- self .cleanup .append (self .service_offering )
163151
164- # Create Shared Network Offering
165- self .isolated_network_offering = NetworkOffering .create (
152+ # Create Shared Network Offering
153+ self .isolated_network_offering = NetworkOffering .create (
166154 self .apiclient ,
167155 self .testdata ["isolated_network_offering" ])
168- self .cleanup .append (self .isolated_network_offering )
169156 # Enable Isolated Network offering
170- self .isolated_network_offering .update (self .apiclient , state = 'Enabled' )
157+ self .isolated_network_offering .update (self .apiclient , state = 'Enabled' )
158+
159+ # Register a private template in the account with nic adapter vmxnet3
160+ # Also add required 3D GPU details for enabling it
161+ self .template = Template .register (
162+ self .userapiclient ,
163+ self .testdata ["configurableData" ]["vmxnet3template" ],
164+ zoneid = self .zone .id ,
165+ account = self .account .name ,
166+ domainid = self .account .domainid ,
167+ details = [{"mks.enable3d" : "true" , "mks.use3dRenderer" : "automatic" ,
168+ "svga.autodetect" : "false" , "svga.vramSize" : "131072" }]
169+ )
171170
172171
173172 @attr (tags = ['advanced' , 'basic' , 'vgpu' ], required_hardware = "true" )
@@ -179,10 +178,11 @@ def test_deploy_vgpu_enabled_vm(self):
179178 # 2. Virtual Machine is vGPU enabled (via SSH)
180179 # 3. listVirtualMachines returns accurate information
181180 """
182-
183- if self .hypervisor . lower () not in [ "xenserver" ]:
181+ if self . hypervisor . lower () not in [ "xenserver" ]:
182+ self .cleanup . append ( self . account )
184183 self .skipTest ("This test case is written specifically\
185184 for XenServer hypervisor" )
185+
186186 self .virtual_machine = VirtualMachine .create (
187187 self .apiclient ,
188188 self .testdata ["small" ],
@@ -191,6 +191,7 @@ def test_deploy_vgpu_enabled_vm(self):
191191 serviceofferingid = self .service_offering .id ,
192192 mode = self .testdata ['mode' ]
193193 )
194+ self .cleanup .append (self .virtual_machine )
194195
195196 list_vms = VirtualMachine .list (
196197 self .apiclient ,
@@ -240,11 +241,11 @@ def test_deploy_vgpu_enabled_vm(self):
240241 user = self .testdata ['configurableData' ]['host' ]["username" ],
241242 passwd = self .testdata ['configurableData' ]['host' ]["password" ])
242243 res = sshClient .execute (
243- "xe vgpu-list vm-name-label=%s params=type-uuid %s" %
244+ "xe vgpu-list vm-name-label=%s params=type-uuid %s" %
244245 (vm .instancename ))
245246 self .debug ("SSH result: %s" % res )
246247 except Exception as e :
247- self .fail ("SSH Access failed for %s: %s" %
248+ self .fail ("SSH Access failed for %s: %s" %
248249 (hostip , e )
249250 )
250251 result = str (res )
@@ -253,46 +254,36 @@ def test_deploy_vgpu_enabled_vm(self):
253254 1 ,
254255 "VM is vGPU enabled."
255256 )
257+ self .cleanup .append (self .account )
256258
257259 def tearDown (self ):
258260 try :
259261 cleanup_resources (self .apiclient , self .cleanup )
260262 except Exception as e :
261263 self .debug ("Warning! Exception in tearDown: %s" % e )
264+ return
262265
263266 @attr (tags = ["advanced" ])
264267 def test_3d_gpu_support (self ):
265- """
268+ """Test 3D GPU support
266269
267270 # 1. Register a template for VMware with nicAdapter vmxnet3 and 3D GPU details
268271 # 2. Deploy a VM using this template
269272 # 3. Create an isolated network
270273 # 4. Add network to VM
271274 # 5. Verify vm details for 3D GPU details
272275 """
273-
274276 if self .hypervisor .lower () not in ["vmware" ]:
277+ self .cleanup .append (self .account )
275278 self .skipTest ("This test case is written specifically\
276279 for Vmware hypervisor" )
277280
278- # Register a private template in the account with nic adapter vmxnet3
279- # Also add required 3D GPU details for enabling it
280- template = Template .register (
281- self .userapiclient ,
282- self .testdata ["configurableData" ]["vmxnet3template" ],
283- zoneid = self .zone .id ,
284- account = self .account .name ,
285- domainid = self .account .domainid ,
286- details = [{"mks.enable3d" : "true" , "mks.use3dRenderer" : "automatic" ,
287- "svga.autodetect" : "false" , "svga.vramSize" : "131072" }]
288- )
289- self .cleanup .append (template )
290- template .download (self .apiclient )
281+ self .template .download (self .apiclient )
291282
292283 templates = Template .list (
293284 self .userapiclient ,
294285 listall = True ,
295- id = template .id ,
286+ id = self . template .id ,
296287 templatefilter = "self"
297288 )
298289
@@ -303,28 +294,30 @@ def test_3d_gpu_support(self):
303294 )
304295
305296 self .testdata ["virtual_machine" ]["zoneid" ] = self .zone .id
306- self .testdata ["virtual_machine" ]["template" ] = template .id
297+ self .testdata ["virtual_machine" ]["template" ] = self . template .id
307298
308- virtual_machine = VirtualMachine .create (
299+ self . virtual_machine = VirtualMachine .create (
309300 self .apiclient ,
310301 self .testdata ["virtual_machine" ],
311302 accountid = self .account .name ,
312303 domainid = self .account .domainid ,
313- templateid = template .id ,
304+ templateid = self . template .id ,
314305 serviceofferingid = self .service_offering .id )
315306
316- isolated_network = Network .create (
307+ self . isolated_network = Network .create (
317308 self .apiclient ,
318309 self .testdata ["isolated_network" ],
319310 self .account .name ,
320311 self .account .domainid ,
321312 networkofferingid = self .isolated_network_offering .id )
322313
323- virtual_machine .add_nic (self .apiclient , isolated_network .id )
314+ self .virtual_machine .add_nic (self .apiclient , self .isolated_network .id )
315+
316+ self .cleanup = [self .virtual_machine , self .isolated_network , self .isolated_network_offering , self .service_offering , self .account , self .template ]
324317
325- qresultset = self .dbclient .execute ("select id from vm_instance where uuid = '%s';" % virtual_machine .id )
318+ qresultset = self .dbclient .execute ("select id from vm_instance where uuid = '%s';" % self . virtual_machine .id )
326319 vm_id = qresultset [0 ]
327- qresultset = self .dbclient .execute ("select name, value from user_vm_details where vm_id = '%d';" % vm_id )
320+ qresultset = self .dbclient .execute ("select name, value from user_vm_details where vm_id = '%d';" % vm_id )
328321 detailKeys = [x [0 ] for x in qresultset ]
329322
330323 self .assertTrue ('mks.enable3d' in detailKeys and 'mks.use3dRenderer' in detailKeys and 'svga.autodetect' in detailKeys and 'svga.vramSize' in detailKeys , "VM details do not contain 3D GPU details" )
@@ -336,3 +329,5 @@ def test_3d_gpu_support(self):
336329 self .assertEquals ('false' , qresultset [detailKeys .index ('svga.autodetect' )][1 ], "Expected detail 'svga.autodetect'='false'" )
337330
338331 self .assertEquals ('131072' , qresultset [detailKeys .index ('svga.vramSize' )][1 ], "Expected detail 'svga.vramSize'='131072'" )
332+
333+ return
0 commit comments