关于STF
STF是一套移动设备管理平台,目前只支持安卓,含:
1、远程调试手机;
2、远程装apk;
3、远程执行shell脚本;
4、查看adb执行日志等;
环境
Ubuntu21.04+Docker+STF
root@ubuntu:/home/app/docker-airtest# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 21.04
Release: 21.04
Codename: hirsute
root@ubuntu:/home/app/docker-airtest# docker -v
Docker version 20.10.7, build 20.10.7-0ubuntu1~21.04.1
所需要安装依赖
安装Docker
sudo apt-get update # 更新软件包
sudo apt-get install docker-ce docker-ce-cli containerd.io # 安装Docker
拉取STF相关镜像
sudo docker pull openstf/stf:latest # STF镜像
sudo docker pull sorccu/adb:latest # adb 镜像
sudo docker pull rethinkdb:latest # rethinkdb 镜像
sudo docker pull openstf/ambassador:latest # ambassador 镜像
sudo docker pull nginx:latest # nginx 镜像
启动镜像
启动rethinkdb数据库
sudo docker run -d --name rethinkdb -v /srv/rethinkdb:/data --net host rethinkdb rethinkdb --bind all --cache-size 8192 --http-port 8090
启动adb
sudo docker run -d --name adbd --privileged -v /dev/bus/usb:/dev/bus/usb --net host sorccu/adb:latest
启动stf 启动的时配置的IP地址通过ifconfig命令查询到的结果
sudo docker run -d --name stf --net host openstf/stf stf local --public-ip 192.168.245.128
查看运行中的容器
```bash
root@ubuntu:/home/app/docker-airtest# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f0931aa160f2 openstf/stf "stf local --public-…" 40 minutes ago Up 40 minutes stf
af4959e321d7 sorccu/adb:latest "/sbin/tini -- adb -…" 41 minutes ago Up 41 minutes adbd
2fbd7cbaa792 rethinkdb "rethinkdb --bind al…" 41 minutes ago Up 41 minutes rethinkdb
9458bb0484a4 nginx "/docker-entrypoint.…" 17 hours ago Up 17 hours 0.0.0.0:80->80/tcp webserver
b67331b84f49 jenkinsci/blueocean "/sbin/tini -- /usr/…" 12 days ago Up 12 days jenkins
6aff5f308a96 busybox "sh" 12 days ago Exited (0) 12 days ago storedata
最后在虚拟机里的浏览器或者本地PC端浏览器输入:http://ip:7100 即可访问,这里的ip即为上文中ifconfig红框中的ip,必须是外网可以访问。y
搭建完成后效果
输入admin及任一邮箱
插入设备后,自动就会连上展示
双击任一设备,稍等手机自动安装STFService.apk并启动,然后可以
为方便阅读,可以切成中文
同步查看linux后台中STF日志
root@ubuntu:/home/lixf6# docker logs -f stf
2021-08-16T09:06:08.736Z INF/device:plugins:screen:stream 174 [8KE0219730006796] Connecting to minicap service
2021-08-16T09:06:08.749Z INF/device:plugins:screen:stream 174 [8KE0219730006796] minicap says: "INFO: (external/MY_minicap/src/minicap_29.cpp:244) Performing SurfaceComposerClient init check"
2021-08-16T09:06:08.750Z INF/device:plugins:screen:stream 174 [8KE0219730006796] minicap says: "INFO: (external/MY_minicap/src/minicap_29.cpp:255) Creating virtual display"
2021-08-16T09:06:08.751Z INF/device:plugins:screen:stream 174 [8KE0219730006796] minicap says: "INFO: (external/MY_minicap/src/minicap_29.cpp:261) Creating buffer queue"
2021-08-16T09:06:08.751Z INF/device:plugins:screen:stream 174 [8KE0219730006796] minicap says: "INFO: (external/MY_minicap/src/minicap_29.cpp:264) Setting buffer options"
2021-08-16T09:06:08.754Z INF/device:plugins:screen:stream 174 [8KE0219730006796] minicap says: "INFO: (external/MY_minicap/src/minicap_29.cpp:268) Creating CPU consumer"
2021-08-16T09:06:08.754Z INF/device:plugins:screen:stream 174 [8KE0219730006796] minicap says: "INFO: (external/MY_minicap/src/minicap_29.cpp:272) Creating frame waiter"
2021-08-16T09:06:08.755Z INF/device:plugins:screen:stream 174 [8KE0219730006796] minicap says: "INFO: (external/MY_minicap/src/minicap_29.cpp:276) Publishing virtual display"
2021-08-16T09:06:08.765Z INF/device:plugins:screen:stream 174 [8KE0219730006796] minicap says: "INFO: (jni/minicap/JpgEncoder.cpp:64) Allocating 7678980 bytes for JPG encoder"
2021-08-16T09:06:08.773Z IMP/device:plugins:connect 174 [8KE0219730006796] Remote Connect Started for device "8KE0219730006796" at "192.168.245.128:7413"
2021-08-16T09:06:08.853Z INF/device:plugins:screen:stream 174 [8KE0219730006796] Reading minicap banner
参考:https://www.huaweicloud.com/articles/66374193b9f7058311f1777ad0ea96ac.html