Gce管理器
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) GceManager (DeviceDescriptor deviceDesc, TestDeviceOptions deviceOptions, IBuildInfo buildInfo, testResourceBuildInfos) 该构造函数已被弃用。使用其他构造函数,我们暂时保留它以实现向后兼容性。 | |
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 从设备获取错误报告,以避免任何 adb 连接潜在问题。 |
static String | getInstanceSerialLog ( GceAvdInfo infos, File avdConfigFile, File jsonKeyFile, IRunUtil runUtil) 读取 Gce Avd 实例串行日志的当前内容。 |
static File | getNestedDeviceSshBugreportz ( GceAvdInfo gceAvd, TestDeviceOptions options, IRunUtil runUtil) 通过 ssh 获取嵌套实例的错误报告。 |
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) 记录 |
static CommandResult | remoteSshCommandExecution ( GceAvdInfo gceAvd, TestDeviceOptions options, IRunUtil runUtil, long timeoutMs, String... command) 通过 ssh 在实例上执行远程命令。 |
boolean | shutdownGce () 关闭与 |
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
公共构造函数
Gce管理器
public GceManager (DeviceDescriptor deviceDesc, TestDeviceOptions deviceOptions, IBuildInfo buildInfo)
科特
参数 | |
---|---|
deviceDesc | DeviceDescriptor :将与 GCE 设备关联的DeviceDescriptor 。 |
deviceOptions | TestDeviceOptions :与设备关联的TestDeviceOptions 。 |
buildInfo | IBuildInfo :描述要启动的 gce 构建的IBuildInfo 。 |
Gce管理器
public GceManager (DeviceDescriptor deviceDesc, TestDeviceOptions deviceOptions, IBuildInfo buildInfo,testResourceBuildInfos)
该构造函数已被弃用。
使用其他构造函数,我们暂时保留它以实现向后兼容性。
参数 | |
---|---|
deviceDesc | DeviceDescriptor |
deviceOptions | TestDeviceOptions |
buildInfo | IBuildInfo |
testResourceBuildInfos |
Gce管理器
public GceManager (DeviceDescriptor deviceDesc, TestDeviceOptions deviceOptions, IBuildInfo buildInfo, String gceInstanceName, String gceHost)
Ctor,可用于提供 GCE 实例名称以直接使用的变体。
参数 | |
---|---|
deviceDesc | DeviceDescriptor :将与 GCE 设备关联的DeviceDescriptor 。 |
deviceOptions | TestDeviceOptions :与设备关联的TestDeviceOptions |
buildInfo | IBuildInfo :描述要启动的 gce 构建的IBuildInfo 。 |
gceInstanceName | String :要使用的实例名称。 |
gceHost | String :要使用的实例的主机名或 IP。 |
公共方法
Acloud关机
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 | 如果成功则为真 |
清理
public void cleanUp ()
getBugreportzWithSsh
public static File getBugreportzWithSsh (GceAvdInfo gceAvd, TestDeviceOptions options, IRunUtil runUtil)
使用 ssh 从设备获取错误报告,以避免任何 adb 连接潜在问题。
参数 | |
---|---|
gceAvd | GceAvdInfo :描述设备的GceAvdInfo 。 |
options | TestDeviceOptions : TestDeviceOptions 描述用于 GCE 设备的设备选项。 |
runUtil | IRunUtil :执行命令的IRunUtil 。 |
退货 | |
---|---|
File | 指向 zip 错误报告的文件,如果发生问题则为 null。 |
获取实例序列日志
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 获取嵌套实例的错误报告。这需要请求嵌套虚拟实例中的adb。
参数 | |
---|---|
gceAvd | GceAvdInfo :描述设备的GceAvdInfo 。 |
options | TestDeviceOptions : TestDeviceOptions 描述用于 GCE 设备的设备选项。 |
runUtil | IRunUtil :执行命令的IRunUtil 。 |
退货 | |
---|---|
File | 指向 zip 错误报告的文件,如果发生问题则为 null。 |
日志嵌套远程文件
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 。 |
日志嵌套远程文件
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,则将使用实际文件名。 |
日志串行输出
public void logSerialOutput (GceAvdInfo infos, ITestLogger logger)
记录GceAvdInfo
描述的设备的串行输出。
参数 | |
---|---|
infos | GceAvdInfo :描述实例的GceAvdInfo 。 |
logger | ITestLogger : ITestLogger 记录串行日志的位置。 |
远程Ssh命令执行
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 shutdown 作为非阻塞,则返回 true。 |
启动Gce
public GceAvdInfo startGce (String ipDevice, MultiMap<String, String> attributes)
尝试启动gce实例
参数 | |
---|---|
ipDevice | String :运行 AVD 的 GCE 实例的初始 IP,如果不适用则为null |
attributes | MultiMap :与当前调用关联的属性,用于将适用的信息传递到 GCE 实例以作为 VM 元数据添加 |
退货 | |
---|---|
GceAvdInfo | 描述 GCE 实例的GceAvdInfo 。可能是 BOOT_FAIL 实例。 |
投掷 | |
---|---|
TargetSetupError |
受保护的方法
构建GceCmd
protectedbuildGceCmd (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 启动日志中检索实例名称。搜索“名称”:“gce-”
参数 | |
---|---|
bootupLogs | String |
退货 | |
---|---|
String |