Firebase Test Lab と Flank から AI を搭載したデベロッパー デバイス プラットフォームに移行する

このスキルは、以前のテスト実行構成とワークフロー(Flank または gcloud firebase test から)を最新のリソース指向の gcloud beta device-run CLI サーフェス(および iOS XCTest セッションを送信するための gcloud alpha device-run)に変換する際に役立ちます。

コマンドとリソースの構造のマッピング

デバイスラン CLI は、コマンドをリソース(devices、software-versions、sessions)ごとに整理します。

1. デバイス カタログ(devices)

  • デバイスを一覧表示する:
    • レガシー: gcloud firebase test android/ios models list
    • 新規: gcloud beta device-run devices list [--filter="..."]
    • 例: gcloud beta device-run devices list --filter="platform:android"
  • デバイスの説明:
    • レガシー: gcloud firebase test android/ios models describe {MODEL}
    • 新規: gcloud beta device-run devices describe {DEVICE}
    • 例: gcloud beta device-run devices describe redfin-30
  • デバイスの容量とフリートの在庫状況を確認する:
    • レガシー: gcloud firebase test android/ios list-device-capacities
    • 新規: デバイス リソース(availability.capacity と availability.available)に直接埋め込まれます。gcloud beta device-run devices describe {DEVICE} を使用して検査するか、gcloud beta device-run devices list --filter="availability.capacity=CAPACITY_HIGH" を使用して直接フィルタします。

2. ソフトウェア バージョン(software-versions)

  • サポートされているソフトウェア バージョン(Xcode と Android Test Orchestrator)のリスト:
    • レガシー: gcloud firebase test ios xcode-versions list
    • 新規: gcloud beta device-run software-versions list
  • ソフトウェア バージョンを説明する:
    • 新規: gcloud beta device-run software-versions describe {SOFTWARE_VERSION}
    • 例: gcloud beta device-run software-versions describe xcode-16-4

3. 自動化セッション(sessions)

  • Android インストルメンテーションを送信する:
    • レガシー: gcloud firebase test android run --type=instrumentation ...
    • 新規: gcloud beta device-run sessions submit instrumentation ...
  • iOS XCTest を送信する:
    • レガシー: gcloud firebase test ios run --type=xctest ...
    • 新規: gcloud alpha device-run sessions submit xctest ...
  • セッションの完了を待つ:
    • レガシー: 同期 CLI ブロッキングのみ
    • 新規: gcloud beta device-run sessions wait {SESSION}
  • セッションの説明 / 検査:
    • レガシー: Firebase コンソール / Cloud Tool Results でウェブリンクを表示する
    • 新規: gcloud beta device-run sessions describe {SESSION} [--full]
  • 過去のセッションを一覧表示する:
    • 以前のバージョン: ウェブ コンソールでマトリックスの履歴を表示する
    • 新規: gcloud beta device-run sessions list
  • セッションのキャンセル:
    • レガシー: ウェブコンソールのみ(CLI コマンドなし)
    • 新規: gcloud beta device-run sessions cancel {SESSION}

フラグ マッピング参照表

次の表は、以前の Firebase Test Lab と Flank のパラメータと、gcloud beta device-run でサポートされている同等のパラメータのマッピングを示しています。

