Skip to content

Can't use device from grid without STF-agent connected #149

Open
@azarouski

Description

@azarouski

I have following workaround:

  1. Device connected to server
  2. Appium instance connected to device and successfully registered in mcloud/grid/console
  3. No mcloud-device container started
docker run -itd --name device-Samsung_Galaxy_S7-123123123123-appium -m 1g --log-opt max-size=1024m --log-opt max-file=2 --net=infra \
--restart on-failure \
--link device-Samsung_Galaxy_S7-123123123123-connector:connector \
-v appium-storage-volume:/opt/appium-storage \
-v device-Samsung_Galaxy_S7-123123123123:/tmp/log \
-e TASK_LOG=/tmp/log/appium.log \
-e PLATFORM_NAME=android \
-e ANDROID_DEVICE=$ANDROID_DEVICE \
-e RETAIN_TASK=true \
-e CONNECT_TO_GRID=true \
-e CUSTOM_NODE_CONFIG=true \
-e STF_PROVIDER_HOST=demo.zebrunner.farm \
-e APPIUM_APP_SIZE_DISABLE=false \
-e APPIUM_APP_FETCH_RETRIES=2 \
-e APPIUM_MAX_LOCK_FILE_LIFETIME=180 \
-e APPIUM_APP_WAITING_TIMEOUT=90 \
-e SELENIUM_HOST=mcloud-grid \
-e SELENIUM_PORT=4444 \
-e DEFAULT_CAPABILITIES=true \
-e DEVICE_NAME=Samsung_Galaxy_S7 \
-e DEVICE_UDID=123123123123 \
-e ADB_PORT=7552 \
-e PROXY_PORT=7553 \
-e SERVER_PROXY_PORT=0 \
-e APPIUM_PORT=7551 \
-p 7551:7551 \
-e RELAXED_SECURITY=true \
-e LOG_LEVEL=debug \
-e ADB_SERVER_SOCKET=tcp:connector:5037 \
-e REMOTE_ADB_HOST_1=connector \
public.ecr.aws/zebrunner/appium:connector

When i'm trying to run tests on this device i have following error logs in mcloud-grid:2.5 container

[STFClient.reserveSTFDevice] - [STF-02549a97-e365-414a-82f8-7ada04592a68] Could not reserve STF device with udid: 123123123123. Status: 0. Response: null
[STFClient.reserveSTFDevice] - [STF-02549a97-e365-414a-82f8-7ada04592a68] Device will be marked as unhealthy due to response status '0'.
[STFClient.reserveSTFDevice] - [STF-02549a97-e365-414a-82f8-7ada04592a68] Could not mark device as unhealthy. Status: 403. Response: null

[TestSlot.getNewSession] - Trying to create a new session on test slot {deviceType=Phone, proxy_port=7553, server:CONFIG_UUID=de0ee23d-545a-4ee2-864f-86a886468ef7, seleniumProtocol=WebDriver, server_proxy_port=0, adb_port=7552, deviceName=Samsung_Galaxy_S7, platform=ANDROID, platformVersion=8.0.0, automationName=uiautomator2, maxInstances=1, platformName=android, udid=123123123123}

these logs are produced by the following code

} else if (stfDevice.getOwner() == null && stfDevice.getPresent() && stfDevice.getReady()) {
Map<String, Object> entity = new HashMap<>();
entity.put("serial", deviceUDID);
entity.put("timeout", TimeUnit.SECONDS.toMillis(stfTimeout));
HttpClient.Response response = HttpClient.uri(Path.STF_USER_DEVICES_PATH, STF_URL)
.withAuthorization(buildAuthToken(stfToken))
.post(Void.class, entity);
if (response.getStatus() != 200) {
LOGGER.warning(() -> String.format("[STF-%s] Could not reserve STF device with udid: %s. Status: %s. Response: %s",
sessionUUID, deviceUDID, response.getStatus(), response.getObject()));
if (response.getStatus() == 0) {
STF_DEVICE_IGNORE_AUTOMATION_TIMERS.put(deviceUDID, Duration.ofMillis(System.currentTimeMillis()).plus(Duration.ofMinutes(30)));
LOGGER.warning(() -> String.format("[STF-%s] Device will be marked as unhealthy due to response status '0'.", sessionUUID));
entity.put("body", Map.of("status", "Unhealthy"));
HttpClient.Response r = HttpClient.uri(Path.STF_DEVICES_ITEM_PATH, STF_URL, deviceUDID)
.withAuthorization(buildAuthToken(stfToken))
.put(Void.class, entity);
if (r.getStatus() != 200) {
LOGGER.warning(() -> String.format("[STF-%s] Could not mark device as unhealthy. Status: %s. Response: %s", sessionUUID,
r.getStatus(), r.getObject()));
}
}
return null;
}
} else {
return null;
}


When i'm starting mcloud-device(STF) container everything works fine.


Let's discuss how to fix this problem and should we fix it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions