GceManager

public class GceManager
extends Object

java.lang.Object 中
   ↳ com.android.tradefed.device.cloud.GceManager


帮助管理 GCE 调用以启动/停止并从 GCE 收集日志。

摘要

字段

public static final String GCE_HOSTNAME_KEY

public static final String GCE_INSTANCE_CLEANED_KEY

public static final String GCE_INSTANCE_NAME_KEY

公共构造函数

GceManager(DeviceDescriptor deviceDesc, TestDeviceOptions deviceOptions, IBuildInfo buildInfo)

托尔

GceManager(DeviceDescriptor deviceDesc, TestDeviceOptions deviceOptions, IBuildInfo buildInfo, testResourceBuildInfos)

<ph type="x-smartling-placeholder"></ph> 此构造函数已废弃。 使用其他构造函数,为保持向后兼容性,我们暂时将其保留。

GceManager(DeviceDescriptor deviceDesc, TestDeviceOptions deviceOptions, IBuildInfo buildInfo, String gceInstanceName, String gceHost)

ctor,可用于提供要直接使用的 GCE 实例名称的变体。

公共方法

static boolean AcloudShutdown(TestDeviceOptions options, IRunUtil runUtil, String instanceName, String hostname)

实际的 Acloud 运行作业,用于关闭虚拟设备。

void cleanUp()
static File getBugreportzWithSsh(GceAvdInfo gceAvd, TestDeviceOptions options, IRunUtil runUtil)

使用 SSH 从设备获取 bugreportz,以避免任何 adb 连接潜在问题。

static String getInstanceSerialLog(GceAvdInfo infos, File avdConfigFile, File jsonKeyFile, IRunUtil runUtil)

读取 Gce Avd 实例串行日志的当前内容。

static File getNestedDeviceSshBugreportz(GceAvdInfo gceAvd, TestDeviceOptions options, IRunUtil runUtil)

通过 SSH 获取嵌套实例的 bug 报告。

static void logNestedRemoteFile(ITestLogger logger, GceAvdInfo gceAvd, TestDeviceOptions options, IRunUtil runUtil, String remoteFilePath, LogDataType type)

从嵌套实例中提取远程文件并将其记录。

static void logNestedRemoteFile(ITestLogger logger, GceAvdInfo gceAvd, TestDeviceOptions options, IRunUtil runUtil, String remoteFilePath, LogDataType type, String baseName)

从嵌套实例中提取远程文件并将其记录。

void logSerialOutput(GceAvdInfo infos, ITestLogger logger)

记录设备的串行输出(如 GceAvdInfo 所述)。

static CommandResult remoteSshCommandExecution(GceAvdInfo gceAvd, TestDeviceOptions options, IRunUtil runUtil, long timeoutMs, String... command)

在实例上通过 SSH 执行远程命令。

boolean shutdownGce()

关停与 startGce() 关联的 Gce 实例。

GceAvdInfo startGce()
GceAvdInfo startGce(String ipDevice, MultiMap<String, String> attributes)

尝试启动 gce 实例

受保护的方法

buildGceCmd(File reportFile, IBuildInfo b, String ipDevice, MultiMap<String, String> attributes)

构建并返回启动 GCE 的命令。

String extractInstanceName(String bootupLogs)

从 gce 启动日志中检索实例名称。

字段

GCE_HOSTNAME_KEY

public static final String GCE_HOSTNAME_KEY

GCE_INSTANCE_CLEANED_KEY

public static final String GCE_INSTANCE_CLEANED_KEY

GCE_INSTANCE_NAME_KEY

public static final String GCE_INSTANCE_NAME_KEY

公共构造函数

GceManager

public GceManager (DeviceDescriptor deviceDesc, 
                TestDeviceOptions deviceOptions, 
                IBuildInfo buildInfo)

托尔

参数
deviceDesc DeviceDescriptor:将与 GCE 设备关联的 DeviceDescriptor

