移动端设备管理平台 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/