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 |