AWS Device Farm에서 원격 액세스 세션 생성 - AWS Device Farm

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

AWS Device Farm에서 원격 액세스 세션 생성

원격 액세스 세션에 대한 자세한 내용은 세션 단원을 참조하세요.

사전 조건

원격 세션 생성

Console
  1. https://console.aws.amazon.com/devicefarm에서 Device Farm 콘솔에 로그인하세요.

  2. Device Farm 탐색 패널에서 모바일 디바이스 테스트를 선택한 다음 프로젝트를 선택하세요.

  3. 프로젝트가 이미 있는 경우 프로젝트 페이지에서 선택하세요. 프로젝트를 만들려면, AWS Device Farm에서 프로젝트 생성의 지침을 따르십시오.

  4. 원격 액세스 탭에서 원격 액세스 세션 생성을 선택합니다.

  5. 세션의 디바이스를 선택하세요. 사용 가능한 디바이스 목록에서 선택하거나 목록 맨 위에 있는 필드를 사용하여 디바이스를 검색할 수 있습니다.

  6. (선택 사항) 앱과 보조 앱을 세션의 일부로 포함합니다. 새로 업로드된 앱 또는 지난 30일 동안이 프로젝트에 이전에 업로드된 앱일 수 있습니다(30일 후에는 앱 업로드가 만료됨).

  7. 세션 이름에 세션 이름을 입력하세요.

  8. 확인 및 세션 시작을 선택하세요.

AWS CLI

참고:이 지침은 원격 액세스 세션 생성에만 중점을 둡니다. 세션 중에 사용할 앱을 업로드하는 방법에 대한 지침은 앱 업로드 자동화를 참조하세요.

먼저 최신 버전을 다운로드하고 설치하여 AWS CLI 버전이 up-to-date 버전인지 확인합니다.

중요

이 문서에 언급된 특정 명령은 AWS CLI의 이전 버전에서는 사용할 수 없습니다.

그런 다음 테스트할 디바이스를 결정할 수 있습니다.

$ aws devicefarm list-devices

그러면 다음과 같은 출력이 표시됩니다.

{ "devices": [ { "arn": "arn:aws:devicefarm:us-west-2::device:DE5BD47FF3BD42C3A14BF7A6EFB1BFE7", "name": "Google Pixel 8", "remoteAccessEnabled": true, "availability": "HIGHLY_AVAILABLE" ... }, ... ] }

그런 다음 선택한 디바이스 ARN을 사용하여 원격 액세스 세션을 생성할 수 있습니다.

$ aws devicefarm create-remote-access-session \ --project-arn arn:aws:devicefarm:us-west-2:111122223333:project:12345678-1111-2222-333-456789abcdef \ --device-arn arn:aws:devicefarm:us-west-2::device:DE5BD47FF3BD42C3A14BF7A6EFB1BFE7 \ --app-arn arn:aws:devicefarm:us-west-2:111122223333:upload:12345678-1111-2222-333-456789abcdef/12345678-1111-2222-333-456789abcdef \ --configuration '{ "auxiliaryApps": [ "arn:aws:devicefarm:us-west-2:111122223333:upload:12345678-1111-2222-333-456789abcdef/12345678-1111-2222-333-456789abcde0", "arn:aws:devicefarm:us-west-2:111122223333:upload:12345678-1111-2222-333-456789abcdef/12345678-1111-2222-333-456789abcde1" ] }'

그러면 다음과 같은 출력이 표시됩니다.