テストタイプ 特徴グループ 以前のパラメータ(firebase / Flank) ターゲット パラメータ(device-run) 形式 / 変換ロジック
共通(Android、iOS) コア パラメータとアセット 側面 --project --project 標準の Google Cloud グローバルフラグ(--project=PROJECT_ID)またはアクティブな Google Cloud CLI 構成。
共通(Android、iOS) コア パラメータとアセット --client-details --labels key=value ペアの辞書。
共通(Android、iOS) デバイスの設定とターゲティング --device model={M},version={V} --device={M}-{V} モデルと OS バージョンを --device ID 文字列にマッピングします。1 つのフラグで複数のデバイスのカンマ区切りリストを受け入れます(例:--device=mediumphone-arm-32,shiba-36)。
共通(Android、iOS) 実行制御と不安定性 --async --async 1 対 1 でマッピングされます。コマンドはデフォルトで同期のままです。すぐに戻るには、これを渡します。gcloud beta device-run sessions wait <SESSION_ID> でモニタリングまたは待機します。
共通(Android、iOS) 実行の制御と不安定さ --num-flaky-test-attempts {R} --flaky-test-attempts {A} 整数。再試行回数 $R$ を合計試行回数の上限に変換します。$A = R + 1$(デフォルトは 1)。
共通(Android と iOS) 実行制御と不安定さ なし --flaky-test-parallel-retry Boolean。テストの失敗を並行して再試行するかどうか(デフォルトは順次)。
共通(Android と iOS) 実行制御と不安定さ なし --flaky-test-retry-level 文字列。再試行レベル: shard または test(デフォルトは shard)。
共通(Android と iOS) 出力とストレージ --results-bucket --bucket-name テスト出力アーティファクトがアップロードされるバケット(デフォルトは gs://[PROJECT_ID]-devicerun)。
共通(Android、iOS) 出力とストレージ --results-dir 自動的に管理される カスタム サブディレクトリの設定はサポートされていません。すべてのテスト アーティファクトは、--bucket-name で指定されたバケット内の automation/sessions/{session_id}/ の下に自動的に整理されます。
共通(Android と iOS) 出力とストレージ --record-video --video 有効な値は always または on-failure です。
共通(Android と iOS) 出力とストレージ --directories-to-pull --paths-to-pull 実行後にデバイスから pull するパスのリスト。
一般的な Android コア パラメータとアセット --app --apps リスト。複数のアプリケーション APK/AAB が指定されている場合は、すべてを --apps に渡します。
一般的な Android コア パラメータとアセット --additional-apks --apps リスト。追加のリスト値をメインの --apps リストに直接マージします。
一般的な Android コア パラメータとアセット --obb-files --other-files-to-push SOURCE=DEST 形式の辞書。OBB ファイルをデバイスパス(/sdcard/Android/obb/{package_name}/)に直接 push します。
一般的な Android コア パラメータとアセット --other-files --other-files-to-push 辞書(SOURCE=DEST 形式)。
一般的な Android デバイスの設定とターゲティング --device locale={L} --locale={L} デバイスのロケールを最上位の --locale フラグ(language-region など)にマッピングします。--locale=en-US)を指定できます。
一般的な Android デバイスの設定とターゲティング --device orientation={O} --orientation={O} デバイスの向きを最上位の --orientation フラグ(portrait または landscape)にマッピングします。
共通 Android デバイス設定とターゲティング なし --coordinates 仮の現在地情報の座標 (latitude,longitude、例: 37.4220,-122.0841)。
共通 Android 実行制御と不安定さ --grant-permissions 自動デフォルト 自動化。実行時の権限はデフォルトで自動的に付与されます(--grant-permissions=all と同等)。
一般的な Android 出力とストレージ なし --dumpsys デバイス(always または on-failure)から dumpsys を収集します。
一般的な Android 出力とストレージ なし --bugreport デバイス(always または on-failure)からバグレポートを収集します。
Android 計測 コア パラメータとアセット --type=instrumentation sessions submit instrumentation サブコマンド構造で、--type フラグではなくテストタイプを決定します。
Android 計測 コア パラメータとアセット --test --test インストルメンテーション テストを含むバイナリ ファイルへのパス。
Android インストルメンテーション 実行の制御と不安定さ --timeout --instrumentation-timeout 期間(例: 10m、20s、1h)。有効な範囲: 1m~3h(デフォルトは 5m)。
Android インストルメンテーション 実行の制御と不安定さ --num-uniform-shards {N} --sharding-option=uniform
--uniform-sharding-count={N}
フラグ構成により、均一シャーディング戦略が有効になります(有効なカウント範囲: 物理 1 ~ 20、仮想 1 ~ 200)。
Android インストルメンテーション 実行の制御と不安定さ 側面 --shard-time {S} --sharding-option=smart
--smart-sharding-target-duration={S}
目標実行時間でスマート シャーディングを有効にします(例: 2m、10m、1h)。有効な範囲: 2m~1h。
Android インストルメンテーション 実行制御と不安定さ 側面 --smart-flank-gcs-path --smart-sharding-record-name={name}
--bucket-name={bucket}
automation/smart-sharding/ の --bucket-name 内にあるシャーディング レコード YAML の名前(拡張子を除く)。
Android インストルメンテーション 実行の制御と不安定さ 側面 --max-test-shards {N} --smart-sharding-max-shard-count={N} スマート シャーディングが有効になっている場合、最大シャード境界にマッピングされます(物理 0 ~ 20、仮想 0 ~ 200)。
Android インストルメンテーション テストランナーとターゲット --test-runner-class --test-runner-class 完全修飾ランナークラス。
Android インストルメンテーション テストランナーとターゲット --test-targets --test-targets package、notPackage、class、notClass、annotation、notAnnotation、size などのキーをサポートする辞書。testfile や notTestfile などの形式はサポートされません。
Android インストルメンテーション テストランナーとターゲット --use-orchestrator --orchestrator-version auto(デフォルトのオーケストレーター)または特定のバージョン文字列(例: 1.6)。
Android インストルメンテーション テストランナーとターゲット --environment-variables --additional-test-options テストランナーに渡されるオプションのディクショナリ。--test-targets でサポートされている形式は、ここでは使用できません。
iOS の一般的な問題 コア パラメータとアセット --additional-ipas --additional-apps テスト実行前にデバイスにインストールする .ipa ファイルのリスト。
一般的な iOS コア パラメータとアセット --other-files --other-files-to-push SOURCE=BUNDLE_ID:DEVICE_PATH 形式の辞書。
iOS の一般的な問題 デバイスの設定とターゲティング --device locale={L} --locale={L} デバイスの言語 / 地域を最上位の --locale フラグ(language-region、例: --locale=en-US)を指定できます。
iOS の一般的な問題 出力とストレージ --directories-to-pull --paths-to-pull テスト後に pull するファイルまたはディレクトリのリスト(BUNDLE_ID:DEVICE_PATH 形式)。
iOS XCTest のみ コア パラメータとアセット --type=xctest sessions submit xctest サブコマンド構造によって、--type フラグではなくテストタイプが決定されます(gcloud alpha を使用)。
iOS XCTest のみ コア パラメータとアセット --test --test iOS アプリと XCTest ファイルを含む ZIP ファイルのパス。
iOS XCTest のみ 実行の制御と不安定さ --timeout --xctest-timeout XCTest の実行に許容される最大時間(有効な範囲: 1m~1h、デフォルトは 5m)。
iOS XCTest のみ テストランナーとターゲット --xctestrun-file --xctestrun-file カスタム .xctestrun ファイルのパス。
iOS XCTest のみ テストランナーとターゲット --xcode-version --xcode-version 使用する Xcode のカタログ ID またはバージョン文字列(例: xcode-16-4 または 16.4)。software-versions list を使用してクエリします。

