本文整理匯總了Python中ambari_agent.ActionQueue.ActionQueue.executeCommand方法的典型用法代碼示例。如果您正苦於以下問題:Python ActionQueue.executeCommand方法的具體用法?Python ActionQueue.executeCommand怎麽用?Python ActionQueue.executeCommand使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ambari_agent.ActionQueue.ActionQueue
的用法示例。
在下文中一共展示了ActionQueue.executeCommand方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_upgradeCommand_executeCommand
# 需要導入模塊: from ambari_agent.ActionQueue import ActionQueue [as 別名]
# 或者: from ambari_agent.ActionQueue.ActionQueue import executeCommand [as 別名]
def test_upgradeCommand_executeCommand(self, action_conf_handler_findRunDir_method,
puppet_executor_run_command_method, perform_stack_upgrade_method):
queue = ActionQueue(config = MagicMock())
command = {
'commandId': 17,
'role' : "role",
'taskId' : "taskId",
'clusterName' : "clusterName",
'serviceName' : "serviceName",
'roleCommand' : 'UPGRADE',
'hostname' : "localhost.localdomain",
'hostLevelParams': "hostLevelParams",
'clusterHostInfo': "clusterHostInfo",
'configurations': "configurations",
'commandType': "EXECUTION_COMMAND",
'configurations':{'global' : {}},
'roleParams': {},
'commandParams' : {
'source_stack_version' : 'HDP-1.2.1',
'target_stack_version' : 'HDP-1.3.0'
}
}
upgrade_method_return_value = {'exitcode' : 0,
'stdout' : 'abc',
'stderr' : 'def'}
perform_stack_upgrade_method.return_value = upgrade_method_return_value
result = queue.executeCommand(command)
expected_result = [{'actionId': 17,
'clusterName': 'clusterName',
'exitCode': 0,
'role': 'role',
'serviceName': 'serviceName',
'status': 'COMPLETED',
'stderr': 'def',
'stdout': 'abc',
'taskId': 'taskId',
'roleCommand': 'UPGRADE'}]
self.assertEquals(result, expected_result)
puppet_executor_run_command_method.return_value = {'exitcode' : 0,
'stdout' : 'abc',
'stderr' : 'def'}
command['roleCommand'] = 'START'
action_conf_handler_findRunDir_method.return_value = AmbariConfig().getConfig().get("stack", "installprefix")
expected_result[0]['configurationTags'] = None
expected_result[0]['roleCommand'] = 'START'
result = queue.executeCommand(command)
self.assertEquals(result, expected_result)
#--------------------------------------------
command['roleCommand'] = 'UPGRADE'
upgrade_method_return_value['exitcode'] = 1
upgrade_method_return_value['stdout'] = ''
upgrade_method_return_value['stderr'] = ''
perform_stack_upgrade_method.return_value = upgrade_method_return_value
result = queue.executeCommand(command)
expected_result[0]['roleCommand'] = 'UPGRADE'
del expected_result[0]['configurationTags']
expected_result[0]['exitCode'] = 1
expected_result[0]['stderr'] = 'None'
expected_result[0]['stdout'] = 'None'
expected_result[0]['status'] = 'FAILED'
self.assertEquals(result, expected_result)