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

public static final String GCE_IP_PRECONFIGURED_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, boolean isIpPreconfigured)

實際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 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

GCE_IP_PRECONFIGURED_KEY

public static final String GCE_IP_PRECONFIGURED_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, 
                boolean isIpPreconfigured)

實際Acloud運行以關閉虛擬設備。

參數
options TestDeviceOptions :Acloud 選項的TestDeviceOptions

runUtil IRunUtil : 執行 Acloud 的IRunUtil

instanceName String :要關閉的實例。

hostname String : 實例的主機名,僅用於 Oxygen cuttlefish。

isIpPreconfigured boolean : AVD 是否是在具有預先配置 IP 的遠端設備上建立的

退貨
boolean如果成功則為真

清理

public void cleanUp ()

getBugreportzWithSsh

public static File getBugreportzWithSsh (GceAvdInfo gceAvd, 
                TestDeviceOptions options, 
                IRunUtil runUtil)

使用 ssh 從裝置取得錯誤報告,以避免任何 adb 連線潛在問題。

參數
gceAvd GceAvdInfo :描述裝置的GceAvdInfo

options TestDeviceOptionsTestDeviceOptions描述用於 GCE 裝置的裝置選項。

runUtil IRunUtil :執行指令的IRunUtil

退貨
File指向 zip 錯誤報告的文件,如果發生問題則為 null。

投擲
IO異常

取得實例序列日誌

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 TestDeviceOptionsTestDeviceOptions描述用於 GCE 裝置的裝置選項。

runUtil IRunUtil :執行指令的IRunUtil

退貨
File指向 zip 錯誤報告的文件,如果發生問題則為 null。

投擲
IO異常

日誌嵌套遠端文件

public static boolean logNestedRemoteFile (ITestLogger logger, 
                GceAvdInfo gceAvd, 
                TestDeviceOptions options, 
                IRunUtil runUtil, 
                String remoteFilePath, 
                LogDataType type)

從嵌套實例中獲取遠端檔案並記錄它。

參數
logger ITestLoggerITestLogger記錄檔案的位置。

gceAvd GceAvdInfo :描述裝置的GceAvdInfo

options TestDeviceOptionsTestDeviceOptions描述用於 GCE 裝置的裝置選項。

runUtil IRunUtil :執行指令的IRunUtil

remoteFilePath String :尋找檔案的遠端路徑。

type LogDataType :記錄檔案的LogDataType

退貨
boolean文件是否記錄成功。

日誌嵌套遠端文件

public static boolean logNestedRemoteFile (ITestLogger logger, 
                GceAvdInfo gceAvd, 
                TestDeviceOptions options, 
                IRunUtil runUtil, 
                String remoteFilePath, 
                LogDataType type, 
                String baseName)

從嵌套實例中獲取遠端檔案並記錄它。

參數
logger ITestLoggerITestLogger記錄檔案的位置。

gceAvd GceAvdInfo :描述裝置的GceAvdInfo

options TestDeviceOptionsTestDeviceOptions描述用於 GCE 裝置的裝置選項。

runUtil IRunUtil :執行指令的IRunUtil

remoteFilePath String :尋找檔案的遠端路徑。

type LogDataType :記錄檔案的LogDataType

baseName String :用於記錄文件的基本名稱。如果為 null,則將使用實際檔案名稱。

退貨
boolean文件是否記錄成功。

日誌串行輸出

public void logSerialOutput (GceAvdInfo infos, 
                ITestLogger logger)

記錄GceAvdInfo所描述的設備的串列輸出。

參數
infos GceAvdInfo :描述實例的GceAvdInfo

logger ITestLoggerITestLogger記錄串列日誌的位置。

遠端Ssh命令執行

public static CommandResult remoteSshCommandExecution (GceAvdInfo gceAvd, 
                TestDeviceOptions options, 
                IRunUtil runUtil, 
                long timeoutMs, 
                String... command)

透過 ssh 在實例上執行遠端命令。

參數
gceAvd GceAvdInfo :描述裝置的GceAvdInfo

options TestDeviceOptionsTestDeviceOptions描述用於 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, 
                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 ITestLoggerITestLogger記錄設備啟動日誌的位置。

退貨
GceAvdInfo描述 GCE 實例的GceAvdInfo 。可能是 BOOT_FAIL 實例。

投擲
com.android.tradefed.targetprep.TargetSetupError
TargetSetupError

啟動Gce

public GceAvdInfo startGce ()

退貨
GceAvdInfo

投擲
TargetSetupError

啟動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 實例。

投擲
com.android.tradefed.targetprep.TargetSetupError
TargetSetupError

啟動Gce

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 元資料添加

退貨
GceAvdInfo描述 GCE 實例的GceAvdInfo 。可能是 BOOT_FAIL 實例。

投擲
com.android.tradefed.targetprep.TargetSetupError
TargetSetupError

啟動多設備Gce

public  startMultiDevicesGce ( buildInfos)

此方法已被棄用。
master 分支更新後刪除它。

參數
buildInfos

退貨

投擲
TargetSetupError

啟動多設備Gce

public  startMultiDevicesGce ( buildInfos, 
                MultiMap<String, String> attributes)

嘗試使用 Oxygen 啟動多裝置 gce 執行個體。

參數
buildInfos : ERROR(/List ) ERROR(/List )

attributes MultiMap :與目前呼叫關聯的屬性

退貨
ERROR(/List ) ERROR(/List )描述 GCE Avd 資訊。

投擲
TargetSetupError

受保護的方法

建置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 中。

參數
bootupLogs String

退貨
String