1616# under the License.
1717""" P1 tests for Scaling up Vm
1818"""
19+
20+ import math
21+
1922# Import Local Modules
2023from marvin .cloudstackTestCase import cloudstackTestCase
2124from marvin .lib .base import (VirtualMachine , Volume , DiskOffering , ServiceOffering , Template )
22- from marvin .lib .common import (get_zone , get_domain )
25+ from marvin .lib .common import (get_zone , get_domain , list_storage_pools )
2326from nose .plugins .attrib import attr
2427
2528_multiprocess_shared_ = True
@@ -78,8 +81,13 @@ def test_01_restore_vm(self):
7881 self ._cleanup .append (virtual_machine )
7982
8083 old_root_vol = Volume .list (self .apiclient , virtualmachineid = virtual_machine .id )[0 ]
84+ old_root_vol_pool_res = list_storage_pools (self .apiclient , id = old_root_vol .storageid )
85+ old_root_vol_pool = old_root_vol_pool_res [0 ]
86+ expected_old_root_vol_size = self .template_t1 .size
87+ if old_root_vol_pool .type .lower () == "powerflex" :
88+ expected_old_root_vol_size = (int (math .ceil ((expected_old_root_vol_size / (1024 ** 3 )) / 8 ) * 8 )) * (1024 ** 3 )
8189 self .assertEqual (old_root_vol .state , 'Ready' , "Volume should be in Ready state" )
82- self .assertEqual (old_root_vol .size , self . template_t1 . size , "Size of volume and template should match" )
90+ self .assertEqual (old_root_vol .size , expected_old_root_vol_size , "Size of volume and template should match" )
8391
8492 virtual_machine .restore (self .apiclient , self .template_t2 .id , expunge = True )
8593
@@ -88,8 +96,13 @@ def test_01_restore_vm(self):
8896 self .assertEqual (restored_vm .templateid , self .template_t2 .id , "VM's template after restore is incorrect" )
8997
9098 root_vol = Volume .list (self .apiclient , virtualmachineid = restored_vm .id )[0 ]
99+ root_vol_pool_res = list_storage_pools (self .apiclient , id = root_vol .storageid )
100+ root_vol_pool = root_vol_pool_res [0 ]
101+ expected_root_vol_size = self .template_t2 .size
102+ if root_vol_pool .type .lower () == "powerflex" :
103+ expected_root_vol_size = (int (math .ceil ((expected_root_vol_size / (1024 ** 3 )) / 8 ) * 8 )) * (1024 ** 3 )
91104 self .assertEqual (root_vol .state , 'Ready' , "Volume should be in Ready state" )
92- self .assertEqual (root_vol .size , self . template_t2 . size , "Size of volume and template should match" )
105+ self .assertEqual (root_vol .size , expected_root_vol_size , "Size of volume and template should match" )
93106
94107 old_root_vol = Volume .list (self .apiclient , id = old_root_vol .id )
95108 self .assertEqual (old_root_vol , None , "Old volume should be deleted" )
@@ -105,8 +118,13 @@ def test_02_restore_vm_with_disk_offering(self):
105118 self ._cleanup .append (virtual_machine )
106119
107120 old_root_vol = Volume .list (self .apiclient , virtualmachineid = virtual_machine .id )[0 ]
121+ old_root_vol_pool_res = list_storage_pools (self .apiclient , id = old_root_vol .storageid )
122+ old_root_vol_pool = old_root_vol_pool_res [0 ]
123+ expected_old_root_vol_size = self .template_t1 .size
124+ if old_root_vol_pool .type .lower () == "powerflex" :
125+ expected_old_root_vol_size = (int (math .ceil ((expected_old_root_vol_size / (1024 ** 3 )) / 8 ) * 8 )) * (1024 ** 3 )
108126 self .assertEqual (old_root_vol .state , 'Ready' , "Volume should be in Ready state" )
109- self .assertEqual (old_root_vol .size , self . template_t1 . size , "Size of volume and template should match" )
127+ self .assertEqual (old_root_vol .size , expected_old_root_vol_size , "Size of volume and template should match" )
110128
111129 virtual_machine .restore (self .apiclient , self .template_t2 .id , self .disk_offering .id , expunge = True )
112130
@@ -115,9 +133,14 @@ def test_02_restore_vm_with_disk_offering(self):
115133 self .assertEqual (restored_vm .templateid , self .template_t2 .id , "VM's template after restore is incorrect" )
116134
117135 root_vol = Volume .list (self .apiclient , virtualmachineid = restored_vm .id )[0 ]
136+ root_vol_pool_res = list_storage_pools (self .apiclient , id = root_vol .storageid )
137+ root_vol_pool = root_vol_pool_res [0 ]
138+ expected_root_vol_size = self .disk_offering .disksize
139+ if root_vol_pool .type .lower () == "powerflex" :
140+ expected_root_vol_size = (int (math .ceil (expected_root_vol_size / 8 ) * 8 ))
118141 self .assertEqual (root_vol .diskofferingid , self .disk_offering .id , "Disk offering id should match" )
119142 self .assertEqual (root_vol .state , 'Ready' , "Volume should be in Ready state" )
120- self .assertEqual (root_vol .size , self . disk_offering . disksize * 1024 * 1024 * 1024 ,
143+ self .assertEqual (root_vol .size , expected_root_vol_size * 1024 * 1024 * 1024 ,
121144 "Size of volume and disk offering should match" )
122145
123146 old_root_vol = Volume .list (self .apiclient , id = old_root_vol .id )
@@ -134,8 +157,13 @@ def test_03_restore_vm_with_disk_offering_custom_size(self):
134157 self ._cleanup .append (virtual_machine )
135158
136159 old_root_vol = Volume .list (self .apiclient , virtualmachineid = virtual_machine .id )[0 ]
160+ old_root_vol_pool_res = list_storage_pools (self .apiclient , id = old_root_vol .storageid )
161+ old_root_vol_pool = old_root_vol_pool_res [0 ]
162+ expected_old_root_vol_size = self .template_t1 .size
163+ if old_root_vol_pool .type .lower () == "powerflex" :
164+ expected_old_root_vol_size = (int (math .ceil ((expected_old_root_vol_size / (1024 ** 3 )) / 8 ) * 8 )) * (1024 ** 3 )
137165 self .assertEqual (old_root_vol .state , 'Ready' , "Volume should be in Ready state" )
138- self .assertEqual (old_root_vol .size , self . template_t1 . size , "Size of volume and template should match" )
166+ self .assertEqual (old_root_vol .size , expected_old_root_vol_size , "Size of volume and template should match" )
139167
140168 virtual_machine .restore (self .apiclient , self .template_t2 .id , self .disk_offering .id , rootdisksize = 16 )
141169
0 commit comments