移动端设备管理平台 atx server2实践
1、需求背景
- 移动设备(Android和IOS)异地调试,包括但不限于apk安装,功能测试,日志查看,屏幕截图等。
- 移动设备管理,重启,关机,网络管理等。
- 结合设备管理平台完成app UI自动化测试。
- 异常调试时延迟可接受,画质可接受。
2、初步调研
了解需求后便开始在网络上查看资料,大部分都是自动化工具的,关于设备管理平台的介绍很少。多番查阅之下,发现业内目前的移动端设备主要有以下几种:
2.1、云测试平台
- 优点:省心,机型多,服务全面。
- 缺点:费用不菲,部分是按照时间收费的。
2.2、开源工具
STF
- 优点:开源免费
- 缺点:网络延迟比较严重
atx server
这个是在TesterHome上看到的,感觉不错决定试一试,感谢作者。github地址如下:
https://github.com/openatx/atxserver2
2.3、VNC
Android VNC Server多年不更新,Android 5.x由于Pie的限制用不了,需要重新编译,过程略复杂,作为安卓未入门级选手果断直接放弃。
2.4、企业内部自研云测试平台
比如美团点评的云真机平台,知乎的云测试平台,这种的一般都是投入一个团队在研发,成本大。
3、ATX Server安装
我使用的机器是Ubuntu18,Windows平台推荐用源码安装。
依赖环境
- Python3
- rethinkdb
安装rethinkdb
官方安装手册地址:https://www.rethinkdb.com/docs/install/ 。根据平台选择对应的安装方法。官方给出的ubuntu安装方法如下:
source /etc/lsb-release && echo "deb http://download.rethinkdb.com/apt $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
wget -qO- https://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install rethinkdb
无法定位到rethinkdb,有的网友说是http改成了https,修改后重新安装也不行。经过查阅资料,rethinkdb不支持ubuntu18,于是尝试用deb的包安装。下载倒数第四个。
下载地址:https://github.com/srh/rethinkdb/releases/tag/v2.3.6.srh.1
安装方法:
Run sudo dpkg -i foo.deb to install a deb package.
If you get a message about missing some dependencies, run sudo apt-get install -f to install them.
Then run rethinkdb --version to test that installation succeeded.
安装atx server
clone代码到本地
git clone https://github.com/openatx/atxserver2.git
安装curl工具
sudo apt install curl
安装docker-compose
sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
将当前用户假如docker组
sudo gpasswd -a ${USER} docker
编辑/etc/default/docker文件
加入如下配置
DOCKER_OPTS="-H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock"
重启docker或重启机器
service docker restart
退出命令行,切换到代码docker-compose.yml所在目录,执行
docker-compose up
启动日志如下:
stephen@stephen-K55VD:~/atx-server/atxserver2$ docker-compose up
Creating network "atxserver2_default" with the default driver
Pulling rethinkdb (rethinkdb:2.3.6)...
2.3.6: Pulling from library/rethinkdb
9811207f4eba: Pull complete
d7c48489ee79: Pull complete
bd3fe89ae346: Pull complete
1914a1a7f89d: Pull complete
bf26223d4854: Pull complete
Digest: sha256:37340d5fcc7b0e83eed0e699a6af5362a3d8ff19cf3f80819dcf75d6c5ebcc18
Status: Downloaded newer image for rethinkdb:2.3.6
Building web
Step 1/6 : FROM python:3.6
3.6: Pulling from library/python
6f2f362378c5: Pull complete
494c27a8a6b8: Pull complete
7596bb83081b: Pull complete
372744b62d49: Pull complete
615db220d76c: Pull complete
1865698adfb0: Pull complete
7159b3304cc0: Pull complete
ad0713808ef6: Pull complete
7ba593904573: Pull complete
Digest: sha256:904bc648c46a22d0bca62340785da841eaeb7099addb2fc4941a5a8b878c5ce7
Status: Downloaded newer image for python:3.6
---> 48c06762acf0
Step 2/6 : ADD . /app
---> abff59a2fca3
Step 3/6 : WORKDIR /app
---> Running in cc16e0af3f06
Removing intermediate container cc16e0af3f06
---> 61b746c8516d
Step 4/6 : RUN pip install -r requirements.txt
---> Running in 8faf64de476a
Collecting six (from -r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting bunch (from -r requirements.txt (line 2))
Downloading https://files.pythonhosted.org/packages/ef/bf/a4cf1779a4ffb4f610903fa08e15d1f4a8a2f4e3353a02afbe097c5bf4a8/bunch-1.0.1.tar.gz
Collecting logzero (from -r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/97/24/27295d318ea8976b12cf9cc51d82e7c7129220f6a3cc9e3443df3be8afdb/logzero-1.5.0-py2.py3-none-any.whl
Collecting tornado>=5.0 (from -r requirements.txt (line 4))
Downloading https://files.pythonhosted.org/packages/03/3f/5f89d99fca3c0100c8cede4f53f660b126d39e0d6a1e943e95cc3ed386fb/tornado-6.0.2.tar.gz (481kB)
Collecting requests (from -r requirements.txt (line 5))
Downloading https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl (57kB)
Collecting apkutils-patch<=0.6.0,>=0.5.4 (from -r requirements.txt (line 6))
Downloading https://files.pythonhosted.org/packages/d0/e3/fd4d547044b9fcf0af7eca25c055dc1169aadc47a3677eb5951426c9a66a/apkutils-patch-0.5.4.tar.gz (60kB)
Collecting rethinkdb==2.4.2.post1 (from -r requirements.txt (line 7))
Downloading https://files.pythonhosted.org/packages/98/4b/b22065b2686f440f8eaa8a7326e96a442ce98b7b637d28529958b83b2128/rethinkdb-2.4.2.post1-py2.py3-none-any.whl (155kB)
Collecting certifi>=2017.4.17 (from requests->-r requirements.txt (line 5))
Downloading https://files.pythonhosted.org/packages/60/75/f692a584e85b7eaba0e03827b3d51f45f571c2e793dd731e598828d380aa/certifi-2019.3.9-py2.py3-none-any.whl (158kB)
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests->-r requirements.txt (line 5))
Downloading https://files.pythonhosted.org/packages/e6/60/247f23a7121ae632d62811ba7f273d0e58972d75e58a94d329d51550a47d/urllib3-1.25.3-py2.py3-none-any.whl (150kB)
Collecting idna<2.9,>=2.5 (from requests->-r requirements.txt (line 5))
Downloading https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)
Collecting chardet<3.1.0,>=3.0.2 (from requests->-r requirements.txt (line 5))
Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
Collecting pyelftools (from apkutils-patch<=0.6.0,>=0.5.4->-r requirements.txt (line 6))
Downloading https://files.pythonhosted.org/packages/fa/9a/0674cb1725196568bdbca98304f2efb17368b57af1a4bb3fc772c026f474/pyelftools-0.25.tar.gz (499kB)
Collecting cigam (from apkutils-patch<=0.6.0,>=0.5.4->-r requirements.txt (line 6))
Downloading https://files.pythonhosted.org/packages/3c/d0/19ff49c1938aea4e0076ee084ca23845408cffb51582b2be975f926533b5/cigam-0.0.3-py3-none-any.whl
Collecting xmltodict (from apkutils-patch<=0.6.0,>=0.5.4->-r requirements.txt (line 6))
Downloading https://files.pythonhosted.org/packages/28/fd/30d5c1d3ac29ce229f6bdc40bbc20b28f716e8b363140c26eff19122d8a5/xmltodict-0.12.0-py2.py3-none-any.whl
Building wheels for collected packages: bunch, tornado, apkutils-patch, pyelftools
Building wheel for bunch (setup.py): started
Building wheel for bunch (setup.py): finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/56/0f/19/fbbf81e5764e6d8b74501c4357a88c14c94466ec777c03734c
Building wheel for tornado (setup.py): started
Building wheel for tornado (setup.py): finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/61/7e/7a/5e02e60dc329aef32ecf70e0425319ee7e2198c3a7cf98b4a2
Building wheel for apkutils-patch (setup.py): started
Building wheel for apkutils-patch (setup.py): finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/43/70/ff/194b6150b109c3143bf17d8821a21cb7060de738038b920c64
Building wheel for pyelftools (setup.py): started
Building wheel for pyelftools (setup.py): finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/55/2f/15/4ce6885a52f475de68c16f3116a94d2156d588390cdb6c507c
Successfully built bunch tornado apkutils-patch pyelftools
Installing collected packages: six, bunch, logzero, tornado, certifi, urllib3, idna, chardet, requests, pyelftools, cigam, xmltodict, apkutils-patch, rethinkdb
Successfully installed apkutils-patch-0.5.4 bunch-1.0.1 certifi-2019.3.9 chardet-3.0.4 cigam-0.0.3 idna-2.8 logzero-1.5.0 pyelftools-0.25 requests-2.22.0 rethinkdb-2.4.2.post1 six-1.12.0 tornado-6.0.2 urllib3-1.25.3 xmltodict-0.12.0
Removing intermediate container 8faf64de476a
---> 1fa1eb974541
Step 5/6 : ENTRYPOINT [ "scripts/wait-for-db.sh" ]
---> Running in 38527f1e1551
Removing intermediate container 38527f1e1551
---> b107d738e458
Step 6/6 : CMD ["python", "main.py"]
---> Running in 2c4b41cc5b10
Removing intermediate container 2c4b41cc5b10
---> 41a3cc6d72f4
Successfully built 41a3cc6d72f4
Successfully tagged atxserver2_web:latest
WARNING: Image for service web was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating atxserver2_rethinkdb_1 ... done
Creating atxserver2_web_1 ... done
Attaching to atxserver2_rethinkdb_1, atxserver2_web_1
rethinkdb_1 | Recursively removing directory /data/rethinkdb_data/tmp
rethinkdb_1 | Initializing directory /data/rethinkdb_data
rethinkdb_1 | Running rethinkdb 2.3.6~0jessie (GCC 4.9.2)...
rethinkdb_1 | Running on Linux 4.15.0-34-generic x86_64
rethinkdb_1 | Loading data from directory /data/rethinkdb_data
rethinkdb_1 | Listening for intracluster connections on port 29015
rethinkdb_1 | Listening for client driver connections on port 28015
rethinkdb_1 | Listening for administrative HTTP connections on port 8080
rethinkdb_1 | Listening on cluster addresses: 127.0.0.1, 172.18.0.2
rethinkdb_1 | Listening on driver addresses: 127.0.0.1, 172.18.0.2
rethinkdb_1 | Listening on http addresses: 127.0.0.1, 172.18.0.2
rethinkdb_1 | Server ready, "32b5db1e779c_vxj" d1530d1a-a1e6-4c91-ba9a-09343c76dd16
web_1 | RethinkDB is running
web_1 | [I 190616 05:21:21 main:70] listen on port http://172.18.0.3:4000
web_1 | [I 190616 05:21:50 web:2246] 302 GET / (172.18.0.1) 1.69ms
web_1 | [I 190616 05:21:50 web:2246] 200 GET /login?next=%2F (172.18.0.1) 3.17ms
web_1 | [I 190616 05:21:50 web:2246] 200 GET /favicon.ico (172.18.0.1) 34.69ms
web_1 | [I 190616 05:22:00 web:2246] 302 POST /login (172.18.0.1) 307.36ms
web_1 | [I 190616 05:22:00 web:2246] 302 GET / (172.18.0.1) 9.53ms
web_1 | [I 190616 05:22:00 web:2246] 200 GET /devices (172.18.0.1) 18.83ms
web_1 | [I 190616 05:22:00 web:2246] 200 GET /static/vendor/fontawesome-5.7.2/css/all.css (172.18.0.1) 1.48ms
在浏览器地址栏输入:http://172.18.0.3:4000/devices,具体的地址见启动日志,页面如下:
至此,说明atx sever部署成功了,pull镜像的时间略长,耐心等等,接下来就是部署atxserver2-android-provider。
4、安卓设备接入
vim .bashrc,在环境变量中加入
SERVER_URL="http://172.18.0.3:4000" # 这个修改成自己的atxserver2地址
IMAGE="codeskyblue/atxserver2-android-provider"
保存后,source .bashrc 使之生效。然后执行命令:
docker pull $IMAGE
安装pillow
pip3 install pillow
安装wediter
pip3 install -U weditor
安装adb工具
apt-get install android-tools-adb
机器安装uiautomator2
pip install --pre --upgrade uiautomator2
使用usb线连接上手机,打开开发者模式。查看当前机器上挂的设备
stephen@stephen-K55VD:~$ adb devices
List of devices attached
9fb1c6ae device
初始化(可选步骤)
python3.6 -m uiautomator2 init
最后执行下面这条命令,该镜像会把所有必要的资源 (atx-uiautomator.apk, minicap, minitouch, atx-agent) 全部推送到手机上。安装时需要确认。
docker run --rm --privileged -v /dev/bus/usb:/dev/bus/usb --net host \
${IMAGE} python main.py --server ${SERVER_URL}
等待一切推送完成后,激动人心的时候到了,打开web端看一下效果。点击立即使用可以操作手机。
5、Docker端口转发
截至目前,部署成功,来尝试从别的机器访问web页面,发现无法打开,初步怀疑是防火墙的问题,后排除。导致无法访问的原因是:docker 需要设置端口。
列出容器信息:
stephen@stephen-K55VD:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b0bae8e68a86 codeskyblue/atxserver2-android-provider "python main.py --se…" 12 minutes ago Up 12 minutes affectionate_ardinghelli
7c5284cbdb9e atxserver2_web "scripts/wait-for-db…" 5 hours ago Up 4 hours 0.0.0.0:4000->4000/tcp atxserver2_web_1
32b5db1e779c rethinkdb:2.3.6 "rethinkdb --bind all" 5 hours ago Up 4 hours 8080/tcp, 28015/tcp, 29015/tcp atxserver2_rethinkdb_1
查看容器地址:
docker inspect "web服务所在的容器id"| grep IPAddress
stephen@stephen-K55VD:~/atx-server/atxserver2$ docker inspect 7c5284cbdb9e| grep IPAddress
"SecondaryIPAddresses": null,
"IPAddress": "",
"IPAddress": "172.18.0.3",
设置端口转发
iptables -t nat -A DOCKER -p tcp --dport 4001 -j DNAT --to-destination 172.18.0.3:4000
然后使用地址:http://本机地址:4001 ,查看本机地址用ifconfig,然后就可以从其它机器上访问了。
5、小结
非常棒的一款工具,开源,简洁易用,期待更多新特性,不足之处是画质有点模糊,接下来实践一下IOS设备如何接入和是否能和appium集成。
移动端设备管理平台 atx server2实践的更多相关文章
- 《开源安全运维平台OSSIM最佳实践》
<开源安全运维平台OSSIM最佳实践> 经多年潜心研究开源技术,历时三年创作的<开源安全运维平台OSSIM最佳实践>一书即将出版.该书用80多万字记录了,作者10多年的IT行业 ...
- 微软云平台媒体服务实践系列 2- 使用动态封装为iOS, Android , Windows 等多平台提供视频点播(VoD)方案
文章微软云平台媒体服务实践系列 1- 使用静态封装为iOS, Android 设备实现点播(VoD)方案 介绍了如何针对少数iOS, Android 客户端的场景,出于节约成本的目的使用媒体服务的静 ...
- DataPipeline在大数据平台的数据流实践
文 | 吕鹏 DataPipeline架构师 进入大数据时代,实时作业有着越来越重要的地位.本文将从以下几个部分进行讲解DataPipeline在大数据平台的实时数据流实践. 一.企业级数据面临的主要 ...
- 携程实时计算平台架构与实践丨DataPipeline
文 | 潘国庆 携程大数据平台实时计算平台负责人 本文主要从携程大数据平台概况.架构设计及实现.在实现当中踩坑及填坑的过程.实时计算领域详细的应用场景,以及未来规划五个方面阐述携程实时计算平台架构与实 ...
- ML平台_微博深度学习平台架构和实践
( 转载至: http://www.36dsj.com/archives/98977) 随着人工神经网络算法的成熟.GPU计算能力的提升,深度学习在众多领域都取得了重大突破.本文介绍了微博引入深度学 ...
- 高德Serverless平台建设及实践
导读 高德启动Serverless建设已经有段时间了,目前高德Serverless业务的峰值早已超过十万QPS量级,平台从0到1,QPS从零到超过十万,成为阿里集团内Serverless应用落地规模最 ...
- 高德 Serverless 平台建设及实践
作者 | 邓学祥(祥翼) 来源 | Serverless 公众号 高德从 FY21 财年开始启动 Serverless 建设,至今一年了,高德 Serverless 业务的峰值超过十万 qps 量级, ...
- Windows平台分布式架构实践 - 负载均衡(下)
概述 我们在上一篇Windows平台分布式架构实践 - 负载均衡中讨论了Windows平台下通过NLB(Network Load Balancer) 来实现网站的负载均衡,并且通过压力测试演示了它的效 ...
- Golang在视频直播平台的高性能实践
http://toutiao.com/i6256894054273909249/ 熊猫 TV 是一家视频直播平台,先介绍下我们系统运行的环境,下面这 6 大服务只是我们几十个服务中的一部分,由于并发量 ...
随机推荐
- 详解用python实现简单的遗传算法
详解用python实现简单的遗传算法 今天整理之前写的代码,发现在做数模期间写的用python实现的遗传算法,感觉还是挺有意思的,就拿出来分享一下. 首先遗传算法是一种优化算法,通过模拟基因的优胜劣汰 ...
- linux双机热备份
使用HeartBeat实现高可用HA的配置过程详解 一.写在前面 HA即(high available)高可用,又被叫做双机热备,用于关键性业务.简单理解就是,有2台机器 A 和 B,正常是 A 提供 ...
- 容器时代的持续交付工具---Drone:Drone使用
上一篇文章里已经介绍了如何安装Drone,下面我们来看下如何使用.还是基于gogs作为git仓储. 首先打开server对应的地址,进入登录页面,输入在启动server时配置的管理员账号(对应的就是g ...
- 《精通并发与Netty》学习笔记(10 - 详解NIO (一) Channel、Buffer )
一.Java NIO 概述 Java NIO 由以下几个核心部分组成:ChannelsBuffersSelectors虽然Java NIO 中除此之外还有很多类和组件,但在我看来,Channel,Bu ...
- TeX教程
转自 [抢工作向]一个更适合玩物理的同学的论坛TeX教程 1. 基础知识 如何在你的帖子里插入一个\(\TeX\)环境来写公式呢?答案其实很简单,对于不同的要求,我们有两种方法. 第一种只需要在\(\ ...
- Redis3.2学习记录
nosql 特征:访问量大,高并发,高可用,海量数据 redis3.2作用:减轻关系型数据库查询的压力安装:windows下解压即可使用,启动服务如:redis-server redis-config ...
- RabbitMQ快速开始
①:安装rabbitmq所需要的依赖包 yum install build-essential openssl openssl-devel unixODBC unixODBC-devel make g ...
- Devexpress WinForm TreeList的三种数据绑定方式(DataSource绑定、AppendNode添加节点、VirtualTreeGetChildNodes(虚拟树加载模式))
第一种:DataSource绑定,这种绑定方式需要设置TreeList的ParentFieldName和KeyFieldName两个属性,这里需要注意的是KeyFieldName的值必须是唯一的. 代 ...
- Java 关于String Pool
下面的文章讲得挺清楚: https://www.baeldung.com/java-string-pool 再加一个关于虚拟机的,因为上面的文章提到了JVM: https://abhirockzz.w ...
- docker 入门4 - 群 【翻译】
开始,第 4 部分:群 先决条件 安装 Docker 版本 1.13 或更高版本. 获取第 3 部分先决条件中所述的 Docker Compose. 获取 Docker Machine, Mac 的 ...