deviceOptions TestDeviceOptions:与设备关联的 TestDeviceOptions

buildInfo IBuildInfo:描述要启动的 gce build 的 IBuildInfo

GceManager

public GceManager (DeviceDescriptor deviceDesc, 
                TestDeviceOptions deviceOptions, 
                IBuildInfo buildInfo, 
                 testResourceBuildInfos)

<ph type="x-smartling-placeholder"></ph> 此构造函数已废弃。
使用其他构造函数,为保持向后兼容性,我们暂时将其保留。

参数
deviceDesc DeviceDescriptor

deviceOptions TestDeviceOptions

buildInfo IBuildInfo

testResourceBuildInfos

GceManager

public GceManager (DeviceDescriptor deviceDesc, 
                TestDeviceOptions deviceOptions, 
                IBuildInfo buildInfo, 
                String gceInstanceName, 
                String gceHost)

ctor,可用于提供要直接使用的 GCE 实例名称的变体。

参数
deviceDesc DeviceDescriptor:将与 GCE 设备关联的 DeviceDescriptor

deviceOptions TestDeviceOptions:与设备关联的 TestDeviceOptions

buildInfo IBuildInfo:描述要启动的 gce build 的 IBuildInfo

gceInstanceName String:要使用的实例名称。

gceHost String:要使用的实例的主机名或 IP 地址。

公共方法

AcloudShutdown

public static boolean AcloudShutdown (TestDeviceOptions options, 
                IRunUtil runUtil, 
                String instanceName, 
                String hostname)

实际的 Acloud 运行作业,用于关闭虚拟设备。

参数
options TestDeviceOptions:Acloud 选项的 TestDeviceOptions

runUtil IRunUtil:用于运行 Acloud 的 IRunUtil

instanceName String:要关停的实例。

hostname String:实例的主机名,仅用于 Oxygen Cuttlefish。

返回
boolean 如果成功,则为 true

清理

public void cleanUp ()

使用 Ssh 获取错误报告

public static File getBugreportzWithSsh (GceAvdInfo gceAvd, 
                TestDeviceOptions options, 
                IRunUtil runUtil)

使用 SSH 从设备获取 bugreportz,以避免任何 adb 连接潜在问题。

参数
gceAvd GceAvdInfo:用于描述设备的 GceAvdInfo

options TestDeviceOptions:一个 TestDeviceOptions,用于描述要用于 GCE 设备。

runUtil IRunUtil:用于执行命令的 IRunUtil

返回
File 指向 ZIP 错误报告的文件;如果出现问题,则为 null。

getInstanceSerialLog

public static String getInstanceSerialLog (GceAvdInfo infos, 
                File avdConfigFile, 
                File jsonKeyFile, 
                IRunUtil runUtil)

读取 Gce Avd 实例串行日志的当前内容。

参数
infos GceAvdInfo:描述实例的 GceAvdInfo

avdConfigFile File:avd 配置文件

jsonKeyFile File:服务账号 JSON 密钥文件。

runUtil IRunUtil:用于执行命令的 IRunUtil

返回
String 串行日志输出,如果出现问题,则返回 null。

getNestedDeviceSshBugreportz

public static File getNestedDeviceSshBugreportz (GceAvdInfo gceAvd, 
                TestDeviceOptions options, 
                IRunUtil runUtil)

通过 SSH 获取嵌套实例的 bug 报告。这需要在嵌套层中请求 adb 虚拟实例。

参数
gceAvd GceAvdInfo:用于描述设备的 GceAvdInfo

options TestDeviceOptions:一个 TestDeviceOptions,用于描述要用于 GCE 设备。

runUtil IRunUtil:用于执行命令的 IRunUtil

返回
File 指向 ZIP 错误报告的文件;如果出现问题,则为 null。

logNestedRemoteFile

public static void logNestedRemoteFile (ITestLogger logger, 
                GceAvdInfo gceAvd, 
                TestDeviceOptions options, 
                IRunUtil runUtil, 
                String remoteFilePath, 
                LogDataType type)

