cocluto/ClusterController/TestBug00000003.py

53 lines
1.9 KiB
Python
Raw Normal View History

#!/usr/bin/env python
import sys
sys.path.insert(0, '..')
from Log import *
import Util
from PowerState import *
from HTMLParser import HTMLParser
def Test0000():
logInfo('Testing bug 00000003 if a series of wake up, goto sleep can shutdown a machine')
strTargetMachineName = 'simpatix12'
ePowerState = Util.getPowerState(strTargetMachineName)
while True:
if ePowerState == PowerState.ON:
bSuccess = Util.blockingPutMachineToSleep(strTargetMachineName)
assert( bSuccess )
bSuccess = Util.blockingPutMachineToSleep(strTargetMachineName)
ePowerState = PowerState.SLEEP
elif ePowerState == PowerState.SLEEP:
bSuccess = Util.blockingWakeUpMachine(strTargetMachineName)
assert( bSuccess )
ePowerState = PowerState.ON
else:
assert(False)
def Test0001():
logInfo('Testing bug 00000003 : could it be caused by a sleep and a power on at the same tim ?')
strTargetMachineName = 'simpatix12'
ePowerState = Util.getPowerState(strTargetMachineName)
if ePowerState == PowerState.SLEEP:
bSuccess = Util.blockingWakeUpMachine(strTargetMachineName)
assert( bSuccess )
ePowerState = PowerState.ON
assert(ePowerState == PowerState.ON)
Util.executeCommand("ssh %s 'pmset sleepnow'" % strTargetMachineName )
bSuccess = Util.blockingWakeUpMachine(strTargetMachineName)
assert(bSuccess)
def Test0002():
logInfo('Testing bug 00000003 : could it be caused by a power on quickly followed by a sleep ?')
strTargetMachineName = 'simpatix12'
ePowerState = Util.getPowerState(strTargetMachineName)
if ePowerState == PowerState.ON:
bSuccess = Util.blockingWakeUpMachine(strTargetMachineName)
assert( bSuccess )
ePowerState = PowerState.SLEEP
assert(ePowerState == PowerState.SLEEP)
Util.executeIpmiCommand( strTargetMachineName, 'chassis power on' )
Util.executeCommand("ssh %s 'pmset sleepnow'" % strTargetMachineName )
if __name__ == '__main__':
Test0000()