Changeset 108803 in vbox for trunk/src/VBox/ValidationKit/tests/api
- Timestamp:
- Mar 31, 2025 5:47:02 PM (6 weeks ago)
- svn:sync-xref-src-repo-rev:
- 168246
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/api/tdSnapshots1.py
r106061 r108803 54 54 from testdriver import base 55 55 from testdriver import reporter 56 from testdriver import vbox 56 57 from testdriver import vboxcon 57 58 58 59 59 class SubTstDrvNested Snapshots1(base.SubTestDriverBase):60 class SubTstDrvNestedLiveSnapshots1(base.SubTestDriverBase): 60 61 """ 61 62 Sub-test driver for nested snapshot testing. 62 63 """ 63 64 def __init__(self, oTstDrv): 64 base.SubTestDriverBase.__init__(self, oTstDrv, 'nested- snapshots', 'NestedSnapshot Testing');65 self.sVmName = 'tst-nested- snapshots';65 base.SubTestDriverBase.__init__(self, oTstDrv, 'nested-live-snapshots', 'Nested Live Snapshot Testing'); 66 self.sVmName = 'tst-nested-live-snapshots'; 66 67 # Note that any VM can be used here as these tests simply involve taking 67 68 # online snapshots and restoring them. This OL6 image was chosen based purely … … 78 79 Execute the sub-testcases. 79 80 """ 80 return self.testRestoreNestedSnapshot() \ 81 and self.testDeleteSnapshots(); 81 return self.testRestoreNestedLiveSnapshot() \ 82 and self.testDeleteNestedLiveSnapshot() \ 83 and self.testDeleteLiveSnapshots(); 82 84 83 85 # 84 86 # Test execution helpers. 85 87 # 86 def testRestoreNested Snapshot(self):88 def testRestoreNestedLiveSnapshot(self): 87 89 """ 88 90 The scenario being exercised here is referenced in xTracker 10252 Comment #9 89 where the sequence of restoring a nested snapshot and then booting that restored91 where the sequence of restoring a nested live snapshot and then booting that restored 90 92 VM would accidentally delete that snapshot's saved state file during boot. So 91 93 here we perform the following steps to exercise this functionality: 92 + Take t wo online snapshots of the VM: 'alpha', and 'beta' (IMachine::takeSnapshot())94 + Take three online snapshots of the VM: 'alpha', 'beta' and 'gamma' (IMachine::takeSnapshot()) 93 95 + Restore snapshot 'beta' (IMachine::restoreSnapshot()) 94 96 + Boot and then poweroff the VM 95 97 + Verify snapshot 'beta' still exists (IMachine::findSnapshot()) 96 98 """ 97 reporter.testStart('testRestoreNested Snapshot');99 reporter.testStart('testRestoreNestedLiveSnapshot'); 98 100 reporter.log('Verify saved state file exists after nested snapshot restore'); 99 101 … … 117 119 self.oTstDrv.addTask(oTxsSession); 118 120 119 # Take t woonline snapshots.120 reporter.log('Taking t woonline snapshots of test VM: \'%s\'' % self.sVmName);121 # Take three online snapshots. 122 reporter.log('Taking three online snapshots of test VM: \'%s\'' % self.sVmName); 121 123 fRc = oSession.takeSnapshot('alpha'); 122 124 fRc = fRc and oSession.takeSnapshot('beta'); 125 fRc = fRc and oSession.takeSnapshot('gamma'); 126 if not fRc: 127 return reporter.error('Failed to take online snapshot of test VM: \'%s\'' % self.sVmName); 123 128 124 129 # Shutdown the VM and cleanup. … … 131 136 oTxsSession = None; 132 137 if not fRc: 133 return reporter.error('Failed to take snapshot of test VM: \'%s\'' % self.sVmName);138 return reporter.error('Failed to take online snapshot of test VM: \'%s\'' % self.sVmName); 134 139 135 140 oVM = self.oTstDrv.getVmByName(self.sVmName); … … 180 185 return reporter.testFailure('Failed to close session of test VM: \'%s\'' % self.sVmName); 181 186 182 reporter.log('Verifying nested snapshot \'beta\' still exists.');187 reporter.log('Verifying nested online snapshot \'beta\' still exists.'); 183 188 oVM = self.oTstDrv.getVmByName(self.sVmName); 184 189 oSession = self.oTstDrv.openSession(oVM); … … 193 198 194 199 195 def testDeleteSnapshots(self): 200 def testDeleteNestedLiveSnapshot(self): 201 """ 202 The scenario being exercised here is to verify that removing a nested online 203 snapshot also removes its corresponding saved state ('.sav') file. A regression 204 caused IMachine::deleteSnapshot() to remove a live snapshot from the VM's 205 settings but left the '.sav' file behind. So here we perform the following steps to 206 exercise this functionality: 207 + Delete live snapshot 'gamma' (IMachine::deleteSnapshot()) 208 + Check that the 'gamma' snapshot was removed 209 + Verify that the 'gamma' snapshot's '.sav' file was removed as well 210 """ 211 212 reporter.testStart('testDeleteNestedLiveSnapshot'); 213 reporter.log('Verify IMachine::deleteSnapshot() deletes a nested live snapshot along with its .sav file'); 214 oVM = self.oTstDrv.getVmByName(self.sVmName); 215 oSession = self.oTstDrv.openSession(oVM); 216 if oSession is None: 217 return reporter.error('Failed to create session for test VM: \'%s\'' % self.sVmName); 218 219 oSnapshot = oSession.findSnapshot('gamma'); 220 if oSnapshot is None: 221 return reporter.testFailure('Failed to find snapshot \'gamma\' of test VM: \'%s\'' % self.sVmName); 222 223 # Save the path to gamma's '.sav' file while the snapshot still exists for querying later. 224 strSaveFilePath = oSnapshot.machine.stateFilePath; 225 reporter.log('Calling IMachine::deleteSnapshot() to delete snapshot \'gamma\''); 226 # Call IMachine::deleteSnapshot() (or its historic equivalent) to remove the 227 # live snapshot named 'gamma' 228 fRc = oSession.deleteSnapshot(oSnapshot.id, cMsTimeout = 120 * 1000); 229 if not fRc: 230 return reporter.error('Failed to delete snapshot \'gamma\''); 231 232 # Verify that the snapshot was indeed removed as well as its corresponding saved 233 # state file. 234 reporter.log('Verifying snapshot \'gamma\' was deleted'); 235 try: 236 oSnapshot = oSession.findSnapshot('gamma'); 237 except vbox.ComException as oXcpt: 238 if vbox.ComError.notEqual(oXcpt, vbox.ComError.VBOX_E_OBJECT_NOT_FOUND): 239 return reporter.testFailure('Failed to delete snapshot \'gamma\' of test VM: \'%s\'' % self.sVmName); 240 241 reporter.log('Verifying that the \'gamma\' snapshot\'s \'.sav\' file was deleted'); 242 if os.path.exists(strSaveFilePath): 243 return reporter.error('The saved state file of snapshot \'gamma\' was not deleted'); 244 245 return reporter.testDone()[1] == 0; 246 247 248 def testDeleteLiveSnapshots(self): 196 249 """ 197 250 The scenario being exercised here is also referenced in xTracker 10252 Comment #9 198 where unregistering and deleting a VM which contained one or more snapshots would251 where unregistering and deleting a VM which contained one or more live snapshots would 199 252 neglect to delete the snapshot(s). So here we perform the following steps to 200 253 exercise this functionality which conveniently also tidies up our test setup: … … 204 257 """ 205 258 206 reporter.testStart('testDelete Snapshots');259 reporter.testStart('testDeleteLiveSnapshots'); 207 260 reporter.log('Verify IMachine::unregister()+IMachine::deleteConfig() deletes snapshots'); 208 261 oVM = self.oTstDrv.getVmByName(self.sVmName); … … 255 308 sys.path.append(os.path.dirname(os.path.abspath(__file__))); 256 309 from tdApi1 import tdApi1; # pylint: disable=relative-import 257 sys.exit(tdApi1([SubTstDrvNested Snapshots1]).main(sys.argv))310 sys.exit(tdApi1([SubTstDrvNestedLiveSnapshots1]).main(sys.argv))
Note:
See TracChangeset
for help on using the changeset viewer.