Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test Automation: How to simulate power failure/machine crash?

I have a delphi application that relies on SQLite3, a DB engine that's advertised as crash-proof.

So far I was able to make my whole application crash-proof, but now I need to simulate brutal machine reboot / power failure.

Obviously it would crazy/unpractical to brutally reboot my machine 100 times / per day just to conduct this test, so...

I wonder if there's a way to simulate power failure using VirtualBox (or something similar) programmatically / in an automated fashion?

Any other method/thought would be more than welcome, my goal is to make sure my users' data is never corrupted.

PS. This question is for Windows XP or later

like image 252
TheDude Avatar asked Dec 17 '12 08:12

TheDude


1 Answers

Running this on the virtual box host should do the trick

VBoxManage controlvm (vmname) reset/poweroff

VBoxManage controlvm (vmname) reset has the same effect on a virtual machine as pressing the "Reset" button on a real computer: a cold reboot of the virtual machine, which will restart and boot the guest operating system again immediately. The state of the VM is not saved beforehand, and data may be lost. (This is equivalent to selecting the "Reset" item in the "Machine" menu of the GUI.)

VBoxManage controlvm (vmname) poweroff has the same effect on a virtual machine as pulling the power cable on a real computer. Again, the state of the VM is not saved beforehand, and data may be lost. (This is equivalent to selecting the "Close" item in the "Machine" menu of the GUI or pressing the window's close button, and then selecting "Power off the machine" in the dialog.)

like image 119
Yanaki Avatar answered Oct 21 '22 02:10

Yanaki