Firebase Test Lab からデベロッパー デバイス プラットフォームへのコマンドとフラグの変換

デベロッパー デバイス プラットフォーム(DDP)は、従来の Firebase Test Lab コンソールと Test Lab CLI ワークフローを、統合された高性能で安全なGoogle Cloudファースト テスト CLI(gcloud beta device-run)に置き換えます。

このガイドでは、Test Lab(または Flank)から DDP へのコマンドラインの変換とフラグのマッピングについて説明します。このガイダンスに沿って、テストを手動で移行します。自動化ツール、メリット、主な違い、移行のヒントについては、Firebase Test Lab から Developer Device Platform への移行をご覧ください。

シャーディングの移行

DDP は、Flank の複雑な Cloud Storage ベースのスマート シャーディングと Test Lab の均一なシャーディングの両方をネイティブに置き換えることで、シャーディング構成を最新化します。

均一シャーディング

  • --sharding-option=uniform を設定します。
  • --uniform-sharding-count={count} を設定します(物理の場合は 1 ~ 20、仮想の場合は 1 ~ 200)。

  • 以前の Firebase Test Lab: --num-uniform-shards {N}

  • DDP CLI: --sharding-option=uniform --uniform-sharding-count={N}

スマート シャーディング

  • --sharding-option=smart を設定します。
  • --smart-sharding-target-duration={duration} を設定します(例: 2m、10m、1h。有効範囲: 2m~1h)。
  • --smart-sharding-record-name={record_name} を設定します(automation/smart-sharding/ の --bucket-name 内の YAML トラッキング レコードを指します)。
  • --smart-sharding-max-shard-count={max_count} を設定します(上限は省略可。物理デバイスの場合は 0 ~ 20、仮想デバイスの場合は 0 ~ 200)。

過去 30 日間のタイミング メタデータを使用する場合:

  • レガシー フランク:

    max-test-shards: 10
    shard-time: 120
    smart-flank-gcs-path: gs://my-bucket/smart-sharding/timing-record.yaml
    
  • DDP CLI:

    --sharding-option=smart \
    --smart-sharding-max-shard-count=10 \
    --smart-sharding-target-duration=2m \
    --smart-sharding-record-name=timing-record \
    --bucket-name=my-bucket
    

宣言型 YAML 構成(--flags-file)

複雑な構成や、長いターミナル コマンドではなくバージョン管理されたファイルの維持を好むチームの場合、gcloud は汎用の --flags-file 引数プリプロセッサを提供します($ gcloud topic flags-file を参照)。

gcloud beta device-run sessions submit instrumentation --flags-file=device-run-flags.yaml

次に、複数値のリストとディクショナリのフラグを示す例を示します。

# device-run-flags.yaml
--device:
  -   mediumphone-arm-32
  -   shiba-36
--apps:
  -   app-debug.apk
  -   test-helper.apk
--test: app-debug-androidTest.apk
--bucket-name: my-bucket
--sharding-option: smart
--smart-sharding-target-duration: 2m
--smart-sharding-record-name: timing-record
--paths-to-pull:
  -   /sdcard/screenshots
  -   /sdcard/coverage.ec
--additional-test-options:
  coverage: "true"
  clearPackageData: "true"

エンドツーエンドのコマンド変換の例

具体的な例については、標準的な翻訳と複雑な翻訳をご覧ください。

例: 標準のインストルメンテーション テストを実行する

以前の Firebase CLI:

gcloud firebase test android run \
  --app=app-debug.apk \
  --test=app-debug-androidTest.apk \
  --device model=shiba,version=36 \
  --timeout=5m \
  --num-flaky-test-attempts=2 \
  --directories-to-pull=/sdcard/screenshots \
  --environment-variables key=value

DDP CLI の変換:

gcloud beta device-run sessions submit instrumentation \
  --device=shiba-36 \
  --apps=app-debug.apk \
  --test=app-debug-androidTest.apk \
  --instrumentation-timeout=5m \
  --flaky-test-attempts=3 \
  --paths-to-pull=/sdcard/screenshots \
  --additional-test-options key=value

例: 複雑な flank YAML 構成を移行する

以前の Flank 構成:

app: app-debug.apk
test: app-debug-androidTest.apk
device:
  -   model: shiba
    version: 36
shard-time: 120
smart-flank-gcs-path: gs://my-bucket/smart-sharding/timing-record.yaml

DDP CLI の変換:

gcloud beta device-run sessions submit instrumentation \
  --device=shiba-36 \
  --apps=app-debug.apk \
  --test=app-debug-androidTest.apk \
  --bucket-name=my-bucket \
  --sharding-option=smart \
  --smart-sharding-target-duration=2m \
  --smart-sharding-record-name=timing-record