{ "remoteAccessSession": { "arn": "arn:aws:devicefarm:us-west-2:111122223333:session:abcdef123456-1234-5678-abcd-abcdef123456/abcdef123456-1234-5678-abcd-abcdef123456/00000", "name": "Google Pixel 8", "status": "PENDING", ... }

이제 선택적으로 세션을 폴링하고 준비할 때까지 기다릴 수 있습니다.

$ POLL_INTERVAL=3 TIMEOUT=600 DEADLINE=$(( $(date +%s) + TIMEOUT )) while [[ "$(date +%s)" -lt "$DEADLINE" ]]; do STATUS=$(aws devicefarm get-remote-access-session \ --arn "$DEVICE_FARM_SESSION_ARN" \ --query 'remoteAccessSession.status' \ --output text) case "$STATUS" in RUNNING) echo "Session is ready with status: $STATUS" break ;; STOPPING|COMPLETED) echo "Session ended early with status: $STATUS" exit 1 ;; esac done
Python

참고:이 지침은 원격 액세스 세션 생성에만 중점을 둡니다. 세션 중에 사용할 앱을 업로드하는 방법에 대한 지침은 앱 업로드 자동화를 참조하세요.

이 예제에서는 먼저 Device Farm에서 사용 가능한 Google Pixel 디바이스를 찾은 다음 해당 디바이스로 원격 액세스 세션을 생성하고 세션이 실행될 때까지 기다립니다.

import random import time import boto3 client = boto3.client("devicefarm", region_name="us-west-2") # 1) Gather all matching devices via paginated ListDevices with filters filters = [ {"attribute": "MODEL", "operator": "CONTAINS", "values": ["Pixel"]}, {"attribute": "AVAILABILITY", "operator": "EQUALS", "values": ["AVAILABLE"]}, ] matching_arns = [] next_token = None while True: args = {"filters": filters} if next_token: args["nextToken"] = next_token page = client.list_devices(**args) for d in page.get("devices", []): matching_arns.append(d["arn"]) next_token = page.get("nextToken") if not next_token: break if not matching_arns: raise RuntimeError("No available Google Pixel device found.") # Randomly select one device from the full matching set device_arn = random.choice(matching_arns) print("Selected device ARN:", device_arn) # 2) Create remote access session and wait until RUNNING resp = client.create_remote_access_session( projectArn="arn:aws:devicefarm:us-west-2:111122223333:project:12345678-1111-2222-333-456789abcdef", deviceArn=device_arn, appArn="arn:aws:devicefarm:us-west-2:111122223333:upload:12345678-1111-2222-333-456789abcdef/12345678-1111-2222-333-456789abcdef", # optional configuration={ "auxiliaryApps": [ # optional "arn:aws:devicefarm:us-west-2:111122223333:upload:12345678-1111-2222-333-456789abcdef/12345678-1111-2222-333-456789abcde0", "arn:aws:devicefarm:us-west-2:111122223333:upload:12345678-1111-2222-333-456789abcdef/12345678-1111-2222-333-456789abcde1", ] }, ) session_arn = resp["remoteAccessSession"]["arn"] print(f"Created Remote Access Session: {session_arn}") poll_interval = 3 timeout = 600 deadline = time.time() + timeout terminal_states = ["STOPPING", "COMPLETED"] while True: out = client.get_remote_access_session(arn=session_arn) status = out["remoteAccessSession"]["status"] print(f"Current status: {status}") if status == "RUNNING": print(f"Session is ready with status: {status}") break if status in terminal_states: raise RuntimeError(f"Session ended early with status: {status}") if time.time() >= deadline: raise RuntimeError("Timed out waiting for session to be ready.") time.sleep(poll_interval)
Java

참고:이 지침은 원격 액세스 세션 생성에만 중점을 둡니다. 세션 중에 사용할 앱을 업로드하는 방법에 대한 지침은 앱 업로드 자동화를 참조하세요.

참고:이 예제에서는 Java v2용 AWS SDK를 사용하며 JDK 버전 11 이상과 호환됩니다.

이 예제에서는 먼저 Device Farm에서 사용 가능한 Google Pixel 디바이스를 찾은 다음 해당 디바이스로 원격 액세스 세션을 생성하고 세션이 실행될 때까지 기다립니다.

