本文整理匯總了Python中ambari_agent.ActionQueue.ActionQueue.startAction方法的典型用法代碼示例。如果您正苦於以下問題:Python ActionQueue.startAction方法的具體用法?Python ActionQueue.startAction怎麽用?Python ActionQueue.startAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ambari_agent.ActionQueue.ActionQueue
的用法示例。
在下文中一共展示了ActionQueue.startAction方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_startAndStopAction
# 需要導入模塊: from ambari_agent.ActionQueue import ActionQueue [as 別名]
# 或者: from ambari_agent.ActionQueue.ActionQueue import startAction [as 別名]
def test_startAndStopAction(self):
command = {'script' : 'import os,sys,time\ni = 0\nwhile (i < 1000):\n print "testhello"\n sys.stdout.flush()\n time.sleep(1)\n i+=1',
'param' : ''}
action={'id' : 'ttt',
'kind' : 'START_ACTION',
'clusterId' : 'foobar',
'clusterDefinitionRevision' : 1,
'component' : 'foocomponent',
'role' : 'foorole',
'command' : command,
'user' : getpass.getuser()
}
actionQueue = ActionQueue(AmbariConfig().getConfig())
result = actionQueue.startAction(action)
cmdResult = result['commandResult']
self.assertEqual(cmdResult['exitCode'], 0, "starting a process failed")
shell = actionQueue.getshellinstance()
key = shell.getServerKey(action['clusterId'],action['clusterDefinitionRevision'],
action['component'],action['role'])
keyPresent = True
if not key in serverTracker:
keyPresent = False
self.assertEqual(keyPresent, True, "Key not present")
plauncher = serverTracker[key]
self.assertTrue(plauncher.getpid() > 0, "Pid less than 0!")
time.sleep(5)
shell.stopProcess(key)
keyPresent = False
if key in serverTracker:
keyPresent = True
self.assertEqual(keyPresent, False, "Key present")
processexists = True
try:
os.kill(serverTracker[key].getpid(),0)
except:
processexists = False
self.assertEqual(processexists, False, "Process still exists!")
self.assertTrue("testhello" in plauncher.out, "Output doesn't match!")