Skip to content

Commit

Permalink
Merge pull request #270 from zebrunner/develop
Browse files Browse the repository at this point in the history
2.6.1 rc
  • Loading branch information
vdelendik authored Nov 30, 2023
2 parents ebe0df9 + 4e08165 commit 4379f51
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 27 deletions.
13 changes: 11 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
---
DEVICE_IMAGE: public.ecr.aws/zebrunner/mcloud-device
DEVICE_VERSION: 2.6
DEVICE_VERSION: 2.6.1

APPIUM_IMAGE: public.ecr.aws/zebrunner/appium
APPIUM_VERSION: 2.0.7
APPIUM_VERSION: 2.0.9

UPLOADER_IMAGE: public.ecr.aws/zebrunner/uploader
UPLOADER_VERSION: 3.4

# Put true to disable app size check using local appium storage
APPIUM_APP_SIZE_DISABLE: false

# Optomized app verifications for AppCenter and AWS S3 storages
APPIUM_APP_FETCH_RETRIES: 2
APPIUM_MAX_LOCK_FILE_LIFETIME: 180
APPIUM_APP_WAITING_TIMEOUT: 90

12 changes: 11 additions & 1 deletion roles/devices/tasks/udev.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
---

- name: Get OS name
shell: uname
register: os

- name: Check OS compatibility
ansible.builtin.assert:
that:
- os.stdout is search("Linux")
fail_msg: "OS version is not compatible!"

- name: Check if roles/devices/vars/main.yml file is generated
stat: path=roles/devices/vars/main.yml
register: main_yml

- name: Verify Setup
fail:
msg: "You have to setup services in advance using: ./zebrunner.sh setup"
msg: "You have to setup services in advance using: ./zebrunner.sh setup!"
when: not main_yml.stat.exists

- name: copy script to launch container with appium for device
Expand Down
4 changes: 2 additions & 2 deletions roles/devices/templates/90_mcloud.rules
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% for device in devices %}
SUBSYSTEM=="usb", ENV{ID_SERIAL_SHORT}=="{{ device.id | replace('-','') }}", MODE="0666", SYMLINK+="device-{{ device.name }}-{{ device.id }}"
ACTION=="remove", ENV{ID_SERIAL_SHORT}=="{{ device.id | replace('-','') }}", RUN+="/usr/local/bin/zebrunner-farm"
ACTION=="add", ENV{ID_SERIAL_SHORT}=="{{ device.id | replace('-','') }}", RUN+="/usr/local/bin/zebrunner-farm"
ACTION=="remove", ENV{ID_SERIAL_SHORT}=="{{ device.id | replace('-','') }}", RUN+="/usr/local/bin/zebrunner-farm remove {{ device.id }}"
ACTION=="add", ENV{ID_SERIAL_SHORT}=="{{ device.id | replace('-','') }}", RUN+="/usr/local/bin/zebrunner-farm add {{ device.id }}"
{% endfor %}
40 changes: 29 additions & 11 deletions roles/devices/templates/zebrunner-farm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