行動につながる翻訳のガイダンス

Firebase Test Lab と Flank の構成をデバイス実行に変換するには、次のガイドラインに沿って操作します。

1. デバイスの仕様

gcloud beta device-run では、--device はモデルとバージョン ID の文字列のカンマ区切りのリストを受け取ります。Firebase ではデバイスごとに 1 つの --device フラグが必要でしたが、device-run では 1 つのフラグで複数のデバイスを指定できます。デバイスの言語 / 地域、向き、モック座標は、別々のトップレベル フラグを使用して指定します。

  • ❌ --device model=MediumPhone.arm,version=32,locale=en,orientation=portrait
  • ✅ --device=mediumphone-arm-32 --locale=en-US --orientation=portrait

2. 辞書とリスト

カンマ区切りのフラグをリスト(--apps、--paths-to-pull)または Key-Value 辞書(--other-files-to-push、--additional-test-options)に変換します。

  • ❌ --other-files /sdcard/file1.txt=local/file1.txt,/sdcard/file2.txt=local/file2.txt
  • ✅ --other-files-to-push local/file1.txt=/sdcard/file1.txt,local/file2.txt=/sdcard/file2.txt

3. シャーディング戦略

  • 均一シャーディング:
    • --sharding-option=uniform を設定します。
    • --uniform-sharding-count={count} を設定します(物理の場合は 1 ~ 20、仮想の場合は 1 ~ 200)。
  • スマート シャーディング:
    • --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)。

