2021-06-15 好用的STF-Git项目
作者:互联网
好用的STF-Git项目
1. 基于openstf二次开发的群控管理平台
| 本项目根据openstf以及openstf-ios二次开发。同时支持Android/iOS单体
控制以及群体控制。
| 本项目可以兼容Linux/Mac,利用最新开源的tidevice实现wda快速编译运行,不一定需要Mac设备的支持,体验不一样的openstf.
- 单控: 基于原生的openstf,操作便捷可使用文件安装,shell、剪贴板、日志等功能;
- 群控: 批量支持机器同屏展示,一键home/移除等功能;
快速开始
Mac
仅需两步快速安装 (Mac):
-
准备一台 Mac 主机;
-
安装 brew 以及nodejs,运行以下命令
pip3 install -U tidevice brew uninstall --ignore-dependencies libimobiledevice brew uninstall --ignore-dependencies usbmuxd brew install --HEAD usbmuxd brew unlink usbmuxd brew link usbmuxd brew install --HEAD libimobiledevice brew install --HEAD ideviceinstaller brew install carthage brew install socat brew install graphicsmagick zeromq protobuf yasm pkg-config brew cask install android-platform-tools
-
进入本项目目录,执行
cnpm install
或者npm install
-
如需使用ios接入,配置
WebDriverAgent
,clone代码,clone完毕后进入目录,执行./Scripts/bootstrap.sh
下载 wda所需依赖库
安装xcode(版本< 10.3),运行WebDriverAgent -
如运行错误,检查stf doctor
Linux(centos):
-
基础环境准备
pip3 install -U tidevice sudo -s yum update yum install git yum install yum yum -y install gcc patch yum install gcc-c++ yum install gcc-gfortran yum install zeromq-devel
-
安装 rethinkdb、GraphicsMagick、zeromq pkg-config、yasm、libsodium、protobuf、libimobiledevice、ideviceinstaller
2.1 安装rethinkdbgit clone https://github.com/rethinkdb/rethinkdb.git cd rethinkdb ./configure --allow-fetch make -j4 make install
2.2 安装GraphicsMagick
wget https://iweb.dl.sourceforge.net/project/graphicsmagick/graphicsmagick/1.3.36/GraphicsMagick-1.3.36.tar.gz tar -zxvf GraphicsMagick-1.3.36.tar.gz cd GraphicsMagick-1.3.36 ./configure --prefix=/usr/local/gm make make install
2.3 安装zeromq
wget https://github.com/zeromq/libzmq/releases/download/v4.2.2/zeromq-4.2.2.tar.gz tar zxvf zeromq-4.2.2.tar.gz cd zeromq-4.2.2 ./configure --prefix=/usr/local/zeromq make make install
2.4 安装pkg-config
wget http://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz tar -zxvf pkg-config-0.29.2.tar.gz cd pkg-config-0.29.2 ./configure --prefix=/usr/local/pkg-config --with-internal-glib make make intall
2.5 安装yasm
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz tar -zxvf yasm-1.3.0.tar.gz cd yasm-1.3.0 ./configure --prefix=/usr/local/yasm make make install
2.6 安装libsodium
wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz tar -zxvf libsodium-1.0.18.tar.gz cd libsodium-1.0.18 ./autogen.sh ./configure --prefix=/usr/local/libsodium make make install
2.7 安装protobuf
wget https://github.com/google/protobuf/releases/download/v3.5.0/protobuf-cpp-3.5.0.tar.gz tar -zxvf protobuf-cpp-3.5.0.tar.gz cd protobuf-3.5.0 ./configure --prefix=/usr/local/protobuf make make intall
2.8 软链接
ln -s /usr/local/gm/bin/* /usr/local/bin/ ln -s /usr/local/yasm/bin/* /usr/local/bin/ ln -s /usr/local/libsodium/bin/* /usr/local/bin/ ln -s /usr/local/protobuf/bin/* /usr/local/bin/
2.9 更新/etc/profile
export PKG_CONFIG_PATH=/usr/local/pkg-config export PATH=$PKG_CONFIG_PATH:$PATH
2.10安装libimobiledevice、ideviceinstaller
git clone https://github.com/libimobiledevice/libimobiledevice.git cd libimobiledevice ./autogen.sh --prefix=/opt/local --enable-debug make sudo make install git clone https://github.com/libimobiledevice/ideviceinstaller.git cd ideviceinstaller ./autogen.sh make sudo make install
-
cd到目录执行cnpm install或者npm install + glup build
相关工具
- WebDriverAgent
- brew
- xcode (<10.3)
- nodejs (8)
- python
测试使用版本
- macOS Catalina 10.15.6
- CentOS Linux release 7.8.2003 (Core)
- xcode (10.0)
- nodejs (8.9.0)
- python (3.7.6)
2. deploy-stf-docker 在Ubuntu上使用一键操作部署STF主服务器的脚本
deploy-stf-docker
├─ adbd.service.template
├─nginx.conf.template
└─deploy_stf.sh
-
deploy-stf-docker/adbd.service.template
[Unit] Description=Android Debug Bridge daemon [Service] #TimeoutStartSec=1min Restart=always RestartSec=2s Type=forking User=root ExecStartPre=/usr/bin/adb kill-server ExecStart=/usr/bin/adb start-server ExecStop=/usr/bin/adb kill-server [Install] WantedBy=multi-user.target
-
deploy-stf-docker/nginx.conf.template
daemon off; worker_processes 4; events { worker_connections 1024; } http { upstream stf_app { server __IP_ADDRESS__:3100 max_fails=0; } upstream stf_auth { server __IP_ADDRESS__:3200 max_fails=0; } upstream stf_storage_apk { server __IP_ADDRESS__:3300 max_fails=0; } upstream stf_storage_image { server __IP_ADDRESS__:3400 max_fails=0; } upstream stf_storage { server __IP_ADDRESS__:3500 max_fails=0; } upstream stf_websocket { server __IP_ADDRESS__:3600 max_fails=0; } upstream stf_api { server __IP_ADDRESS__:3700 max_fails=0; } types { application/javascript js; image/gif gif; image/jpeg jpg; text/css css; text/html html; } map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 80; server_name stf.test; keepalive_timeout 70; root /dev/null; resolver 127.0.0.1 valid=300s; resolver_timeout 10s; # Handle stf-provider@floor4.service location ~ "^/d/floor4/([^/]+)/(?<port>[0-9]{5})/$" { proxy_pass http://__IP_ADDRESS__:$port/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Real-IP $remote_addr; } location /auth/ { proxy_pass http://stf_auth/auth/; } location /s/image/ { proxy_pass http://stf_storage_image; } location /s/apk/ { proxy_pass http://stf_storage_apk; } location /s/ { client_max_body_size 10240m; client_body_buffer_size 128k; proxy_pass http://stf_storage; } location /socket.io/ { proxy_pass http://stf_websocket; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $http_x_real_ip; } location /api/ { proxy_pass http://stf_api/api/; } location / { proxy_pass http://stf_app; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $http_x_real_ip; } } }
-
deploy-stf-docker/deploy_stf.sh
NETNAME="" NETWORK_INTERFACES=$(ls /sys/class/net) DNS_A DDRESS=$(nmcli device show ${NETNAME}|grep "IP4\.DNS\[1\]"|awk '{print $2}') echo "DNS Address: ${DNS_ADDRESS}" # Get exported IP Adreess [ ! -z "$(echo ${NETWORK_INTERFACES} | grep "wlo1")" ]&&NETNAME="wlo1" [ ! -z "$(echo ${NETWORK_INTERFACES} | grep "eno1")" ]&&NETNAME="eno1" IP_ADDRESS=$(ifconfig ${NETNAME}|grep "inet "|awk -F: '{print $2}'|awk '{print $1}') [ $# -gt 0 ]&&IP_ADDRESS=$1 echo "IP ADDRESS: ${IP_ADDRESS}" check_return_code() { if [ $? -ne 0 ]; then echo "Failed to run last step!" return 1 fi return 0 } assert_run_ok() { if [ $? -ne 0 ]; then echo "Failed to run last step!" exit 1 fi return 0 } prepare() { echo "setup environment ..." # Given advantages of performance and stability, we run adb server and rethinkdb # on host(physical) machine rather than on docker containers, so need to # install package of android-tools-adb first [ thinkhy 2017-05-04 ] # install adb apt-get install -y android-tools-adb apt-get install -y docker.io assert_run_ok docker pull openstf/stf assert_run_ok #docker pull sorccu/adb #assert_run_ok docker pull rethinkdb assert_run_ok docker pull openstf/ambassador assert_run_ok docker pull nginx assert_run_ok cp -rf adbd.service.template /etc/systemd/system/adbd.service assert_run_ok sed -e "s/__IP_ADDRESS__/${IP_ADDRESS}/g" \ -e "s/__DNS_ADDRESS__/${DNS_ADDRESS}/g" \ nginx.conf.template |tee nginx.conf echo 1>"env.ok" } if [ ! -e env.ok ]; then prepare fi # start local adb server echo "start adb server" systemctl start adbd # start rethinkdb echo "start docker container: rethinkdb" docker rm -f rethinkdb docker run -d --name rethinkdb -v /srv/rethinkdb:/data --net host rethinkdb rethinkdb --bind all --cache-size 8192 --http-port 8090 check_return_code # start nginx, note: generate nginx.conf first echo "start docker container: nginx" docker rm -f nginx docker run -d -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf:ro --name nginx --net host nginx nginx check_return_code # create tables echo "start docker container: stf-migrate" docker rm -f stf-migrate docker run -d --name stf-migrate --net host openstf/stf stf migrate check_return_code # create storage components echo "start docker container: storage-plugin-apk-3300" docker rm -f storage-plugin-apk-3300 docker run -d --name storage-plugin-apk-3300 -p 3300:3000 --dns ${DNS_ADDRESS} openstf/stf stf storage-plugin-apk --port 3000 --storage-url http://${IP_ADDRESS}/ check_return_code echo "start docker container: storage-plugin-image-3400" docker rm -f storage-plugin-image-3400 docker run -d --name storage-plugin-image-3400 -p 3400:3000 --dns ${DNS_ADDRESS} openstf/stf stf storage-plugin-image --port 3000 --storage-url http://${IP_ADDRESS}/ check_return_code echo "start docker container: storage-temp-3500" docker rm -f storage-temp-3500 docker run -d --name storage-temp-3500 -v /mnt/storage:/data -p 3500:3000 --dns ${DNS_ADDRESS} openstf/stf stf storage-temp --port 3000 --save-dir /home/stf check_return_code # tri-proxy echo "start docker container: triproxy-app" docker rm -f triproxy-app docker run -d --name triproxy-app --net host openstf/stf stf triproxy app --bind-pub "tcp://*:7150" --bind-dealer "tcp://*:7160" --bind-pull "tcp://*:7170" check_return_code echo "start docker container: triproxy-dev" docker rm -f triproxy-dev docker run -d --name triproxy-dev --net host openstf/stf stf triproxy dev --bind-pub "tcp://*:7250" --bind-dealer "tcp://*:7260" --bind-pull "tcp://*:7270" check_return_code # auth echo "start docker container: stf-auth-3200" docker rm -f stf-auth-3200 docker run -d --name stf-auth-3200 -e "SECRET=YOUR_SESSION_SECRET_HERE" -p 3200:3000 --dns ${DNS_ADDRESS} openstf/stf stf auth-mock --port 3000 --app-url http://${IP_ADDRESS}/ check_return_code # api echo "start docker container: stf-api" docker rm -f stf-api docker run -d --name stf-api --net host -e "SECRET=YOUR_SESSION_SECRET_HERE" openstf/stf stf api --port 3700 --connect-sub tcp://${IP_ADDRESS}:7150 --connect-push tcp://${IP_ADDRESS}:7170 check_return_code # stf APP echo "start docker container: stf-app-3100" docker rm -f stf-app-3100 docker run -d --name stf-app-3100 --net host -e "SECRET=YOUR_SESSION_SECRET_HERE" -p 3100:3000 openstf/stf stf app --port 3100 --auth-url http://${IP_ADDRESS}/auth/mock/ --websocket-url http://${IP_ADDRESS}/ check_return_code # processor echo "start docker container: stf-processor" docker rm -f stf-processor docker run -d --name stf-processor --net host openstf/stf stf processor stf-processor.service --connect-app-dealer tcp://${IP_ADDRESS}:7160 --connect-dev-dealer tcp://${IP_ADDRESS}:7260 check_return_code # websocket echo "start docker container: websocket" docker rm -f websocket docker run -d --name websocket -e "SECRET=YOUR_SESSION_SECRET_HERE" --net host openstf/stf stf websocket --port 3600 --storage-url http://${IP_ADDRESS}/ --connect-sub tcp://${IP_ADDRESS}:7150 --connect-push tcp://${IP_ADDRESS}:7170 check_return_code # reaper echo "start docker container: reaper" docker rm -f reaper docker run -d --name reaper --net host openstf/stf stf reaper dev --connect-push tcp://${IP_ADDRESS}:7270 --connect-sub tcp://${IP_ADDRESS}:7150 --heartbeat-timeout 30000 check_return_code # provider echo "start docker container: provider-${HOSTNAME}" docker rm -f provider1 docker run -d --name provider1 --net host openstf/stf stf provider --name "provider-${HOSTNAME}" --connect-sub tcp://${IP_ADDRESS}:7250 --connect-push tcp://${IP_ADDRESS}:7270 --storage-url http://${IP_ADDRESS} --public-ip ${IP_ADDRESS} --min-port=15000 --max-port=25000 --heartbeat-interval 20000 --screen-ws-url-pattern "ws://${IP_ADDRESS}/d/floor4/<%= serial %>/<%= publicPort %>/" check_return_code
标签:STF,Git,15,--,IP,stf,install,ADDRESS,docker 来源: https://blog.csdn.net/qq_37497758/article/details/117923621