import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.ThreadLocalRandom; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.devicefarm.DeviceFarmClient; import software.amazon.awssdk.services.devicefarm.model.CreateRemoteAccessSessionConfiguration; import software.amazon.awssdk.services.devicefarm.model.CreateRemoteAccessSessionRequest; import software.amazon.awssdk.services.devicefarm.model.CreateRemoteAccessSessionResponse; import software.amazon.awssdk.services.devicefarm.model.Device; import software.amazon.awssdk.services.devicefarm.model.DeviceFilter; import software.amazon.awssdk.services.devicefarm.model.DeviceFilterAttribute; import software.amazon.awssdk.services.devicefarm.model.GetRemoteAccessSessionRequest; import software.amazon.awssdk.services.devicefarm.model.GetRemoteAccessSessionResponse; import software.amazon.awssdk.services.devicefarm.model.ListDevicesRequest; import software.amazon.awssdk.services.devicefarm.model.ListDevicesResponse; import software.amazon.awssdk.services.devicefarm.model.RuleOperator; public class CreateRemoteAccessSession { public static void main(String[] args) throws Exception { DeviceFarmClient client = DeviceFarmClient.builder() .region(Region.US_WEST_2) .build(); String projectArn = "arn:aws:devicefarm:us-west-2:111122223333:project:12345678-1111-2222-333-456789abcdef"; String appArn = "arn:aws:devicefarm:us-west-2:111122223333:upload:12345678-1111-2222-333-456789abcdef/12345678-1111-2222-333-456789abcdef"; String aux1 = "arn:aws:devicefarm:us-west-2:111122223333:upload:12345678-1111-2222-333-456789abcdef/12345678-1111-2222-333-456789abcde0"; String aux2 = "arn:aws:devicefarm:us-west-2:111122223333:upload:12345678-1111-2222-333-456789abcdef/12345678-1111-2222-333-456789abcde1"; // 1) Gather all matching devices via paginated ListDevices with filters List<DeviceFilter> filters = Arrays.asList( DeviceFilter.builder() .attribute(DeviceFilterAttribute.MODEL) .operator(RuleOperator.CONTAINS) .values("Pixel") .build(), DeviceFilter.builder() .attribute(DeviceFilterAttribute.AVAILABILITY) .operator(RuleOperator.EQUALS) .values("AVAILABLE") .build() ); List<String> matchingDeviceArns = new ArrayList<>(); String next = null; do { ListDevicesResponse page = client.listDevices( ListDevicesRequest.builder().filters(filters).nextToken(next).build()); for (Device d : page.devices()) { matchingDeviceArns.add(d.arn()); } next = page.nextToken(); } while (next != null); if (matchingDeviceArns.isEmpty()) { throw new RuntimeException("No available Google Pixel device found."); } // Randomly select one device from the full matching set String deviceArn = matchingDeviceArns.get( ThreadLocalRandom.current().nextInt(matchingDeviceArns.size())); System.out.println("Selected device ARN: " + deviceArn); // 2) Create Remote Access session and wait until it is RUNNING CreateRemoteAccessSessionConfiguration cfg = CreateRemoteAccessSessionConfiguration.builder() .auxiliaryApps(Arrays.asList(aux1, aux2)) .build(); CreateRemoteAccessSessionResponse res = client.createRemoteAccessSession( CreateRemoteAccessSessionRequest.builder() .projectArn(projectArn) .deviceArn(deviceArn) .appArn(appArn) // optional .configuration(cfg) // optional .build()); String sessionArn = res.remoteAccessSession().arn(); System.out.println("Created Remote Access Session: " + sessionArn); int pollIntervalMs = 3000; long timeoutMs = 600_000L; long deadline = System.currentTimeMillis() + timeoutMs; while (true) { GetRemoteAccessSessionResponse get = client.getRemoteAccessSession( GetRemoteAccessSessionRequest.builder().arn(sessionArn).build()); String status = get.remoteAccessSession().statusAsString(); System.out.println("Current status: " + status); if ("RUNNING".equals(status)) { System.out.println("Session is ready with status: " + status); break; } if ("STOPPING".equals(status) || "COMPLETED".equals(status)) { throw new RuntimeException("Session ended early with status: " + status); } if (System.currentTimeMillis() >= deadline) { throw new RuntimeException("Timed out waiting for session to be ready."); } Thread.sleep(pollIntervalMs); } } }
JavaScript

참고:이 지침은 원격 액세스 세션 생성에만 중점을 둡니다. 세션 중에 사용할 앱을 업로드하는 방법에 대한 지침은 앱 업로드 자동화를 참조하세요.

참고:이 예제에서는 JavaScript v3용 AWS SDK를 사용합니다.

이 예제에서는 먼저 Device Farm에서 사용 가능한 Google Pixel 디바이스를 찾은 다음 해당 디바이스로 원격 액세스 세션을 생성하고 세션이 실행될 때까지 기다립니다.

import { DeviceFarmClient, ListDevicesCommand, CreateRemoteAccessSessionCommand, GetRemoteAccessSessionCommand, } from "@aws-sdk/client-device-farm"; const client = new DeviceFarmClient({ region: "us-west-2" }); // 1) Gather all matching devices via paginated ListDevices with filters const filters = [ { attribute: "MODEL", operator: "CONTAINS", values: ["Pixel"] }, { attribute: "AVAILABILITY", operator: "EQUALS", values: ["AVAILABLE"] }, ]; let nextToken; const matching = []; while (true) { const page = await client.send(new ListDevicesCommand({ filters, nextToken })); for (const d of page.devices ?? []) { matching.push(d.arn); } nextToken = page.nextToken; if (!nextToken) break; } if (matching.length === 0) { throw new Error("No available Google Pixel device found."); } // Randomly select one device from the full matching set const deviceArn = matching[Math.floor(Math.random() * matching.length)]; console.log("Selected device ARN:", deviceArn); // 2) Create remote access session and wait until RUNNING const out = await client.send(new CreateRemoteAccessSessionCommand({ projectArn: "arn:aws:devicefarm:us-west-2:111122223333:project:12345678-1111-2222-333-456789abcdef", deviceArn, appArn: "arn:aws:devicefarm:us-west-2:111122223333:upload:12345678-1111-2222-333-456789abcdef/12345678-1111-2222-333-456789abcdef", // optional configuration: { auxiliaryApps: [ // optional "arn:aws:devicefarm:us-west-2:111122223333:upload:12345678-1111-2222-333-456789abcdef/12345678-1111-2222-333-456789abcde0", "arn:aws:devicefarm:us-west-2:111122223333:upload:12345678-1111-2222-333-456789abcdef/12345678-1111-2222-333-456789abcde1", ], }, })); const sessionArn = out.remoteAccessSession?.arn; console.log("Created Remote Access Session:", sessionArn); const pollIntervalMs = 3000; const timeoutMs = 600000; const deadline = Date.now() + timeoutMs; while (true) { const get = await client.send(new GetRemoteAccessSessionCommand({ arn: sessionArn })); const status = get.remoteAccessSession?.status; console.log("Current status:", status); if (status === "RUNNING") { console.log("Session is ready with status:", status); break; } if (status === "STOPPING" || status === "COMPLETED") { throw new Error(`Session ended early with status: ${status}`); } if (Date.now() >= deadline) { throw new Error("Timed out waiting for session to be ready."); } await new Promise((r) => setTimeout(r, pollIntervalMs)); }
C#

참고:이 지침은 원격 액세스 세션 생성에만 중점을 둡니다. 세션 중에 사용할 앱을 업로드하는 방법에 대한 지침은 앱 업로드 자동화를 참조하세요.

이 예제에서는 먼저 Device Farm에서 사용 가능한 Google Pixel 디바이스를 찾은 다음 해당 디바이스로 원격 액세스 세션을 생성하고 세션이 실행될 때까지 기다립니다.

using System; using System.Collections.Generic; using System.Threading.Tasks; using Amazon; using Amazon.DeviceFarm; using Amazon.DeviceFarm.Model; class Program { static async Task Main() { var client = new AmazonDeviceFarmClient(RegionEndpoint.USWest2); // 1) Gather all matching devices via paginated ListDevices with filters var filters = new List<DeviceFilter> { new DeviceFilter { Attribute = DeviceAttribute.MODEL, Operator = RuleOperator.CONTAINS, Values = new List<string>{ "Pixel" } }, new DeviceFilter { Attribute = DeviceAttribute.AVAILABILITY, Operator = RuleOperator.EQUALS, Values = new List<string>{ "AVAILABLE" } }, }; var matchingArns = new List<string>(); string nextToken = null; do { var list = await client.ListDevicesAsync(new ListDevicesRequest { Filters = filters, NextToken = nextToken }); foreach (var d in list.Devices) matchingArns.Add(d.Arn); nextToken = list.NextToken; } while (nextToken != null); if (matchingArns.Count == 0) throw new Exception("No available Google Pixel device found."); // Randomly select one device from the full matching set var rnd = new Random(); var deviceArn = matchingArns[rnd.Next(matchingArns.Count)]; Console.WriteLine($"Selected device ARN: {deviceArn}"); // 2) Create remote access session and wait until RUNNING var request = new CreateRemoteAccessSessionRequest { ProjectArn = "arn:aws:devicefarm:us-west-2:111122223333:project:12345678-1111-2222-333-456789abcdef", DeviceArn = deviceArn, AppArn = "arn:aws:devicefarm:us-west-2:111122223333:upload:12345678-1111-2222-333-456789abcdef/12345678-1111-2222-333-456789abcdef", // optional Configuration = new CreateRemoteAccessSessionConfiguration { AuxiliaryApps = new List<string> { "arn:aws:devicefarm:us-west-2:111122223333:upload:12345678-1111-2222-333-456789abcdef/12345678-1111-2222-333-456789abcde0", "arn:aws:devicefarm:us-west-2:111122223333:upload:12345678-1111-2222-333-456789abcdef/12345678-1111-2222-333-456789abcde1" } } }; request.Configuration.AuxiliaryApps.RemoveAll(string.IsNullOrWhiteSpace); var response = await client.CreateRemoteAccessSessionAsync(request); var sessionArn = response.RemoteAccessSession.Arn; Console.WriteLine($"Created Remote Access Session: {sessionArn}"); var pollIntervalMs = 3000; var timeoutMs = 600000; var deadline = DateTime.UtcNow.AddMilliseconds(timeoutMs); while (true) { var get = await client.GetRemoteAccessSessionAsync(new GetRemoteAccessSessionRequest { Arn = sessionArn }); var status = get.RemoteAccessSession.Status.Value; Console.WriteLine($"Current status: {status}"); if (status == "RUNNING") { Console.WriteLine($"Session is ready with status: {status}"); break; } if (status == "STOPPING" || status == "COMPLETED") { throw new Exception($"Session ended early with status: {status}"); } if (DateTime.UtcNow >= deadline) { throw new TimeoutException("Timed out waiting for session to be ready."); } await Task.Delay(pollIntervalMs); } } }
Ruby

참고:이 지침은 원격 액세스 세션 생성에만 중점을 둡니다. 세션 중에 사용할 앱을 업로드하는 방법에 대한 지침은 앱 업로드 자동화를 참조하세요.

이 예제에서는 먼저 Device Farm에서 사용 가능한 Google Pixel 디바이스를 찾은 다음 해당 디바이스로 원격 액세스 세션을 생성하고 세션이 실행될 때까지 기다립니다.

require 'aws-sdk-devicefarm' client = Aws::DeviceFarm::Client.new(region: 'us-west-2') # 1) Gather all matching devices via paginated ListDevices with filters filters = [ { attribute: 'MODEL', operator: 'CONTAINS', values: ['Pixel'] }, { attribute: 'AVAILABILITY', operator: 'EQUALS', values: ['AVAILABLE'] }, ] matching_arns = [] next_token = nil loop do resp = client.list_devices(filters: filters, next_token: next_token) resp.devices&.each { |d| matching_arns << d.arn } next_token = resp.next_token break unless next_token end abort "No available Google Pixel device found." if matching_arns.empty? # Randomly select one device from the full matching set device_arn = matching_arns.sample puts "Selected device ARN: #{device_arn}" # 2) Create remote access session and wait until RUNNING resp = client.create_remote_access_session( project_arn: "arn:aws:devicefarm:us-west-2:111122223333:project:12345678-1111-2222-333-456789abcdef", device_arn: device_arn, app_arn: "arn:aws:devicefarm:us-west-2:111122223333:upload:12345678-1111-2222-333-456789abcdef/12345678-1111-2222-333-456789abcdef", # optional configuration: { auxiliary_apps: [ # optional "arn:aws:devicefarm:us-west-2:111122223333:upload:12345678-1111-2222-333-456789abcdef/12345678-1111-2222-333-456789abcde0", "arn:aws:devicefarm:us-west-2:111122223333:upload:12345678-1111-2222-333-456789abcdef/12345678-1111-2222-333-456789abcde1" ].compact } ) session_arn = resp.remote_access_session.arn puts "Created Remote Access Session: #{session_arn}" poll_interval = 3 timeout = 600 deadline = Time.now + timeout terminal = %w[STOPPING COMPLETED] loop do get = client.get_remote_access_session(arn: session_arn) status = get.remote_access_session.status puts "Current status: #{status}" if status == 'RUNNING' puts "Session is ready with status: #{status}" break end abort "Session ended early with status: #{status}" if terminal.include?(status) abort "Timed out waiting for session to be ready." if Time.now >= deadline sleep poll_interval end

다음 단계

Device Farm은 일반적으로 몇 분 이내에 요청된 디바이스 및 인프라를 사용할 수 있게 되는 즉시 세션을 시작합니다. 세션이 시작될 때까지 요청한 디바이스 대화 상자가 나타납니다. 세션 요청을 취소하려면 요청 취소를 선택하세요.

선택한 디바이스를 사용할 수 없거나 사용 중인 경우 세션 상태가 보류 중인 디바이스로 표시되므로 디바이스를 테스트할 수 있으려면 잠시 기다려야 할 수 있습니다.

계정이 퍼블릭 측정 또는 비계측 디바이스의 동시성 한도에 도달한 경우 세션 상태는 동시성 보류 중으로 표시됩니다. 측정되지 않은 디바이스 슬롯의 경우 더 많은 디바이스 슬롯을 구매하여 동시성을 높일 수 있습니다. 사용한 pay-as-you-go 경우 지원 티켓을 통해 AWS에 문의하여 서비스 할당량 증가를 요청하세요.

세션 설정이 시작되면 먼저 진행 중 상태가 표시되고 로컬 웹 브라우저가 디바이스에 대한 원격 연결을 열려고 시도하는 동안 연결 중 상태가 표시됩니다.

세션이 시작된 후 세션을 중단하지 않고 브라우저 또는 브라우저 탭을 닫아야 하거나 브라우저와 인터넷 간의 연결이 끊어지면 세션은 5분 동안 활성 상태로 유지됩니다. 그런 다음 Device Farm은 세션을 종료합니다. 계정에 유휴 시간에 대한 요금이 청구됩니다.

세션이 시작된 후 웹 브라우저에서 디바이스와 상호 작용하거나 Appium을 사용하여 디바이스를 테스트할 수 있습니다.