从嵌套实例中提取远程文件并将其记录。

参数
logger ITestLogger:用于记录文件的 ITestLogger

gceAvd GceAvdInfo:用于描述设备的 GceAvdInfo

options TestDeviceOptions:一个 TestDeviceOptions,用于描述要用于 GCE 设备。

runUtil IRunUtil:用于执行命令的 IRunUtil

remoteFilePath String:文件所在位置的远程路径。

type LogDataType:所记录文件的 LogDataType

logNestedRemoteFile

public static void logNestedRemoteFile (ITestLogger logger, 
                GceAvdInfo gceAvd, 
                TestDeviceOptions options, 
                IRunUtil runUtil, 
                String remoteFilePath, 
                LogDataType type, 
                String baseName)

从嵌套实例中提取远程文件并将其记录。

参数
logger ITestLogger:用于记录文件的 ITestLogger

gceAvd GceAvdInfo:用于描述设备的 GceAvdInfo

options TestDeviceOptions:一个 TestDeviceOptions,用于描述要用于 GCE 设备。

runUtil IRunUtil:用于执行命令的 IRunUtil

remoteFilePath String:文件所在位置的远程路径。

type LogDataType:所记录文件的 LogDataType

baseName String:用于记录文件的基本名称。如果为 null,实际文件名将为 。

logSerialOutput

public void logSerialOutput (GceAvdInfo infos, 
                ITestLogger logger)

记录设备的串行输出(如 GceAvdInfo 所述)。

参数
infos GceAvdInfo:描述实例的 GceAvdInfo

logger ITestLogger:用于记录串行日志的 ITestLogger

RemoteSshCommandExecution

public static CommandResult remoteSshCommandExecution (GceAvdInfo gceAvd, 
                TestDeviceOptions options, 
                IRunUtil runUtil, 
                long timeoutMs, 
                String... command)

在实例上通过 SSH 执行远程命令。

参数
gceAvd GceAvdInfo:用于描述设备的 GceAvdInfo

options TestDeviceOptions:一个 TestDeviceOptions,用于描述要用于 GCE 设备。

runUtil IRunUtil:用于执行命令的 IRunUtil

timeoutMs long:命令的超时时间(以毫秒为单位)。0 表示无超时。

command String:要执行的远程命令。

返回
CommandResult 包含执行结果的 CommandResult

关停 Gce

public boolean shutdownGce ()

关停与 startGce() 关联的 Gce 实例。

返回
boolean 如果将 gce 关闭请求作为非阻塞请求,则返回 true。

startGce

public GceAvdInfo startGce ()

返回
GceAvdInfo

抛出
TargetSetupError

startGce

public GceAvdInfo startGce (String ipDevice, 
                MultiMap<String, String> attributes)

尝试启动 gce 实例

参数
ipDevice String:要在其中运行 AVD 的 GCE 实例的初始 IP,否则为 null 适用

attributes MultiMap:与当前调用关联的属性,用于传递适用的 向下传递到 GCE 实例,以作为虚拟机元数据添加

返回
GceAvdInfo 描述 GCE 实例的 GceAvdInfo。可能是 BOOT_FAIL 实例。

抛出
TargetSetupError

受保护的方法

buildGceCmd

protected  buildGceCmd (File reportFile, 
                IBuildInfo b, 
                String ipDevice, 
                MultiMap<String, String> attributes)

构建并返回启动 GCE 的命令。可供测试。

参数
reportFile File

b IBuildInfo

ipDevice String

attributes MultiMap

返回

提取实例名称

protected String extractInstanceName (String bootupLogs)

从 gce 启动日志中检索实例名称。搜索“name”:“gce-” 来提取其名称。我们从日志而不是结果文件中提取数据,因为 gce 启动失败,尝试的实例名称不会显示在 JSON 中。

参数
bootupLogs String

返回
String