Changeset 75377 in vbox for trunk/src/VBox/ValidationKit/tests/storage
- Timestamp:
- Nov 9, 2018 9:24:50 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/storage/tdStorageSnapshotMerging1.py
r75375 r75377 65 65 fileobj = open(filepath,'rb'); 66 66 current = 0; 67 67 68 68 while True: 69 69 buf = fileobj.read(1024 * 1024); … … 71 71 break 72 72 current = zlib.crc32(buf, current); 73 73 74 74 fileobj.close(); 75 75 return current % 2**32; … … 133 133 fRc = self.test1(); 134 134 return fRc; 135 135 136 136 def resizeMedium(self, oMedium, cbNewSize): 137 137 if oMedium.deviceType is not vboxcon.DeviceType_HardDisk: 138 138 return False; 139 139 140 140 if oMedium.type is not vboxcon.MediumType_Normal: 141 141 return False; 142 142 143 143 #currently only VDI can be resizable. Medium variant is not checked, because testcase creates disks itself 144 144 oMediumFormat = oMedium.mediumFormat; 145 145 if oMediumFormat.id != 'VDI': 146 146 return False; 147 147 148 148 cbCurrSize = oMedium.logicalSize; 149 149 # currently reduce is not supported 150 if cbNewSize < cbCurrSize: 151 return False; 152 150 if cbNewSize < cbCurrSize: 151 return False; 152 153 153 try: 154 154 oProgressCom = oMedium.resize(cbNewSize); … … 160 160 reporter.logXcpt('IMedium::resize failed on %s' % (oMedium.name)); 161 161 return False; 162 162 163 163 return True; 164 164 165 165 def getMedium(self, oVM, sController): 166 166 oMediumAttachments = oVM.getMediumAttachmentsOfController(sController); 167 167 168 168 for oAttachment in oMediumAttachments: 169 169 oMedium = oAttachment.medium; … … 173 173 continue; 174 174 return oMedium; 175 176 return None; 177 175 176 return None; 177 178 178 def getSnapshotMedium(self, oSnapshot, sController): 179 179 oVM = oSnapshot.machine; 180 180 oMedium = self.getMedium(oVM, sController); 181 181 182 182 for oChildMedium in oMedium.children: 183 183 for uSnapshotId in oChildMedium.getSnapshotIds(oVM.id): 184 184 if uSnapshotId == oVM.id: 185 185 return oChildMedium; 186 186 187 187 return None; 188 188 189 189 def openMedium(self, sHd, fImmutable = False): 190 190 """ … … 203 203 else: 204 204 oHd = self.oVBox.openHardDisk(sFullName, vboxcon.AccessMode_ReadOnly, False, "", False, ""); 205 205 206 206 except: 207 207 reporter.errorXcpt('failed to open hd "%s"' % (sFullName)); 208 208 return False; 209 209 210 210 try: 211 211 if fImmutable: … … 213 213 else: 214 214 oHd.type = vboxcon.MediumType_Normal; 215 215 216 216 except: 217 217 if fImmutable: … … 219 219 else: 220 220 reporter.errorXcpt('failed to set hd "%s" normal' % (sHd)); 221 221 222 222 return None; 223 223 224 224 return oHd; 225 225 226 226 def cloneMedium(self, oSrcHd, oTgtHd): 227 227 """ … … 237 237 reporter.errorXcpt('failed to clone medium %s to %s' % (oSrcHd.name, oTgtHd.name)); 238 238 return False; 239 239 240 240 return True; 241 241 242 242 def deleteVM(self, oVM): 243 243 try: … … 253 253 oProgress = oVM.delete(None); 254 254 self.waitOnProgress(oProgress); 255 255 256 256 except: 257 257 reporter.logXcpt(); 258 258 259 259 else: 260 260 try: oVM.deleteSettings(); 261 261 except: reporter.logXcpt(); 262 262 263 263 return None; 264 264 265 265 # 266 266 # Test execution helpers. … … 274 274 the actual test result. 275 275 """ 276 276 277 277 (asExts, aTypes) = oDskFmt.describeFileExtensions() 278 278 for i in range(0, len(asExts)): #pylint: disable=consider-using-enumerate … … 280 280 sExt = '.' + asExts[i] 281 281 break 282 282 283 283 if sExt is None: 284 284 return False; 285 285 286 286 oOrigBaseHd = self.openMedium('5.3/storage/mergeMedium/t-orig.vdi'); 287 287 if oOrigBaseHd is None: 288 288 return False; 289 289 290 290 #currently only VDI can be resizable. Medium variant is not checked, because testcase creates disks itself 291 fFmtDynamic = oDskFmt.id == 'VDI'; 291 fFmtDynamic = oDskFmt.id == 'VDI'; 292 292 sOrigWithDiffHd = '5.3/storage/mergeMedium/t-fixed.vdi' 293 293 uOrigCrc = 0x7a417cbb; 294 294 295 295 if fFmtDynamic: 296 296 sOrigWithDiffHd = '5.3/storage/mergeMedium/t-resized.vdi'; 297 297 uOrigCrc = 0xa8f5daa3; 298 298 299 299 oOrigWithDiffHd = self.openMedium(sOrigWithDiffHd); 300 300 if oOrigWithDiffHd is None: 301 301 return False; 302 302 303 303 oVM = self.createTestVM('testvm', 1, None); 304 304 if oVM is None: 305 305 return False; 306 306 307 307 sController = _ControllerTypeToName(eStorageController); 308 308 309 309 # Reconfigure the VM 310 310 oSession = self.openSession(oVM); … … 320 320 fRc = fRc and oHd is not None and (oHd.logicalSize == oOrigBaseHd.logicalSize); 321 321 fRc = fRc and self.cloneMedium(oOrigBaseHd, oHd); 322 322 323 323 fRc = fRc and oSession.ensureControllerAttached(sController); 324 324 fRc = fRc and oSession.setStorageControllerType(eStorageController, sController); 325 325 fRc = fRc and oSession.saveSettings(); 326 326 fRc = fRc and oSession.attachHd(sHddPath, sController, iPort = 0, fImmutable=False, fForceResource=False) 327 327 328 328 if fRc: 329 329 oSession.takeSnapshot('Base snapshot'); 330 330 oSnapshot = oSession.findSnapshot('Base snapshot'); 331 331 332 332 if oSnapshot is not None: 333 333 oSnapshotMedium = self.getSnapshotMedium(oSnapshot, sController); 334 334 fRc = oSnapshotMedium is not None; 335 335 336 336 if fFmtDynamic: 337 337 fRc = fRc and self.resizeMedium(oSnapshotMedium, oOrigWithDiffHd.logicalSize); 338 338 fRc = fRc and self.cloneMedium(oOrigWithDiffHd, oSnapshotMedium); 339 339 fRc = fRc and oSession.deleteSnapshot(oSnapshot.id, cMsTimeout = 120 * 1000); 340 340 341 341 if fRc: 342 342 # disk for result test by checksum … … 418 418 if __name__ == '__main__': 419 419 sys.exit(tdStorageSnapshot().main(sys.argv)); 420
Note:
See TracChangeset
for help on using the changeset viewer.