Skip to content

Commit

Permalink
Merge pull request #387 from zebrunner/clarify-location
Browse files Browse the repository at this point in the history
Clarify location
  • Loading branch information
azarouski authored Dec 3, 2024
2 parents b9533e1 + 87f7239 commit 514fc63
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 67 deletions.
2 changes: 1 addition & 1 deletion roles/devices/templates/mcloud-devices.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{% for device in devices %}
{{ device.name }}|{{ device.os }}|{{ device.id }}|{{ device.adb_port }}|{{ device.min_port }}|{{ device.max_port }}|{{ device.proxy_port | default('0') }}|{{ device.appium_port }}|{{ device.wireless | default('false') }}|{{ device.wda_file | default('/dev/null')}}|{{ device.wda_bundleid | default('com.facebook.WebDriverAgentRunner.xctrunner')}}|{{ device.server_proxy_port | default('0')}}
{{ device.id }}|{{ device.os }}|{{ device.name }}|{{ device.location | default('') }}|{{ device.appium_port }}|{{ device.adb_port }}|{{ device.proxy_port | default('0') }}|{{ device.server_proxy_port | default('0') }}|{{ device.min_port }}|{{ device.max_port }}|{{ device.wireless | default('false') }}|{{ device.wda_file | default('/dev/null') }}|{{ device.wda_bundleid | default('com.facebook.WebDriverAgentRunner.xctrunner') }}
{% endfor %}
72 changes: 38 additions & 34 deletions roles/devices/templates/zebrunner-farm
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,30 @@ function create_containers() {
local platform_name=$(cat ${devices} | grep "$udid" | cut -d '|' -f 2)
#echo "platform_name: $platform_name"

local device_adb_port=$(cat ${devices} | grep "$udid" | cut -d '|' -f 4)
#echo "device_adb_port: $device_adb_port"
local location=$(cat ${devices} | grep "$udid" | cut -d '|' -f 4)
#echo "location: $location"

local stf_min_port=$(cat ${devices} | grep "$udid" | cut -d '|' -f 5)
#echo "stf_min_port: $stf_min_port"
local appium_port=$(cat ${devices} | grep "$udid" | cut -d '|' -f 5)
#echo "appium_port: $appium_port"

local stf_max_port=$(cat ${devices} | grep "$udid" | cut -d '|' -f 6)
#echo "stf_max_port: $stf_max_port"
local device_adb_port=$(cat ${devices} | grep "$udid" | cut -d '|' -f 6)
#echo "device_adb_port: $device_adb_port"

local proxy_port=$(cat ${devices} | grep "$udid" | cut -d '|' -f 7)
#echo "proxy_port: $proxy_port"

local appium_port=$(cat ${devices} | grep "$udid" | cut -d '|' -f 8)
#echo "appium_port: $appium_port"
local server_proxy_port=$(cat ${devices} | grep "$udid" | cut -d '|' -f 8)
#echo "server_proxy_port: $server_proxy_port"

local stf_min_port=$(cat ${devices} | grep "$udid" | cut -d '|' -f 9)
#echo "stf_min_port: $stf_min_port"

local wireless=$(cat ${devices} | grep "$udid" | cut -d '|' -f 9)
local stf_max_port=$(cat ${devices} | grep "$udid" | cut -d '|' -f 10)
#echo "stf_max_port: $stf_max_port"

local wireless=$(cat ${devices} | grep "$udid" | cut -d '|' -f 11)
#echo "wireless: $wireless"

local server_proxy_port=$(cat ${devices} | grep "$udid" | cut -d '|' -f 12)
#echo "server_proxy_port: $server_proxy_port"

# without 'block_global=false' mitmproxy does not want to accept requests from devices
# --set confdir allows to provide custom folder with CA Authority certificates
Expand Down Expand Up @@ -150,7 +154,7 @@ function create_containers() {
-e STF_PROVIDER_DEVICE_NAME="${device_name}" \
-e DEVICE_UDID="$STF_DEVICE_UDID" \
-e STF_PROVIDER_HOST={{ STF_PROVIDER_HOST }} \
-e STF_PROVIDER_NAME="{{ STF_PROVIDER_NAME }}" \
-e STF_PROVIDER_NAME="{{ STF_PROVIDER_NAME }}${location:+_$location}" \
-e STF_PROVIDER_MIN_PORT=$stf_min_port \
-e STF_PROVIDER_MAX_PORT=$stf_max_port \
-p $stf_min_port-$stf_max_port:$stf_min_port-$stf_max_port \
Expand Down Expand Up @@ -219,7 +223,7 @@ function create_containers() {

#TODO: comment echoing wda related detailes before release
local wdaIpaPath={{ WDA_FILE }}
local deviceWdaIpaPath=$(cat ${devices} | grep "$udid" | cut -d '|' -f 10)
local deviceWdaIpaPath=$(cat ${devices} | grep "$udid" | cut -d '|' -f 12)
if [ ! -z $deviceWdaIpaPath ] && [ ! "$deviceWdaIpaPath" == "/dev/null" ]; then
wdaIpaPath=$deviceWdaIpaPath
fi
Expand All @@ -230,7 +234,7 @@ function create_containers() {
echo "wdaIpaPath: $wdaIpaPath"

local wdaBundleId={{ WDA_BUNDLEID }}
local deviceWdaBundleId=$(cat ${devices} | grep "$udid" | cut -d '|' -f 11)
local deviceWdaBundleId=$(cat ${devices} | grep "$udid" | cut -d '|' -f 13)
if [ ! -z $deviceWdaBundleId ]; then
wdaBundleId=$deviceWdaBundleId
fi
Expand Down Expand Up @@ -277,7 +281,7 @@ function create_containers() {
-e STF_PROVIDER_DEVICE_NAME="${device_name}" \
-e DEVICE_UDID="${udid}" \
-e STF_PROVIDER_HOST={{ STF_PROVIDER_HOST }} \
-e STF_PROVIDER_NAME="{{ STF_PROVIDER_NAME }}" \
-e STF_PROVIDER_NAME="{{ STF_PROVIDER_NAME }}${location:+_$location}" \
-e STF_PROVIDER_MIN_PORT=$stf_min_port \
-e STF_PROVIDER_MAX_PORT=$stf_max_port \
-p $stf_min_port-$stf_max_port:$stf_min_port-$stf_max_port \
Expand Down Expand Up @@ -348,9 +352,9 @@ function stop() {
# if $device is empty do stop for all connected devices otherwise stop only filtered
if [ ! -z $filter_device ] && [ "$filter_device" != "ios" ] && [ "$filter_device" != "android" ]; then
echo stopping containers for $filter_device...
local device_name=$(cat ${devices} | grep "$filter_device" | cut -d '|' -f 1)
local device_name=$(cat ${devices} | grep "$filter_device" | cut -d '|' -f 3)
local device_name_underscored=${device_name// /_}
local udid=$(cat ${devices} | grep "$filter_device" | cut -d '|' -f 3)
local udid=$(cat ${devices} | grep "$filter_device" | cut -d '|' -f 1)

if [ -z "$device_name" ] || [ -z $udid ]; then
echo_warning "Unable to find device by \"$filter_device\"!"
Expand All @@ -361,13 +365,13 @@ function stop() {
else
# as no device filter provided continue with stopping all device containers
while read -r line; do
local device_name=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 1)
local device_name=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 3)
#echo "device_name: $device_name"
local device_name_underscored=${device_name// /_}

local udid=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 3)
local udid=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 1)
#echo "udid: $udid"
local wireless=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 9)
local wireless=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 11)

if [ -L "/dev/device-${device_name}-${udid}" ] || [ "$wireless" == "True" ]; then
stop_containers ${device_name_underscored} ${udid}
Expand Down Expand Up @@ -402,9 +406,9 @@ function down() {
# if $device is empty do rm for all connected devices otherwise rm only filtered
if [ ! -z $filter_device ] && [ "$filter_device" != "ios" ] && [ "$filter_device" != "android" ]; then
#echo removing containers for $filter_device...
local device_name=$(cat ${devices} | grep "$filter_device" | cut -d '|' -f 1)
local device_name=$(cat ${devices} | grep "$filter_device" | cut -d '|' -f 3)
local device_name_underscored=${device_name// /_}
local udid=$(cat ${devices} | grep "$filter_device" | cut -d '|' -f 3)
local udid=$(cat ${devices} | grep "$filter_device" | cut -d '|' -f 1)

if [ -z "$device_name" ] || [ -z $udid ]; then
echo_warning "Unable to find device by \"$filter_device\"!"
Expand All @@ -414,11 +418,11 @@ function down() {
remove_containers ${device_name_underscored} ${udid}
else
while read -r line; do
local device_name=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 1)
local device_name=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 3)
#echo "device_name: $device_name"
local device_name_underscored=${device_name// /_}

local udid=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 3)
local udid=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 1)
#echo "udid: $udid"
remove_containers ${device_name_underscored} ${udid}
done < ${devices}
Expand Down Expand Up @@ -529,7 +533,7 @@ function verify_containers() {
local udid=$2
#echo "udid: $udid"

local wireless=$(cat ${devices} | grep "$udid" | cut -d '|' -f 9)
local wireless=$(cat ${devices} | grep "$udid" | cut -d '|' -f 11)

local container=device-$device-$udid
if [ ! -L "/dev/$container" ] && [ "$wireless" != "True" ]; then
Expand Down Expand Up @@ -590,9 +594,9 @@ function start() {

# if $device is empty do start for all connected devices otherwise start only filtered
if [ ! -z $filter_device ] && [ "$filter_device" != "ios" ] && [ "$filter_device" != "android" ]; then
local device_name=$(cat ${devices} | grep "$filter_device" | cut -d '|' -f 1)
local device_name=$(cat ${devices} | grep "$filter_device" | cut -d '|' -f 3)
local device_name_underscored=${device_name// /_}
local udid=$(cat ${devices} | grep "$filter_device" | cut -d '|' -f 3)
local udid=$(cat ${devices} | grep "$filter_device" | cut -d '|' -f 1)

if [ -z "$device_name" ] || [ -z $udid ]; then
echo_warning "Unable to find device by \"$filter_device\"!"
Expand All @@ -603,13 +607,13 @@ function start() {
echo -e "\n-----------------------------------------------------------------"
else
while read -r line; do
local device_name=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 1)
local device_name=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 3)
#echo "device_name: $device_name"
local device_name_underscored=${device_name// /_}

local udid=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 3)
local udid=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 1)
#echo "udid: $udid"
local wireless=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 9)
local wireless=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 11)
if [ -L "/dev/device-${device_name}-${udid}" ] || [ "$wireless" == "True" ]; then
create_containers "${device_name}" "${udid}" "${device_name_underscored}" && start_containers "${device_name}" "${udid}" "${device_name_underscored}"
echo -e "\n-----------------------------------------------------------------"
Expand Down Expand Up @@ -643,18 +647,18 @@ function status() {

# if $device is empty do start for all connected devices otherwise start only filtered
if [ ! -z $filter_device ] && [ "$filter_device" != "ios" ] && [ "$filter_device" != "android" ]; then
local device_name=$(cat ${devices} | grep "$filter_device" | cut -d '|' -f 1)
local device_name=$(cat ${devices} | grep "$filter_device" | cut -d '|' -f 3)
#echo "device_name: $device_name"
local device_name_underscored=${device_name// /_}
local udid=$(cat ${devices} | grep "$filter_device" | cut -d '|' -f 3)
local udid=$(cat ${devices} | grep "$filter_device" | cut -d '|' -f 1)
#echo "udid: $udid"
verify_containers "${device_name_underscored}" "${udid}"
else
while read -r line; do
local device_name=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 1)
local device_name=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 3)
#echo "device_name: $device_name"
local device_name_underscored=${device_name// /_}
local udid=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 3)
local udid=$(echo ${line} | grep "$filter_device" | cut -d '|' -f 1)
if [ -z $udid ]; then
continue
fi
Expand Down
3 changes: 3 additions & 0 deletions roles/devices/vars/main.yml.original
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ WDA_BUNDLEID:
# [OBLIGATORY] Declare valid devices metadata
# - id: device udid which is shown by `adb devices`
# name: device name as it will be registered in STF (avoid special symbols and spaces!)
# location: clarified device location for ease of device management (an underscore will be added automatically before the value)
# appium_port: unique port value for sharing appium services from the container to outside selenium hub
# adb_port: unique port value for sharing adb server from the device appium container to outside
# proxy_port: unique port value to configure embedded proxy (they can be used in integration with Carina traffic sniffering functionality: https://zebrunner.github.io/carina/advanced/proxy/)
Expand All @@ -66,6 +67,7 @@ devices:
- id: R28M1384YQY
os: android
name: Samsung_Galaxy_S10
location: location_1
appium_port: 7421
adb_port: 7422
proxy_port: 7423
Expand All @@ -75,6 +77,7 @@ devices:
- id: d6afc6b3a65584ca0813eb8957c6479b9b6ebb11
os: ios
name: iPhone_8_Plus
location: location_2
appium_port: 7431
adb_port: 7432
proxy_port: 7433
Expand Down
3 changes: 1 addition & 2 deletions roles/mac-devices/templates/mcloud-devices.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{% for device in devices %}
{{ device.name }}|{{ device.os }}|{{ device.id }}|{{ device.adb_port }}|{{ device.min_port }}|{{ device.max_port }}|{{ device.proxy_port | default('0') }}|{{ device.appium_port }}|{{ device.wireless | default('false') }}|{{ device.wda_file |
default('/dev/null')}}|{{ device.wda_bundleid | default('com.facebook.WebDriverAgentRunner.xctrunner')}}|{{ device.server_proxy_port | default('0') }}
{{ device.id }}|{{ device.os }}|{{ device.name }}|{{ device.location | default('') }}|{{ device.appium_port }}|{{ device.adb_port }}|{{ device.proxy_port | default('0') }}|{{ device.server_proxy_port | default('0') }}|{{ device.min_port }}|{{ device.max_port }}|{{ device.wireless | default('false') }}|{{ device.wda_file | default('/dev/null') }}|{{ device.wda_bundleid | default('com.facebook.WebDriverAgentRunner.xctrunner') }}
{% endfor %}
Loading

0 comments on commit 514fc63

Please sign in to comment.