if [ ! -z $ACTION ]; then
# triggered by udev rule where device serial (udid) is a must to proceed!
if [ -z $ID_SERIAL_SHORT ]; then
if [ -z $2 ]; then
echo "do nothing as device id/udid missed."
exit 0
fi
Expand Down Expand Up @@ -104,7 +104,6 @@ function create_containers () {
--restart on-failure $DEVICE_ARG \
-v mcloud-key-volume:/root/.android \
-v appium-storage-volume:/opt/appium-storage \
-v mcloud-storage-volume:/opt/zebrunner \
-v device-${device_name}-${udid}:/tmp/log \
-e TASK_LOG=/tmp/log/appium.log \
-e PLATFORM_NAME=$platform_name \
Expand All @@ -113,7 +112,10 @@ function create_containers () {
-e CONNECT_TO_GRID=true \
-e CUSTOM_NODE_CONFIG=true \
-e STF_PROVIDER_HOST={{ STF_PROVIDER_HOST }} \
-e APPIUM_HOST=${device_name}-appium \
-e APPIUM_APP_SIZE_DISABLE={{ APPIUM_APP_SIZE_DISABLE }} \
-e APPIUM_APP_FETCH_RETRIES={{ APPIUM_APP_FETCH_RETRIES }} \
-e APPIUM_MAX_LOCK_FILE_LIFETIME={{ APPIUM_MAX_LOCK_FILE_LIFETIME }} \
-e APPIUM_APP_WAITING_TIMEOUT={{ APPIUM_APP_WAITING_TIMEOUT }} \
-e SELENIUM_HOST={{ SELENIUM_HUB_HOST }} -e SELENIUM_PORT={{ SELENIUM_HUB_PORT }} \
-e DEFAULT_CAPABILITIES=true \
-e DEVICE_NAME="${device_name}" -e DEVICE_UDID="$STF_DEVICE_UDID" \
Expand Down Expand Up @@ -159,31 +161,30 @@ 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`
echo "deviceWdaIpaPath: $deviceWdaIpaPath"
if [ ! -z $deviceWdaIpaPath ] && [ ! "$deviceWdaIpaPath" == "/dev/null" ]; then
wdaIpaPath=$deviceWdaIpaPath
fi
if [ -z $wdaIpaPath ]; then
# unable to use empty value for docker volume share!
wdaIpaPath="/dev/null"
fi
echo "wdaIpaPath: $wdaIpaPath"

local wdaBundleId={{ WDA_BUNDLEID }}
local deviceWdaBundleId=`cat ${devices} | grep "$udid" | cut -d '|' -f 11`
echo "deviceWdaBundleId: $deviceWdaBundleId"
if [ ! -z $deviceWdaBundleId ]; then
wdaBundleId=$deviceWdaBundleId
fi
if [ -z $wdaBundleId ]; then
# provide default value if empty
wdaBundleId="com.facebook.WebDriverAgentRunner.xctrunner"
fi
echo "wdaBundleId: $wdaBundleId"

# candidates for removal: ADB_PORT, STF_PROVIDER_MAX_PORT
docker run -itd --name device-${device_name}-${udid}-appium -m 1g --log-opt max-size=1024m --log-opt max-file=2 --net=${net} \
--restart on-failure \
-v appium-storage-volume:/opt/appium-storage \
-v mcloud-storage-volume:/opt/zebrunner \
-v device-${device_name}-${udid}:/tmp/log \
-v device-${device_name}-${udid}-lockdown:/var/lib/lockdown \
--device=/dev/device-${device_name}-${udid}:${usb_bus} \
Expand All @@ -197,7 +198,10 @@ function create_containers () {
-e CONNECT_TO_GRID=true \
-e CUSTOM_NODE_CONFIG=true \
-e STF_PROVIDER_HOST={{ STF_PROVIDER_HOST }} \
-e APPIUM_HOST=${device_name}-appium \
-e APPIUM_APP_SIZE_DISABLE={{ APPIUM_APP_SIZE_DISABLE }} \
-e APPIUM_APP_FETCH_RETRIES={{ APPIUM_APP_FETCH_RETRIES }} \
-e APPIUM_MAX_LOCK_FILE_LIFETIME={{ APPIUM_MAX_LOCK_FILE_LIFETIME }} \
-e APPIUM_APP_WAITING_TIMEOUT={{ APPIUM_APP_WAITING_TIMEOUT }} \
-e SELENIUM_HOST={{ SELENIUM_HUB_HOST }} -e SELENIUM_PORT={{ SELENIUM_HUB_PORT }} \
-e DEFAULT_CAPABILITIES=true \
-e DEVICE_NAME="${device_name}" -e DEVICE_UDID="${udid}" \
Expand All @@ -222,7 +226,6 @@ function create_containers () {
docker run -d --name device-${device_name}-${udid} --log-opt max-size=1024m --log-opt max-file=2 --net=${net} \
--restart on-failure \
--link device-${device_name}-${udid}-appium:appium \
-v mcloud-storage-volume:/opt/zebrunner \
-e WDA_HOST=appium \
-e WDA_WAIT_TIMEOUT=180 \
-e PLATFORM_NAME=$platform_name \
Expand Down Expand Up @@ -256,6 +259,11 @@ function stop() {
local device_name=`cat ${devices} | grep "$filter_device" | cut -d '|' -f 1`
local udid=`cat ${devices} | grep "$filter_device" | cut -d '|' -f 3`

if [ -z $device_name ] || [ -z $udid ]; then
echo_warning "Unable to find device by \"$filter_device\"!"
return 0
fi

stop_containers ${device_name} ${udid}
else
# as no device filter provided continue with stopping all device containers
Expand Down Expand Up @@ -300,6 +308,11 @@ function down() {
local device_name=`cat ${devices} | grep "$filter_device" | cut -d '|' -f 1`
local udid=`cat ${devices} | grep "$filter_device" | cut -d '|' -f 3`

if [ -z $device_name ] || [ -z $udid ]; then
echo_warning "Unable to find device by \"$filter_device\"!"
return 0
fi

remove_containers ${device_name} ${udid}
else
while read -r line
Expand Down Expand Up @@ -389,6 +402,11 @@ function start() {
local device_name=`cat ${devices} | grep "$filter_device" | cut -d '|' -f 1`
local udid=`cat ${devices} | grep "$filter_device" | cut -d '|' -f 3`

if [ -z $device_name ] || [ -z $udid ]; then
echo_warning "Unable to find device by \"$filter_device\"!"
return 0
fi

create_containers ${device_name} ${udid}
start_containers ${device_name} ${udid}
else
Expand Down Expand Up @@ -489,14 +507,14 @@ case "$ACTION" in
add)
# #122 on start obligatory re-created any existing exited containers
# add action means physical connect via usb and as result we have to remove any existing container for device!
down ${ID_SERIAL_SHORT}
start ${ID_SERIAL_SHORT}
down $2
start $2
;;
bind)
echo "do nothing"
;;
remove)
down ${ID_SERIAL_SHORT}
down $2
;;
start)
start $2
Expand Down
12 changes: 11 additions & 1 deletion roles/mac-devices/tasks/usbmuxd.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
---

- name: Get OS name
shell: uname
register: os

- name: Check OS compatibility
ansible.builtin.assert:
that:
- os.stdout is search("Darwin")
fail_msg: "OS version is not compatible!"

- name: Check if roles/mac-devices/vars/main.yml file is generated
stat: path=roles/mac-devices/vars/main.yml
register: main_yml

- name: Verify Setup
fail:
msg: "You have to setup services in advance using: ./zebrunner.sh setup"
msg: "You have to setup services in advance using: ./zebrunner.sh setup!"
when: not main_yml.stat.exists

- name: copy script to launch container with appium for device
Expand Down
34 changes: 25 additions & 9 deletions roles/mac-devices/templates/zebrunner-farm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export DOCKER_DEFAULT_PLATFORM=linux/amd64

if [ ! -z $ACTION ]; then
# triggered by udev rule where device serial (udid) is a must to proceed!
if [ -z $ID_SERIAL_SHORT ]; then
if [ -z $2 ]; then
echo "do nothing as device id/udid missed."
exit 0
fi
Expand Down Expand Up @@ -140,32 +140,31 @@ function create_containers () {

local wdaIpaPath={{ WDA_FILE }}
local deviceWdaIpaPath=`cat ${devices} | grep "$udid" | cut -d '|' -f 10`
#echo "deviceWdaIpaPath: $deviceWdaIpaPath"
if [ ! -z $deviceWdaIpaPath ] && [ ! "$deviceWdaIpaPath" == "/dev/null" ]; then
wdaIpaPath=$deviceWdaIpaPath
fi
if [ -z $wdaIpaPath ]; then
# unable to use empty value for docker volume share!
wdaIpaPath="/dev/null"
fi
echo "wdaIpaPath: $wdaIpaPath"

local wdaBundleId={{ WDA_BUNDLEID }}
local deviceWdaBundleId=`cat ${devices} | grep "$udid" | cut -d '|' -f 11`
#echo "deviceWdaBundleId: $deviceWdaBundleId"
if [ ! -z $deviceWdaBundleId ]; then
wdaBundleId=$deviceWdaBundleId
fi
if [ -z $wdaBundleId ]; then
# provide default value if empty
wdaBundleId="com.facebook.WebDriverAgentRunner.xctrunner"
fi
echo "wdaBundleId: $wdaBundleId"

# candidates for removal: ADB_PORT, STF_PROVIDER_MAX_PORT
docker run -itd --name device-${device_name}-${udid}-appium -m 1g --log-opt max-size=1024m --log-opt max-file=2 --net=${net} \
-e USBMUXD_SOCKET_ADDRESS={{ USBMUXD_SOCKET_ADDRESS }} \
--restart on-failure \
-v appium-storage-volume:/opt/appium-storage \
-v mcloud-storage-volume:/opt/zebrunner \
-v device-${device_name}-${udid}:/tmp/log \
-e TASK_LOG=/tmp/log/appium.log \
-e APPIUM_CLI="--session-override" \
Expand All @@ -178,7 +177,10 @@ function create_containers () {
-e CONNECT_TO_GRID=true \
-e CUSTOM_NODE_CONFIG=true \
-e STF_PROVIDER_HOST={{ STF_PROVIDER_HOST }} \
-e APPIUM_HOST=${device_name}-appium \
-e APPIUM_APP_SIZE_DISABLE={{ APPIUM_APP_SIZE_DISABLE }} \
-e APPIUM_APP_FETCH_RETRIES={{ APPIUM_APP_FETCH_RETRIES }} \
-e APPIUM_MAX_LOCK_FILE_LIFETIME={{ APPIUM_MAX_LOCK_FILE_LIFETIME }} \
-e APPIUM_APP_WAITING_TIMEOUT={{ APPIUM_APP_WAITING_TIMEOUT }} \
-e SELENIUM_HOST={{ SELENIUM_HUB_HOST }} -e SELENIUM_PORT={{ SELENIUM_HUB_PORT }} \
-e DEFAULT_CAPABILITIES=true \
-e DEVICE_NAME="${device_name}" -e DEVICE_UDID="${udid}" \
Expand All @@ -204,7 +206,6 @@ function create_containers () {
-e USBMUXD_SOCKET_ADDRESS={{ USBMUXD_SOCKET_ADDRESS }} \
--restart on-failure \
--link device-${device_name}-${udid}-appium:appium \
-v mcloud-storage-volume:/opt/zebrunner \
-e WDA_HOST=appium \
-e WDA_WAIT_TIMEOUT=180 \
-e PLATFORM_NAME=$platform_name \
Expand Down Expand Up @@ -238,6 +239,11 @@ function stop() {
local device_name=`cat ${devices} | grep "$filter_device" | cut -d '|' -f 1`
local udid=`cat ${devices} | grep "$filter_device" | cut -d '|' -f 3`

if [ -z $device_name ] || [ -z $udid ]; then
echo_warning "Unable to find device by \"$filter_device\"!"
return 0
fi

stop_containers ${device_name} ${udid}
else
launchctl unload $HOME/Library/LaunchAgents/ZebrunnerDevicesListener.plist > /dev/null 2>&1
Expand Down Expand Up @@ -280,6 +286,11 @@ function down() {
local device_name=`cat ${devices} | grep "$filter_device" | cut -d '|' -f 1`
local udid=`cat ${devices} | grep "$filter_device" | cut -d '|' -f 3`

if [ -z $device_name ] || [ -z $udid ]; then
echo_warning "Unable to find device by \"$filter_device\"!"
return 0
fi

remove_containers ${device_name} ${udid}
else
launchctl unload $HOME/Library/LaunchAgents/ZebrunnerDevicesListener.plist > /dev/null 2>&1
Expand Down Expand Up @@ -382,6 +393,11 @@ function start() {
local device_name=`cat ${devices} | grep "$filter_device" | cut -d '|' -f 1`
local udid=`cat ${devices} | grep "$filter_device" | cut -d '|' -f 3`

if [ -z $device_name ] || [ -z $udid ]; then
echo_warning "Unable to find device by \"$filter_device\"!"
return 0
fi

create_containers ${device_name} ${udid}
start_containers ${device_name} ${udid}
else
Expand Down Expand Up @@ -482,14 +498,14 @@ case "$ACTION" in
add)
# #122 on start obligatory re-created any existing exited containers
# add action means physical connect via usb and as result we have to remove any existing container for device!
down ${ID_SERIAL_SHORT}
start ${ID_SERIAL_SHORT}
down $2
start $2
;;
bind)
echo "do nothing"
;;
remove)
down ${ID_SERIAL_SHORT}
down $2
;;
start)
start $2
Expand Down
1 change: 0 additions & 1 deletion zebrunner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
rm -f roles/mac-devices/vars/main.yml

docker volume rm appium-storage-volume
docker volume rm mcloud-storage-volume
}

status() {
Expand Down

0 comments on commit 4379f51

Please sign in to comment.