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
|
public
static
final
String |
GCE_IP_PRECONFIGURED_KEY
|
公共构造函数 | |
|---|---|
GceManager(DeviceDescriptor deviceDesc, TestDeviceOptions deviceOptions, IBuildInfo buildInfo)
Ctor |
|
GceManager(DeviceDescriptor deviceDesc, TestDeviceOptions deviceOptions, IBuildInfo buildInfo,
此构造函数已废弃。 请使用其他构造函数,我们暂时保留此方法以实现向后兼容性。 |
|
GceManager(DeviceDescriptor deviceDesc, TestDeviceOptions deviceOptions, IBuildInfo buildInfo, String gceInstanceName, String gceHost)
构造函数,可用于提供要直接使用的 GCE 实例名称。 |
|
公共方法 | |
|---|---|
static
boolean
|
AcloudShutdown(TestDeviceOptions options, IRunUtil runUtil, String instanceName, String hostname, boolean isIpPreconfigured)
实际运行 Acloud 以关闭虚拟设备。 |
void
|
cleanUp()
|
static
File
|
getBugreportzWithSsh(GceAvdInfo gceAvd, TestDeviceOptions options, IRunUtil runUtil)
使用 ssh 从设备获取 bugreportz,以避免任何 adb 连接潜在问题。 |
HostOrchestratorUtil
|
getHostOrchestratorUtil()
返回 |
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
|
logAndDeleteFile(File tempFile, String dataName, ITestLogger logger)
|
static
void
|
logDirectory(File remoteDirectory, String baseName, ITestLogger logger, LogDataType type)
|
static
boolean
|
logNestedRemoteFile(ITestLogger logger, GceAvdInfo gceAvd, TestDeviceOptions options, IRunUtil runUtil, String remoteFilePath, LogDataType type)
从嵌套实例中提取远程文件并将其记录到日志中。 |
static
boolean
|
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(String ipDevice, String user, Integer offset, MultiMap<String, String> attributes, ITestLogger logger)
尝试使用 Acloud 或 Oxygen 启动 gce 实例。 |
GceAvdInfo
|
startGce()
|
GceAvdInfo
|
startGce(String ipDevice, MultiMap<String, String> attributes)
尝试启动 gce 实例。 |
GceAvdInfo
|
startGce(String ipDevice, String user, Integer offset, MultiMap<String, String> attributes)
尝试使用 Acloud 或 Oxygen 启动 gce 实例。 |
|
startMultiDevicesGce(
此方法已废弃。 更新主分支后移除此代码。 |
|
startMultiDevicesGce(
尝试使用 Oxygen 启动多设备 GCE 实例。 |
受保护的方法 | |
|---|---|
static
|
buildShutdownCommand(File config, TestDeviceOptions options, String instanceName, String hostname, boolean isIpPreconfigured)
|
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_IP_PRECONFIGURED_KEY
public static final String GCE_IP_PRECONFIGURED_KEY
公共构造函数
GceManager
public GceManager (DeviceDescriptor deviceDesc, TestDeviceOptions deviceOptions, IBuildInfo buildInfo)
Ctor
| 参数 | |
|---|---|
deviceDesc |
DeviceDescriptor:将与 GCE 设备关联的 DeviceDescriptor。 |
deviceOptions |
TestDeviceOptions:与设备关联的 TestDeviceOptions。 |
buildInfo |
IBuildInfo:用于描述要启动的 GCE build 的 IBuildInfo。 |
GceManager
public GceManager (DeviceDescriptor deviceDesc, TestDeviceOptions deviceOptions, IBuildInfo buildInfo,testResourceBuildInfos)
此构造函数已废弃。
使用其他构造函数,我们暂时保留此方法以实现向后兼容性。
| 参数 | |
|---|---|
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, boolean isIpPreconfigured)
实际运行 Acloud 以关闭虚拟设备。
| 参数 | |
|---|---|
options |
TestDeviceOptions:Acloud 选项的 TestDeviceOptions |
runUtil |
IRunUtil:用于运行 Acloud 的 IRunUtil |
instanceName |
String:要关闭的实例。 |
hostname |
String:实例的主机名,仅适用于 Oxygen cuttlefish。 |
isIpPreconfigured |
boolean:AVD 是在预配置 IP 的远程设备上创建的 |
| 返回 | |
|---|---|
boolean |
如果成功,则为 true |
cleanUp
public void cleanUp ()
getBugreportzWithSsh
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 bugreport 的文件,如果发生问题,则为 null。 |
| 抛出 | |
|---|---|
|
IOException |
getHostOrchestratorUtil
public HostOrchestratorUtil getHostOrchestratorUtil ()
返回 HostOrchestratorUtil 的实例。
| 返回 | |
|---|---|
HostOrchestratorUtil |
|
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 bugreport 的文件,如果发生问题,则为 null。 |
| 抛出 | |
|---|---|
|
IOException |
logAndDeleteFile
public static void logAndDeleteFile (File tempFile,
String dataName,
ITestLogger logger)| 参数 | |
|---|---|
tempFile |
File |
dataName |
String |
logger |
ITestLogger |
logDirectory
public static void logDirectory (File remoteDirectory,
String baseName,
ITestLogger logger,
LogDataType type)| 参数 | |
|---|---|
remoteDirectory |
File |
baseName |
String |
logger |
ITestLogger |
type |
LogDataType |
logNestedRemoteFile
public static boolean 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。 |
| 返回 | |
|---|---|
boolean |
文件是否已成功记录。 |
logNestedRemoteFile
public static boolean 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,则系统会使用实际文件名。 |
| 返回 | |
|---|---|
boolean |
文件是否已成功记录。 |
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。 |
shutdownGce
public boolean shutdownGce ()
关闭与 startGce() 关联的 Gce 实例。
| 返回 | |
|---|---|
boolean |
如果请求以非阻塞方式关闭 GCE,则返回 true。 |
startGce
public GceAvdInfo startGce (String ipDevice, String user, Integer offset, MultiMap<String, String> attributes, ITestLogger logger)
尝试使用 Acloud 或 Oxygen 启动 gce 实例。
| 参数 | |
|---|---|
ipDevice |
String:用于运行 AVD 的 GCE 实例的初始 IP,null(如果不适用) |
user |
String:AVD 的主机运行用户,如果不适用,则为 null |
offset |
Integer:主机中 AVD 的设备编号偏移量,null(如果不适用) |
attributes |
MultiMap:与当前调用关联的属性,用于将适用信息向下传递到 GCE 实例以添加为虚拟机元数据 |
logger |
ITestLogger:用于记录设备启动日志的 ITestLogger。 |
| 返回 | |
|---|---|
GceAvdInfo |
用于描述 GCE 实例的 GceAvdInfo。可以是 BOOT_FAIL 实例。 |
| 抛出 | |
|---|---|
|
com.android.tradefed.targetprep.TargetSetupError |
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 实例。 |
| 抛出 | |
|---|---|
|
com.android.tradefed.targetprep.TargetSetupError |
TargetSetupError |
|
startGce
public GceAvdInfo startGce (String ipDevice, String user, Integer offset, MultiMap<String, String> attributes)
尝试使用 Acloud 或 Oxygen 启动 gce 实例。
| 参数 | |
|---|---|
ipDevice |
String:用于运行 AVD 的 GCE 实例的初始 IP,null(如果不适用) |
user |
String:AVD 的主机运行用户,如果不适用,则为 null |
offset |
Integer:主机中 AVD 的设备编号偏移量,null(如果不适用) |
attributes |
MultiMap:与当前调用关联的属性,用于将适用信息向下传递到 GCE 实例以添加为虚拟机元数据 |
| 返回 | |
|---|---|
GceAvdInfo |
用于描述 GCE 实例的 GceAvdInfo。可以是 BOOT_FAIL 实例。 |
| 抛出 | |
|---|---|
|
com.android.tradefed.targetprep.TargetSetupError |
TargetSetupError |
|
startMultiDevicesGce
publicstartMultiDevicesGce ( buildInfos)
此方法已废弃。
更新主分支后移除此内容。
| 参数 | |
|---|---|
buildInfos |
|
| 返回 | |
|---|---|
|
|
| 抛出 | |
|---|---|
TargetSetupError |
|
startMultiDevicesGce
publicstartMultiDevicesGce ( buildInfos, MultiMap<String, String> attributes)
尝试使用 Oxygen 启动多设备 GCE 实例。
| 参数 | |
|---|---|
buildInfos |
:ERROR(/List |
attributes |
MultiMap:与当前调用相关联的属性 |
| 返回 | |
|---|---|
|
用于描述 GCE Avd Info 的 ERROR(/List。 |
| 抛出 | |
|---|---|
TargetSetupError |
|
受保护的方法
buildShutdownCommand
protected staticbuildShutdownCommand (File config, TestDeviceOptions options, String instanceName, String hostname, boolean isIpPreconfigured)
| 参数 | |
|---|---|
config |
File |
options |
TestDeviceOptions |
instanceName |
String |
hostname |
String |
isIpPreconfigured |
boolean |
| 返回 | |
|---|---|
|
|
extractInstanceName
protected String extractInstanceName (String bootupLogs)
从 gce 启动日志中检索实例名称。搜索“name”:“gce-
| 参数 | |
|---|---|
bootupLogs |
String |
| 返回 | |
|---|---|
String |
|