当前位置: 首页>>代码示例>>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;未经允许,请勿转载。