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)

ctor

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

This constructor is deprecated. 請使用其他建構函式,我們會暫時保留這個函式以維持回溯相容性。

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

建構函式,可用來提供要直接使用的 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 取得巢狀執行個體的錯誤報告。

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 建構作業的 IBuildInfo

GceManager

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

This constructor is deprecated.
請使用其他建構函式,我們會暫時保留這個函式以維持回溯相容性。

參數
deviceDesc DeviceDescriptor

deviceOptions TestDeviceOptions

buildInfo IBuildInfo

testResourceBuildInfos

GceManager

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

建構函式,可用來提供要直接使用的 GCE 執行個體名稱。

參數
deviceDesc DeviceDescriptor:與 GCE 裝置相關聯的 DeviceDescriptor

deviceOptions TestDeviceOptions:與裝置相關聯的 TestDeviceOptions

buildInfo IBuildInfo:描述要啟動的 gce 建構作業的 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

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 錯誤報告的檔案,如果發生問題,則為空值。

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 序列記錄輸出內容,或發生錯誤時的空值。

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 錯誤報告的檔案,如果發生問題,則為空值。

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:用於記錄檔案的基本名稱。如果為空值,系統會使用實際的檔案名稱。

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 ()

傳回
GceAvdInfo

擲回
TargetSetupError

startGce

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

受保護的方法

buildGceCmd

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

建構並傳回用於啟動 GCE 的指令。已公開供測試。

參數
reportFile File

b IBuildInfo

ipDevice String

attributes MultiMap

傳回

extractInstanceName

protected String extractInstanceName (String bootupLogs)

從 gce 啟動記錄中擷取執行個體名稱。搜尋「名稱」:「gce-」模式,擷取名稱。我們從記錄中提取資料,而不是從結果檔案中提取,因為在 gce 啟動失敗時,嘗試的執行個體名稱不會顯示在 json 中。

參數
bootupLogs String

傳回
String