背景
pytest的现有分布式执行程序在执行UI脚本时,会有中断的问题
方案设想
在机器上启用flask服务,可以进行主机间的通信,例如上传文件和接受运行脚本的命令。在一台机器上触发运行脚本的命令后,其他机器接收到命令,在运行脚本结束后,其他机器将运行结果统一发送给其中一台机器,接受结果的机器将运行结果保存到相应的文件夹
具体技术实现
在所有机器上启用flask服务后
import flask, os, sys, time
from flask import request, send_from_directory, json
import pytest
# 注意:使用时请将工作路径定位到脚本所在位置
server = flask.Flask(__name__)
scripts_path = os.getcwd() # 脚本所在路径
allure_result_path = r'./allure-result'
# get方法:指定目录下载文件
@server.route('/runscripts', methods=['post'])
def run_scripts():
'''
从端启flask服务使用,接收要运行的模块
:return:
'''
data = request.get_data() # 获取 JOSN 数据
json_data = json.loads(data)
print('json_data:', json_data)
args = []
mod