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

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

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.)

Related

Is a mouse click on a remote desktop possible using AutoIt or alternatives?

I want to write a script that involves mouse click and stuff. I am little confused though. Is there a way mouse clicks (in the form of x and y co-ordinates) would work on a VPS which is logged on, but disconnected from the client?
Example:
MouseClick("left",588, 268)
To my knowledge, these VPSes don't have their own native screen resolution. I have already written the script for my local pc and it's working fine on my resolution. But when tried with the VPS, it doesn't work.
PS: I am running the script from the remote desktop itself and not from my local pc. Please correct me if there's anything I am doing wrong :)
Update: For anyone still looking for an answer, consider installing a vnc server, that way the screen resolution you specify is preserved even when not connected to the server.
Ex: https://www.realvnc.com/en/connect/download/vnc/
It's relevant to almost any automation tool, not only AutoIt.
Remote Desktop has its own GUI context only if it's connected to the remote PC. But you can lose focus for a Remote Desktop window (without disconnection & without minimizing) and continue other local work.
The same effect takes place for VNC server software.
One team in our organization uses it for massive test runs automation: a master server creates a remote session for each test machine and keeps them all connected until tests passes.
Use ControlClick to have the mouse click over RDP connections, even when you're not connected. For some reason it can still be iffy for me, but at least it worked more so that Click which was none at all.

IOStorageFamily deleted in error

I have accidentally deleted the file System/Library/Extensions/IOStorageFamily.kext by mistake. I know how stupid this was!
Now my iMac (model 2008, running Mavericks) gets stuck on the grey startup screen and hangs forever after the Apple logo turns into a no entry sign whilst the wheel continues to turn forever, see the following link for image showing this screen:
No entry sign on startup screen
I have run Disk Utility from the install CD and repaired the disk permissions with no success.
I have tried to run the rescue partition by using the Command + R key but this just displays my exsisting HD and does not show another option.
I have tried to boot into single user start with no success. The screen eventually hangs and says it can not find IOStorageFamily.kext.
I have tried to boot into safe mode with no success. It simply fails with the no entry sign as above.
I have reset the PRAM but this did not make any difference.
I have done a hardware test using the D key on startup but this returned no errors.
Please can someone advise if there is any way to fix this problem and if the is then what is the best way to do it? I know that it is not a harddrive failing or anything else and is simply because I accidently deleted the IOStorageFamily.kext file. Surely there is a way to repair this?
I appreciate any help or advice.
Many thanks
I have managed to fix the problem by using the following method:
http://support.apple.com/kb/PH13842
It says:
If you have two Mac computers with FireWire or Thunderbolt ports, you
can connect them so that one of them appears as an external hard disk
on the other. This is called “target disk mode.”
Connect the two computers with a FireWire or Thunderbolt cable. Start
up the computer to be used as a disk in target disk mode: If the
computer is off, start it up while holding down the T key.
If the computer is on, choose Apple menu > System Preferences, click
Startup Disk, then click Target Disk Mode.
When the computer has started up, a disk icon appears on the desktop
of the other computer.
Transfer files by dragging them to and from the disk. Eject the disk
by dragging its icon to the Trash. While you drag, the Trash icon
changes to an Eject icon.
On the computer you used as a disk, push the power button to shut it
down, then disconnect the cable.
After connecting to another Mac I simply copied the deleted file back into the correct directory from the host Mac.
I then booted my Mac successfully and repaired the file permissions via Disk Utility.

Keep windows GUI while switching windows user or closing remote connection

I need to run a GUI script (AutoHotKey, which makes mouse clicks and press keys) on:
A different windows user (i.e. I run the script, then switch user
while keeping the session active)
A remote Amazon windows server (using remote desktop) where I also
run the script then close the Remote Desktop while keeping the
instance running
Unfortunately, in both cases, the script doesn't run as it seems that Windows enters a "GUI-less" mode where all GUI components are not active anymore.
Is there any solution to this?
Any hint would be greatly appreciated as I've now lost days trying to solve this!
Many thanks, Thomas
I do not believe this is possible due to the way Remote Desktop is implemented. When you close the RD connection, the GUI is no longer drawn. Therefore, AutoHotkey is unable to perform mouse clicks and key presses.
A possible workaround would be to make some registry tweaks (if possible on your server) which allow GUI interaction while minimized.
Locate HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client
Create RemoteDesktop SuppressWhenMinimized as DWORD with a value of 2
Registry Tweak Source

User's Preferred poweroff action - Windows

I have a program that takes a long time to run and is intended to run unattended. In Windows, what is the best way to determine the users preferred poweroff action.
What the power button does.
In Windows 7, the start menu logoff action (Which is Shut Down by default).
How can I determine these values on Windows XP, Windows Vista and Windows 7?
Is there an API to do this? (i.e. Shutdown, Suspend, or Hibernate according to users preferences)
If you are using managed code, there is PowerGetActiveScheme. There is an example of how to use it here: http://www.pinvoke.net/default.aspx/powrprof.powergetactivescheme

Way to Alt-Tab through all applications in Virtual and Host PC

I am using VirtualPc 2007 more and more, the one annoyance is "Alt-Tab".
What I want is to be able to use alt-tab to iterate through all of the applications in the host pc and virtual(s) as if they were one long list. Is there a setting or program to do this?
No. If the VPC is in full screen mode, alt+tab works only within the context of the VPC. If the VPC Screen is not focused, you will get the collection of applications that are in the Host (including the instance of VPC)
Sadly, no. This is possible in Parallels on the Mac, in what they call "Coherence" mode. But Virtual PC does not support that kind of integration.
No. If the VPC is in full screen mode, alt+tab works only within the context of the VPC. However, you may find the "Host key+DOWN ARROW" shortcut useful. This minimizes the virtual machine and allows you to alt-tab on the host again.

Resources