當前位置: 首頁>>代碼示例>>Python>>正文


Python ActionQueue.executeCommand方法代碼示例

本文整理匯總了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)
開發者ID:adamosloizou,項目名稱:fiware-cosmos-ambari,代碼行數:72,代碼來源:TestActionQueue.py


注:本文中的ambari_agent.ActionQueue.ActionQueue.executeCommand方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。