GceManager
public class GceManager
extends Object
java.lang.Object | |
↳ | com.android.tradefed.device.cloud.GceManager |
管理GCE的幫助程序調用以啟動/停止並從GCE收集日誌。
概要
領域 | |
---|---|
public static final String | GCE_INSTANCE_CLEANED_KEY |
public static final String | GCE_INSTANCE_NAME_KEY
|
公共建設者 | |
---|---|
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) 實際運行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 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) 記錄 |
void | logStableHostImageInfos (IBuildInfo build) 記錄與使用的穩定主機映像有關的信息。 |
static CommandResult | remoteSshCommandExecution (GceAvdInfo gceAvd, TestDeviceOptions options, IRunUtil runUtil, long timeoutMs, String... command) 通過ssh在實例上執行遠程命令。 |
boolean | shutdownGce () 關閉與 |
GceAvdInfo | startGce () |
GceAvdInfo | startGce (String ipDevice) 嘗試啟動GCE實例 |
受保護的方法 | |
---|---|
buildGceCmd (File reportFile, IBuildInfo b, String ipDevice) 生成並返回命令以啟動GCE。 | |
String | extractInstanceName (String bootupLogs) 從gce啟動日誌中檢索實例名稱。 |
領域
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)
Ctor
參量 | |
---|---|
deviceDesc | DeviceDescriptor :將與GCE設備關聯的DeviceDescriptor 。 |
deviceOptions | TestDeviceOptions :與設備關聯的TestDeviceOptions 。 |
buildInfo | IBuildInfo : IBuildInfo 描述要開始的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 : IBuildInfo 描述要開始的IBuildInfo 構建。 |
gceInstanceName | String :要使用的實例名稱。 |
gceHost | String :要使用的實例的主機名或IP。 |
公開方法
Acloud關機
public static boolean AcloudShutdown (TestDeviceOptions options, IRunUtil runUtil, String instanceName)
實際運行Acloud以關閉虛擬設備。
參量 | |
---|---|
options | TestDeviceOptions :該TestDeviceOptions 為Acloud選項 |
runUtil | IRunUtil :本IRunUtil 運行Acloud |
instanceName | String :要關閉的實例。 |
退貨 | |
---|---|
boolean | 成功則為真 |
清理
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錯誤報告的文件;如果出現問題,則為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。
參量 | |
---|---|
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 在哪裡記錄串行日誌。 |
logStableHostImageInfos
記錄與使用的穩定主機映像有關的信息。
參量 | |
---|---|
build | IBuildInfo |
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 包含執行結果。 |
startGce
public GceAvdInfo startGce (String ipDevice)
嘗試啟動GCE實例
參量 | |
---|---|
ipDevice | String |
退貨 | |
---|---|
GceAvdInfo | 描述GCE實例的GceAvdInfo 。可能是BOOT_FAIL實例。 |
投擲 | |
---|---|
TargetSetupError |
受保護的方法
buildGceCmd
protectedbuildGceCmd (File reportFile, IBuildInfo b, String ipDevice)
生成並返回命令以啟動GCE。暴露於測試。
參量 | |
---|---|
reportFile | File |
b | IBuildInfo |
ipDevice | String |
退貨 | |
---|---|
extractInstanceName
從gce啟動日誌中檢索實例名稱。搜索“名稱”:“ gce-
參量 | |
---|---|
bootupLogs | String |
退貨 | |
---|---|
String |