本文整理汇总了Python中ambari_agent.ActionQueue.ActionQueue.getshellinstance方法的典型用法代码示例。如果您正苦于以下问题:Python ActionQueue.getshellinstance方法的具体用法?Python ActionQueue.getshellinstance怎么用?Python ActionQueue.getshellinstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ambari_agent.ActionQueue.ActionQueue
的用法示例。
在下文中一共展示了ActionQueue.getshellinstance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_startAndStopAction
# 需要导入模块: from ambari_agent.ActionQueue import ActionQueue [as 别名]
# 或者: from ambari_agent.ActionQueue.ActionQueue import getshellinstance [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!")