GceManager

public class GceManager
extends Object

java.lang.Object
   ↳ com.android.tradefed.device.cloud.GceManager


GCE の呼び出しを管理して、GCE のログの開始、停止、収集を行うヘルパー。

概要

定数

String GCE_HOSTNAME_KEY

String GCE_INSTANCE_CLEANED_KEY

String GCE_INSTANCE_NAME_KEY

String GCE_IP_PRECONFIGURED_KEY

パブリック コンストラクタ

GceManager(DeviceDescriptor deviceDesc, TestDeviceOptions deviceOptions, IBuildInfo buildInfo)

Ctor

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

このコンストラクタは非推奨になりました。 他のコンストラクタを使用してください。下位互換性のために一時的に残しています。

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

使用する 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)

adb 接続の潜在的な問題を回避するため、ssh を使用してデバイスから bugreportz を取得します。

HostOrchestratorUtil getHostOrchestratorUtil()

HostOrchestratorUtil のインスタンスを返します。

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 logAndDeleteFile(File tempFile, String dataName, ITestLogger logger)
static void logDirectory(File remoteDirectory, String baseName, ITestLogger logger, LogDataType type)
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, MultiMap<String, String> attributes)

Oxygen でマルチデバイスの 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-hostname"

GCE_INSTANCE_CLEANED_KEY

public static final String GCE_INSTANCE_CLEANED_KEY

定数値: "gce-instance-clean-called"

GCE_INSTANCE_NAME_KEY

public static final String GCE_INSTANCE_NAME_KEY

定数値: "gce-instance-name"

GCE_IP_PRECONFIGURED_KEY

public static final String GCE_IP_PRECONFIGURED_KEY

定数値: "gce-ip-pre-configured"

パブリック コンストラクタ

GceManager

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

Ctor

パラメータ
deviceDesc DeviceDescriptor: GCE デバイスに関連付けられる DeviceDescriptor

deviceOptions TestDeviceOptions: デバイスに関連付けられた TestDeviceOptions

buildInfo IBuildInfo: 開始する gce ビルドを記述する 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)

直接使用する 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, 
                boolean isIpPreconfigured)

仮想デバイスをシャットダウンするための実際の Acloud 実行。

パラメータ
options TestDeviceOptions: Acloud オプションの TestDeviceOptions

runUtil IRunUtil: Acloud を実行する IRunUtil

instanceName String: シャットダウンするインスタンス。

hostname String: インスタンスのホスト名。Oxygen のカトルフィッシュでのみ使用されます。

isIpPreconfigured boolean: 事前構成された IP を使用してリモート デバイスで AVD が作成されたかどうか

戻り値
boolean 成功した場合は true

cleanUp

public void cleanUp ()

getBugreportzWithSsh

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

adb 接続に関する潜在的な問題を回避するため、ssh を使用してデバイスから bugreportz を取得します。

パラメータ
gceAvd GceAvdInfo: デバイスを説明する GceAvdInfo

options TestDeviceOptions: GCE デバイスに使用するデバイス オプションを記述する TestDeviceOptions

runUtil IRunUtil: コマンドを実行する IRunUtil

戻り値
File ZIP バグレポートを指すファイル。問題が発生した場合は null。

例外
IOException

getHostOrchestratorUtil

public HostOrchestratorUtil getHostOrchestratorUtil ()

HostOrchestratorUtil のインスタンスを返します。

戻り値
HostOrchestratorUtil

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: GCE デバイスに使用するデバイス オプションを記述する TestDeviceOptions

runUtil IRunUtil: コマンドを実行する IRunUtil

戻り値
File ZIP バグレポートを指すファイル。問題が発生した場合は null。

例外
IOException

logAndDeleteFile

public static void logAndDeleteFile (File tempFile, 
                String dataName, 
                ITestLogger logger)

パラメータ
tempFile File

dataName String

logger ITestLogger

logDirectory

public static void logDirectory (File remoteDirectory, 
                String baseName, 
                ITestLogger logger, 
                LogDataType type)

パラメータ
remoteDirectory File

baseName String

logger ITestLogger

type LogDataType

logNestedRemoteFile

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

ネストされたインスタンスからリモート ファイルを取得してログに記録します。

パラメータ
logger ITestLogger: ファイルをログに記録する ITestLogger

gceAvd GceAvdInfo: デバイスを説明する GceAvdInfo

options TestDeviceOptions: GCE デバイスに使用するデバイス オプションを記述する TestDeviceOptions

runUtil IRunUtil: コマンドを実行する IRunUtil

remoteFilePath String: ファイルの検索先となるリモートパス。

type LogDataType: ログに記録されたファイルの LogDataType

戻り値
boolean ファイルが正常に記録されたかどうか。

logNestedRemoteFile

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

ネストされたインスタンスからリモート ファイルを取得してログに記録します。

パラメータ
logger ITestLogger: ファイルをログに記録する ITestLogger

gceAvd GceAvdInfo: デバイスを説明する GceAvdInfo

options TestDeviceOptions: GCE デバイスに使用するデバイス オプションを記述する TestDeviceOptions

runUtil IRunUtil: コマンドを実行する IRunUtil

remoteFilePath String: ファイルの検索先となるリモートパス。

type LogDataType: ログに記録されたファイルの LogDataType

baseName String: ファイルのログ記録に使用するベース名。null の場合は、実際のファイル名が使用されます。

戻り値
boolean ファイルが正常に記録されたかどうか。

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: GCE デバイスに使用するデバイス オプションを記述する TestDeviceOptions

runUtil IRunUtil: コマンドを実行する IRunUtil

timeoutMs long: コマンドのタイムアウト(ミリ秒単位)。0 はタイムアウトなしを意味します。

command String: 実行するリモート コマンド。

戻り値
CommandResult 実行結果を含む CommandResult

shutdownGce

public boolean shutdownGce ()

startGce() に関連付けられた Gce インスタンスをシャットダウンします。

戻り値
boolean gce シャットダウンが非ブロッキングとしてリクエストされた場合は true を返します。

startGce

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

戻り値
GceAvdInfo GCE インスタンスを記述する GceAvdInfo。BOOT_FAIL インスタンスである可能性があります。

例外
com.android.tradefed.targetprep.TargetSetupError
TargetSetupError

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 インスタンスである可能性があります。

例外
com.android.tradefed.targetprep.TargetSetupError
TargetSetupError

startGce

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

startMultiDevicesGce

public  startMultiDevicesGce ( buildInfos)

このメソッドは非推奨です。
マスター ブランチが更新されたら、これを削除します。

パラメータ
buildInfos

戻り値

例外
TargetSetupError

startMultiDevicesGce

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

Oxygen でマルチデバイスの GCE インスタンスの起動を試みます。

パラメータ
buildInfos : ERROR(/List)

attributes MultiMap: 現在の呼び出しに関連付けられた属性

戻り値
GCE Avd Info を記述する ERROR(/List)

例外
TargetSetupError

保護されたメソッド

buildShutdownCommand

protected static  buildShutdownCommand (File config, 
                TestDeviceOptions options, 
                String instanceName, 
                String hostname, 
                boolean isIpPreconfigured)

パラメータ
config File

options TestDeviceOptions

instanceName String

hostname String

isIpPreconfigured boolean

戻り値

extractInstanceName

protected String extractInstanceName (String bootupLogs)

gce ブートログからインスタンス名を取得します。「name: gce-」パターンを検索して、名前を抽出します。gce の起動に失敗した場合、試行されたインスタンス名が JSON に表示されないため、結果ファイルではなくログから抽出します。

パラメータ
bootupLogs String

戻り値
String