1515# specific language governing permissions and limitations
1616# under the License.
1717
18- #Import Local Modules
19- from marvin .cloudstackTestCase import cloudstackTestCase
20- from marvin .cloudstackAPI import (createVolume ,
21- createTemplate )
22- from marvin .lib .base import (Volume ,
23- Iso ,
24- VirtualMachine ,
25- Template ,
26- Snapshot ,
27- SecurityGroup ,
28- Account ,
29- Zone ,
30- Network ,
31- NetworkOffering ,
32- DiskOffering ,
33- ServiceOffering ,
34- VmSnapshot ,
35- SnapshotPolicy ,
36- SSHKeyPair ,
37- Resources ,
38- Configurations ,
39- VpnCustomerGateway ,
40- Hypervisor ,
41- VpcOffering ,
42- VPC ,
43- NetworkACL )
44- from marvin .lib .common import (get_zone ,
45- get_domain ,
46- get_template ,
47- list_os_types )
48- from marvin .lib .utils import (validateList ,
49- cleanup_resources ,
50- random_gen )
51- from marvin .codes import (PASS , FAIL , EMPTY_LIST )
18+ # Import Local Modules
19+ from marvin .cloudstackTestCase import *
20+ from marvin .cloudstackException import *
21+ from marvin .cloudstackAPI import *
22+ from marvin .sshClient import SshClient
23+ from marvin .lib .utils import *
24+ from marvin .lib .base import *
25+ from marvin .lib .common import *
26+ from marvin .lib .utils import checkVolumeSize
27+ from marvin .codes import SUCCESS
5228from nose .plugins .attrib import attr
53- import time
29+ from time import sleep
30+ from ctypes .wintypes import BOOLEAN
5431
5532class TestListInstances (cloudstackTestCase ):
5633
5734 @classmethod
5835 def setUpClass (cls ):
5936 try :
60- cls ._cleanup = []
37+ cls ._cleanup = []
6138 cls .testClient = super (TestListInstances , cls ).getClsTestClient ()
6239 cls .api_client = cls .testClient .getApiClient ()
6340 cls .services = cls .testClient .getParsedTestDataConfig ()
41+ cls .hypervisor = cls .testClient .getHypervisorInfo ()
6442 # Get Domain, Zone, Template
6543 cls .domain = get_domain (cls .api_client )
6644 cls .zone = get_zone (cls .api_client , cls .testClient .getZoneForTests ())
@@ -101,7 +79,7 @@ def setUpClass(cls):
10179 cls .user = cls .account .user [0 ]
10280 cls .userapiclient = cls .testClient .getUserApiClient (cls .user .username , cls .domain .name )
10381 # Updating resource Limits
104- for i in range (0 ,12 ):
82+ for i in range (0 , 12 ):
10583 Resources .updateLimit (
10684 cls .api_client ,
10785 account = cls .account .name ,
@@ -124,7 +102,7 @@ def setUp(self):
124102 self .cleanup = []
125103
126104 def tearDown (self ):
127- #Clean up, terminate the created resources
105+ # Clean up, terminate the created resources
128106 cleanup_resources (self .apiClient , self .cleanup )
129107 return
130108
@@ -194,7 +172,7 @@ def test_01_list_instances_pagination(self):
194172 list_instances_before ,
195173 "Virtual Machine already exists for newly created user"
196174 )
197- # If number of instances are less than (pagesize + 1), then creating them
175+ # If number of instances are less than (pagesize + 1), then creating them
198176 for i in range (0 , (self .services ["pagesize" ] + 1 )):
199177 vm_created = VirtualMachine .create (
200178 self .userapiclient ,
@@ -216,7 +194,7 @@ def test_01_list_instances_pagination(self):
216194 "Newly created VM name and the test data VM name are not matching"
217195 )
218196
219- # Listing all the instances again after creating VM's
197+ # Listing all the instances again after creating VM's
220198 list_instances_after = VirtualMachine .list (self .userapiclient , listall = self .services ["listall" ])
221199 status = validateList (list_instances_after )
222200 self .assertEquals (
@@ -301,7 +279,7 @@ def test_01_list_instances_pagination(self):
301279 "VM was not deleted"
302280 )
303281 return
304-
282+
305283 @attr (tags = ["advanced" , "basic" , "selfservice" ])
306284 def test_02_list_Running_vm (self ):
307285 """
@@ -363,7 +341,7 @@ def test_02_list_Running_vm(self):
363341 )
364342 running_vm = list_running_vms_after [0 ]
365343
366- #Creating expected and actual values dictionaries
344+ # Creating expected and actual values dictionaries
367345 expected_dict = {
368346 "id" :vm_created .id ,
369347 "name" :vm_created .name ,
@@ -456,7 +434,7 @@ def test_03_list_Stopped_vm(self):
456434 "Stopped VM list count is not matching"
457435 )
458436 stopped_vm = list_stopped_vms_after [0 ]
459- #Creating expected and actual values dictionaries
437+ # Creating expected and actual values dictionaries
460438 expected_dict = {
461439 "id" :vm_created .id ,
462440 "name" :vm_created .name ,
@@ -564,7 +542,7 @@ def test_04_list_Destroyed_vm(self):
564542 "Destroyed VM list count is not matching"
565543 )
566544 destroyed_vm = list_destroyed_vms_admin [0 ]
567- #Creating expected and actual values dictionaries
545+ # Creating expected and actual values dictionaries
568546 expected_dict = {
569547 "id" :vm_created .id ,
570548 "name" :vm_created .name ,
@@ -666,7 +644,7 @@ def test_05_list_vm_by_id(self):
666644 "Listing of VM by Id failed"
667645 )
668646 listed_vm = list_vm_byid [0 ]
669- #Creating expected and actual values dictionaries
647+ # Creating expected and actual values dictionaries
670648 expected_dict = {
671649 "id" :vm_created .id ,
672650 "name" :vm_created .name ,
@@ -782,7 +760,7 @@ def test_06_list_vm_by_name(self):
782760 "VM list by full name count is not matching"
783761 )
784762 # Verifying that the details of the listed VM are same as the VM created above
785- #Creating expected and actual values dictionaries
763+ # Creating expected and actual values dictionaries
786764 expected_dict = {
787765 "id" :vms [0 ].id ,
788766 "name" :vms [0 ].name ,
@@ -916,7 +894,7 @@ def test_07_list_vm_by_name_state(self):
916894 "Count of VM list by name and state is not matching"
917895 )
918896 # Verifying that the details of the listed VM are same as the VM created above
919- #Creating expected and actual values dictionaries
897+ # Creating expected and actual values dictionaries
920898 expected_dict = {
921899 "id" :vm_created .id ,
922900 "name" :vm_created .name ,
@@ -1068,7 +1046,7 @@ def test_08_list_vm_by_zone(self):
10681046 )
10691047 listed_vm = list_vms_after [0 ]
10701048 # Verifying that the details of the Listed VM are same as the VM deployed above
1071- #Creating expected and actual values dictionaries
1049+ # Creating expected and actual values dictionaries
10721050 expected_dict = {
10731051 "id" :vm_created .id ,
10741052 "name" :vm_created .name ,
@@ -1235,7 +1213,7 @@ def test_09_list_vm_by_zone_name(self):
12351213 )
12361214 listed_vm = list_vms [0 ]
12371215 # Verifying that the details of the Listed VM are same as the VM deployed above
1238- #Creating expected and actual values dictionaries
1216+ # Creating expected and actual values dictionaries
12391217 expected_dict = {
12401218 "id" :vm_created .id ,
12411219 "name" :vm_created .name ,
@@ -1388,7 +1366,7 @@ def test_10_list_vm_by_zone_name_state(self):
13881366 )
13891367 listed_vm = list_vms [0 ]
13901368 # Verifying that the details of the Listed VM are same as the VM deployed above
1391- #Creating expected and actual values dictionaries
1369+ # Creating expected and actual values dictionaries
13921370 expected_dict = {
13931371 "id" :vm_created .id ,
13941372 "name" :vm_created .name ,
@@ -1456,7 +1434,7 @@ def test_10_list_vm_by_zone_name_state(self):
14561434 )
14571435 listed_vm = list_vms [0 ]
14581436 # Verifying that the details of the Listed VM are same as the VM deployed above
1459- #Creating expected and actual values dictionaries
1437+ # Creating expected and actual values dictionaries
14601438 expected_dict = {
14611439 "id" :vm_created .id ,
14621440 "name" :vm_created .name ,
@@ -1899,7 +1877,7 @@ def setUpClass(cls):
18991877 cls .testClient = super (TestInstances , cls ).getClsTestClient ()
19001878 cls .api_client = cls .testClient .getApiClient ()
19011879 cls .services = cls .testClient .getParsedTestDataConfig ()
1902-
1880+ cls . hypervisor = cls . testClient . getHypervisorInfo ()
19031881 # Get Domain, Zone, Template
19041882 cls .domain = get_domain (cls .api_client )
19051883 cls .zone = get_zone (cls .api_client , cls .testClient .getZoneForTests ())
@@ -1941,7 +1919,7 @@ def setUpClass(cls):
19411919 cls .user = cls .account .user [0 ]
19421920 cls .userapiclient = cls .testClient .getUserApiClient (cls .user .username , cls .domain .name )
19431921 # Updating resource Limits
1944- for i in range (0 ,12 ):
1922+ for i in range (0 , 12 ):
19451923 Resources .updateLimit (
19461924 cls .api_client ,
19471925 account = cls .account .name ,
@@ -1963,7 +1941,7 @@ def setUp(self):
19631941 self .cleanup = []
19641942
19651943 def tearDown (self ):
1966- #Clean up, terminate the created resources
1944+ # Clean up, terminate the created resources
19671945 cleanup_resources (self .apiClient , self .cleanup )
19681946 return
19691947
@@ -2024,6 +2002,8 @@ def test_13_attach_detach_iso(self):
20242002 Step10: Detaching the ISO attached in step8
20252003 Step11: Verifying that detached ISO details are not associated with VM
20262004 """
2005+ if self .hypervisor .lower () == 'kvm' :
2006+ raise unittest .SkipTest ("VM Snapshot is not supported on KVM. Hence, skipping the test" )
20272007 # Listing all the VM's for a User
20282008 list_vms_before = VirtualMachine .list (
20292009 self .userapiclient ,
@@ -2154,6 +2134,8 @@ def test_14_vm_snapshot_pagination(self):
21542134 Step12: Listing all the VM snapshots in Page 2 with page size
21552135 Step13: Verifying that size of the list is 0
21562136 """
2137+ if self .hypervisor .lower () == 'kvm' :
2138+ raise unittest .SkipTest ("VM Snapshot is not supported on KVM. Hence, skipping the test" )
21572139 # Listing all the VM's for a User
21582140 list_vms_before = VirtualMachine .list (
21592141 self .userapiclient ,
@@ -2309,6 +2291,8 @@ def test_15_revert_vm_to_snapshot(self):
23092291 Step10: Verifying that only 1 VM snapshot is having current flag set as true.
23102292 Step11: Verifying that the VM Snapshot with current flag set to true is the reverted snapshot in Step 8
23112293 """
2294+ if self .hypervisor .lower () == 'kvm' :
2295+ raise unittest .SkipTest ("VM Snapshot is not supported on KVM. Hence, skipping the test" )
23122296 # Listing all the VM's for a User
23132297 list_vms_before = VirtualMachine .list (
23142298 self .userapiclient ,
@@ -2624,6 +2608,32 @@ def test_16_list_vm_volumes_pagination(self):
26242608 list_volumes_page2 ,
26252609 "Volumes listed in page 2"
26262610 )
2611+ # Listing all the volumes for a VM again in page 1
2612+ list_volumes_page1 = Volume .list (
2613+ self .userapiclient ,
2614+ listall = self .services ["listall" ],
2615+ virtualmachineid = vm_created .id ,
2616+ page = 1 ,
2617+ pagesize = self .services ["pagesize" ]
2618+ )
2619+ status = validateList (list_volumes_page1 )
2620+ self .assertEquals (
2621+ PASS ,
2622+ status [0 ],
2623+ "Volumes not listed in page1"
2624+ )
2625+ # Verifying that list size is equal to page size
2626+ self .assertEquals (
2627+ self .services ["pagesize" ],
2628+ len (list_volumes_page1 ),
2629+ "VM's volume count is not matching in page 1"
2630+ )
2631+ # Detaching all the volumes attached from VM
2632+ for i in range (0 , len (list_volumes_page1 )):
2633+ vm_created .detach_volume (
2634+ self .userapiclient ,
2635+ list_volumes_page1 [i ]
2636+ )
26272637 return
26282638
26292639 @attr (tags = ["advanced" , "basic" , "provisioning" ])
@@ -2641,6 +2651,8 @@ def test_17_running_vm_scaleup(self):
26412651 Step5: Perform change service (scale up) the Running VM deployed in step1
26422652 Step6: Verifying that VM's service offerings is changed
26432653 """
2654+ if self .hypervisor .lower () == 'kvm' :
2655+ raise unittest .SkipTest ("ScaleVM is not supported on KVM. Hence, skipping the test" )
26442656 # Checking if Dynamic scaling of VM is supported or not
26452657 list_config = Configurations .list (
26462658 self .apiClient ,
@@ -3445,4 +3457,4 @@ def test_23_deploy_vm_multiple_securitygroups(self):
34453457 vm_securitygroups_flag ,
34463458 "Security Groups in VM are not same as created"
34473459 )
3448- return
3460+ return
0 commit comments