4. 非同期実行

  • 非同期と待機: --async が指定されている場合、CLI は作成されたセッション ID をすぐに返します。gcloud beta device-run sessions wait <SESSION_ID> を使用して、CI/CD ワークフローでセッションの完了を待機できます。

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

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

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

!注 キーに -- が必要な理由: gcloud は、YAML キーをコマンドライン フラグとして CLI パーサーに直接挿入します。YAML ファイルのすべてのキーには、-- という接頭辞を付ける必要があります(例: --device:、--apps:)。-- がないと、gcloud は認識されない位置引数として拒否します。

以下に、複数値のリストフラグと辞書フラグの例を示します。

# 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 Test Lab と Flank の構成をデバイス実行に変換します。

Firebase Test Lab からデバイス実行へ

firebase cmd:

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 coverage=true

次のように変換されます。

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 coverage=true

デバイス実行への Flank 構成

flank options(flank.yml):

gcloud:
  app: app-debug.apk
  test: app-debug-androidTest.apk
  device:
    -   model: mediumphone-arm
      version: 32
  shard-time: 120
  smart-flank-gcs-path: gs://my-bucket/automation/smart-sharding/timing-record.yaml

翻訳:

最新の CLI コマンドに直接変換する。

gcloud beta device-run sessions submit instrumentation \
  --device=mediumphone-arm-32 \
  --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

オプション 2: 宣言型 YAML フラグ ファイル(--flags-file)

シェル スクリプト文字列ではなく、バージョン管理された YAML ファイルで構成を維持する場合は、gcloud の組み込み --flags-file 機能を使用します。

# device-run-flags.yaml
# Note: gcloud requires keys to start with '--'
--device:
  -   mediumphone-arm-32
--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

CLI を使用して送信する:

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

(--async の追加など、コマンドラインでフラグを追加またはオーバーライドすることもできます)。

デバイス カタログの検出

listing & inspecting devices:

# List all available Android devices
gcloud beta device-run devices list --filter="platform:android"

# Filter devices with high fleet capacity (replaces legacy list-device-capacities)
gcloud beta device-run devices list --filter="availability.capacity=CAPACITY_HIGH"

# Describe a specific device (OS versions, form factors, orientation, locales, capacity)
gcloud beta device-run devices describe redfin-30

CI/CD におけるエンドツーエンドのセッション ライフサイクル

submitting, waiting, and inspecting sessions:

# 1. Submit asynchronously and capture session ID
SESSION_ID=$(gcloud beta device-run sessions submit instrumentation \
  --apps=app-debug.apk \
  --test=app-debug-androidTest.apk \
  --device=mediumphone-arm-32 \
  --async \
  --format="value(name)")

# 2. Wait for session completion in CI/CD pipeline
gcloud beta device-run sessions wait "$SESSION_ID"

# 3. Describe session summary (or pass --full for complete details)
gcloud beta device-run sessions describe "$SESSION_ID"

# 4. Cancel a running session if aborted
gcloud beta device-run sessions cancel "$SESSION_ID"