GceManager
public class GceManager
extends Object
java.lang.Object |
↳ | com.android.tradefed.device.cloud.GceManager |
管理 GCE 調用以啟動/停止並從 GCE 收集日誌的助手。
概括
公共構造函數 |
---|
GceManager ( DeviceDescriptor deviceDesc, TestDeviceOptions deviceOptions, IBuildInfo buildInfo) Ctor |
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, boolean isIpPreconfigured) 實際 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 獲取嵌套實例的錯誤報告。 |
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) 記錄GceAvdInfo 描述的設備的串行輸出。 |
static CommandResult | remoteSshCommandExecution ( GceAvdInfo gceAvd, TestDeviceOptions options, IRunUtil runUtil, long timeoutMs, String... command) 在實例上通過 ssh 執行遠程命令。 |
boolean | shutdownGce () 關閉與startGce() 關聯的 Gce 實例。 |
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 ( buildInfos) startMultiDevicesGce ( buildInfos) 此方法已棄用。更新 master 分支後刪除它。 |
| startMultiDevicesGce ( buildInfos, MultiMap <String, String> attributes) startMultiDevicesGce ( buildInfos, MultiMap <String, String> attributes) 嘗試使用 Oxygen 啟動多設備 gce 實例。 |
受保護的方法 |
---|
| buildGceCmd (File reportFile, IBuildInfo b, String ipDevice, String user, Integer offset, MultiMap <String, String> attributes) 構建並返回啟動 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
public static final String GCE_IP_PRECONFIGURED_KEY
公共構造函數
GceManager
public GceManager (DeviceDescriptor deviceDesc,
TestDeviceOptions deviceOptions,
IBuildInfo buildInfo,
testResourceBuildInfos)
此構造函數已棄用。
使用其他構造函數,我們暫時保留它是為了向後兼容。
參數 |
---|
deviceDesc | DeviceDescriptor |
deviceOptions | TestDeviceOptions |
buildInfo | IBuildInfo |
testResourceBuildInfos | |
公共方法
Acloud關機
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 的遠程設備上創建的 |
清理
public void cleanUp ()
getBugreportzWithSsh
public static File getBugreportzWithSsh (GceAvdInfo gceAvd,
TestDeviceOptions options,
IRunUtil runUtil)
使用 ssh 從設備獲取 bugreportz 以避免任何 adb 連接潛在問題。
退貨 |
---|
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 獲取嵌套實例的錯誤報告。這需要在嵌套的虛擬實例中請求 adb。
退貨 |
---|
File | 指向 zip 錯誤報告的文件,如果出現問題則為 null。 |
關閉Gce
public boolean shutdownGce ()
關閉與startGce()
關聯的 Gce 實例。
退貨 |
---|
boolean | 如果 gce shutdown 被請求為非阻塞,則返回 true。 |
開始
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 實例以作為 VM 元數據添加 |
logger | ITestLogger :用於記錄設備啟動日誌的ITestLogger 。 |
開始
public GceAvdInfo startGce (String ipDevice,
MultiMap<String, String> attributes)
嘗試啟動 gce 實例。
參數 |
---|
ipDevice | String : 運行 AVD 的 GCE 實例的初始 IP,如果不適用則為null |
attributes | MultiMap :與當前調用關聯的屬性,用於將適用信息向下傳遞到 GCE 實例以作為 VM 元數據添加 |
開始
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 實例以作為 VM 元數據添加 |
啟動MultiDevicesGce
public startMultiDevicesGce ( buildInfos)
此方法已棄用。
更新 master 分支後刪除它。
啟動MultiDevicesGce
public startMultiDevicesGce ( buildInfos,
MultiMap<String, String> attributes)
嘗試使用 Oxygen 啟動多設備 gce 實例。
受保護的方法
構建GceCmd
protected buildGceCmd (File reportFile,
IBuildInfo b,
String ipDevice,
String user,
Integer offset,
MultiMap<String, String> attributes)
構建並返回啟動 GCE 的命令。暴露測試。
參數 |
---|
reportFile | File |
b | IBuildInfo |
ipDevice | String |
user | String |
offset | Integer |
attributes | MultiMap |
建立關機命令
protected static buildShutdownCommand (File config,
TestDeviceOptions options,
String instanceName,
String hostname,
boolean isIpPreconfigured)
參數 |
---|
config | File |
options | TestDeviceOptions |
instanceName | String |
hostname | String |
isIpPreconfigured | boolean |
protected String extractInstanceName (String bootupLogs)
從 gce 引導日誌中檢索實例名稱。搜索“名稱”:“gce- ' 模式來提取它的名稱。我們從日誌而不是結果文件中提取,因為在 gce 啟動失敗時,嘗試的實例名稱不會顯示在 json 中。