実行後と結果の取得

DDP はグラフィカルなウェブ UI(以前の Firebase コンソールなど)で起動しないため、デベロッパーは CLI またはプログラムによる REST API を使用して、結果を直接管理、記述、検査する必要があります。

# 1. List active and completed test sessions
gcloud beta device-run sessions list

# 2. Get a summary and direct Cloud Storage bucket link of a session's results
gcloud beta device-run sessions describe session-number

# 3. Get detailed metadata and print full results
gcloud beta device-run sessions describe session-number --full

# 4. Cancel a running session (replaces console cancellation)
gcloud beta device-run sessions cancel session-number

フラグ マッピング リファレンス

Flank または gcloud firebase test android/ios run から新しい DDP gcloud beta device-run sessions submit instrumentation コマンドにテスト構成を移行するためのフラグ マッピングは次のとおりです。

コアパラメータとアセット

以前のパラメータ(Test Lab / Flank) ターゲット DDP パラメータ 形式 / 変換ロジック
--app --apps List。複数のアプリケーション APK/AAB が提供されている場合は、デバイスにインストールする順序でそれらすべてを --apps に渡します。パスはローカルまたは Cloud Storage(gs://...)に指定できます。
--test --test 必須の文字列。インストルメンテーション テストを含むテスト APK のパス(ローカルまたは Cloud Storage)。
--client-details --labels テスト セッションに付加する key=value ペアのディクショナリ。

デバイス設定とターゲティング

以前のパラメータ(Test Lab / Flank) ターゲット DDP パラメータ 形式 / 変換ロジック
--device model={M},version={V} --device={M}-{V} モデルと OS バージョンを単一の --device ID 文字列にマッピングする必須の文字列。DDP の --device フラグは、カンマ区切りの複数のデバイス ID を受け入れます(例: --device=shiba-34,tokay-36)または複数の --device フラグ。それぞれが異なるデバイス ID を指定します(例: --device=shiba-34 --device=tokay-36)。
--device locale={L} --locale={L} 文字列。マップのデバイス ロケールを最上位の --locale フラグ(language-region、例: --locale=en-US)を使用して、テストを実行する前にデバイスを切り替えます。
--device orientation={O} --orientation={O} 文字列。デバイスの画面の向きを最上位の --orientation フラグ(portrait または landscape)にマッピングします。
なし --coordinates 文字列。デバイスの GPS 位置座標をモックします(例: --coordinates=37.4220,-122.0841)。

実行制御と不安定さ

以前のパラメータ(Test Lab / Flank) ターゲット DDP パラメータ 形式 / 変換ロジック
--num-flaky-test-attempts {R} --flaky-test-attempts {A} 整数。テスト シャードあたりの最大実行試行回数。再試行回数 R を合計試行回数 A の上限に変換します。A = R + 1(デフォルトは 1)。
なし --flaky-test-parallel-retry Boolean。テストの失敗を並行して再試行するかどうか(デフォルトは順次実行の false)。
なし --flaky-test-retry-level 文字列。shard レベルで再試行するか、個々の test レベルで再試行するかを定義します(デフォルトは shard)。
--async --async Boolean。1 対 1 でマッピングします。コマンドはデフォルトで同期的に実行されます。これを渡して、すぐにターミナルに戻ります。ファイルのアップロード直後に終了し、オペレーション ID とセッション ID を出力します。

テストランナーとターゲット

以前のパラメータ(Test Lab / Flank) ターゲット DDP パラメータ 形式 / 変換ロジック
--environment-variables --additional-test-options インストルメンテーション テスト ランナーに渡されるオプションのディクショナリ。--test-targets でサポートされている形式は、ここでは使用できません。
--test-targets --test-targets 実行するテスト ターゲットまたはターゲット フィルタのディクショナリ。各ターゲットは、package、notPackage、class、notClass、annotation、notAnnotation、size などのキーをサポートするパッケージ名またはクラス名で完全修飾されている必要があります。形式 testfile または notTestfile はサポートされていません。
--use-orchestrator --orchestrator-version Android Test Orchestrator を使用するかどうか。auto(デフォルトのオーケストレーター)または特定のバージョン文字列(例: 1.6)。利用可能なバージョンは gcloud beta device-run software-versions list を使用してクエリできます。
--test-runner-class --test-runner-class 文字列。完全修飾のインストルメンテーション テストランナー クラス(例: com.foo.MyRunner)を使用します。指定しない場合、デフォルトのランナー クラスはアプリケーションのマニフェストを調べることによって決定されます。
--directories-to-pull --paths-to-pull List。テスト実行後にデバイスからダウンロードするディレクトリ。
--other-files --other-files-to-push Dictionary にあります)を使用する、フレーズの改行区切りリストで構成されます。テスト実行前にデバイスに push する補助ファイルの SOURCE=DEST リスト(カンマ区切り)。

出力とストレージ

以前のパラメータ(Test Lab / Flank) ターゲット DDP パラメータ 形式 / 変換ロジック
--results-bucket --bucket-name 文字列。ローカル入力ファイル、テスト出力ファイル、スマート シャーディング タイミング レコードなどのテスト アーティファクトがアップロードされる Cloud Storage バケット(指定されていない場合はデフォルトで gs://[PROJECT_ID]-devicerun)。
--results-dir 自動的に管理される サポート対象外。サブパスは、Cloud Storage の automation/sessions/{session_id}/ の下に自動的に整理されます。

シャーディング構成

以前のパラメータ(Test Lab / Flank) ターゲット DDP パラメータ 形式 / 変換ロジック
--num-uniform-shards {N} --sharding-option=uniform --uniform-sharding-count={N} String と Integer。結合フラグ構成は、均一シャーディング戦略を有効にし、最大シャード数を設定します(有効な数の範囲: 物理 1 ~ 20、仮想 1 ~ 200)。
側面 --max-test-shards {N} --sharding-option=smart --smart-sharding-max-shard-count={N} String と Integer。結合フラグ構成では、スマート シャーディング戦略が有効になり、最大シャード数が設定されます(有効なカウント範囲: 物理 0 ~ 20、仮想 0 ~ 200)。
側面 --shard-time {S} --sharding-option=smart --smart-sharding-target-duration={S} 必須の文字列。目標実行時間でスマート シャーディングを有効にします(例: 2m、10m、1h)。有効な範囲: 2m~1h。
側面 --smart-flank-gcs-path --smart-sharding-record-name={name} --bucket-name={bucket} 必須の文字列。Cloud Storage の smart-sharding/ の --bucket-name 内にあるシャーディング レコード YAML の名前(ファイル拡張子を除く)。

Android 固有のフラグ

次の表を使用して、以前の gcloud firebase test android run フラグを新しい device-run の同等のフラグにマッピングします。

以前のパラメータ(firebase android) ターゲット DDP パラメータ 形式 / 変換ロジック
--additional-apks --apps List。追加のリスト値をメインの --apps リストに直接統合します。
なし --bugreport 文字列。デバイスから完全な bugreport を収集します(値: always、on-failure)。
なし --dumpsys 文字列。dumpsys(値: always、on-failure)を使用してシステム状態を収集します。
--timeout --instrumentation-timeout 期間(例: 10m、20s、1h)。有効な範囲: 1m~3h(デフォルトは 5m)。
--record-video --video 文字列。テスト実行中にデバイス画面の動画を記録するタイミング。有効な値は always または on-failure です。

iOS 固有のフラグ

次の表を使用して、以前の gcloud firebase test ios run フラグを新しい device-run の同等のフラグにマッピングします。

以前のパラメータ(firebase ios) ターゲット DDP パラメータ 形式 / 変換ロジック
--test --test ビルドされた XCTest zip へのパス。
--device model={M},version={V} --device={M}-{V} 対象デバイス ID 文字列。
--timeout --xctest-timeout 再生時間(例: 5m)。範囲: 1m~1h。
--xcode-version --xcode-version 使用する Xcode のカタログ ID またはバージョン文字列(例: xcode-16-4 または 16.4)。利用可能なバージョンは gcloud beta device-run software-versions list を使用してクエリできます。
--results-bucket --bucket-name カスタムの宛先 GCS バケット。
--async --async デフォルトでは同期。すぐに終了するには渡します。
--other-files --other-files-to-push SOURCE=BUNDLE_ID:DEST 形式のディクショナリ。
--directories-to-pull --paths-to-pull BUNDLE_ID:DEVICE_PATH 形式のリスト。
--additional-ipas --additional-apps テストの前にインストールするヘルパー IPA のリスト。
--xctestrun-file --xctestrun-file カスタム .xctestrun plist へのパス。
--num-flaky-test-attempts --flaky-test-attempts 再試行回数の整数(例: 3)。
--client-details --labels Key-Value ペア(KEY=VALUE)。

フィードバックと質問

バグや機能リクエストを送信したり、ディスカッション フォーラムに参加したりするには、こちらからお問い合わせください。