diffy自动化脚本实现

在上篇实现后,感觉jar包的执行过程还是比较繁琐,而且需要打开两个窗口才能进行,未免过于麻烦,脚本化后就好了。

如何将其jar包执行自动化,我用了nohub,使其后台运行

      思路主要是,先判断当前环境中diffy的服务有没有启用,如果启用了,就可以直接执行用例,如果没启用的化,需要先启用,然后再执行用例,启用的过程,需要将启动日志存下来,方便后续去debug,所以再一开始,如果没有检测到diffy的pid时,需要先检测下有没有diffy_run.log这个文件,先将其删除,后续启用过程中再新建,并更新此文件。将jar包执行的待测地址,稳定版本1和稳定版本2的地址进行参数化,方便后续环境的迁移。

jar包命令执行过后,需要等待几秒,如果 没有等待,直接去进行curl的化,可能会出现请求失败。整个过程使用了function函数,看起来比较清晰。用if做了判断,检测pid是否为空,用awk进行列中$2的输出。

  nohup java -jar diffy-server.jar -candidate="$candidate" -master.primary="$master_primary" -master.secondary="$master_secondary" -service.protocol=http -serviceName=My-Service -proxy.port=:8880 -admin.port=:8881 -http.port=:8888 -rootUrl='localhost:8888' -summary.email="[email protected]" -allowHttpSideEffects=true -excludeHttpHeadersComparison=true > diffy_run.log 2>&1 &

jar包执行脚本

执行完成后,增加了获取jar包执行地址的命令,获取的是行,第一行的第二列,得到当前的ip地址

ipadr=`ifconfig ens192 | grep inet | sed -n '1p' | awk '{print $2}'`

case执行脚本

昨天弄完后,碰到undefined_endpoint,搜了下官网,意思是

Per endpoint bucketing in Diffy requires either the request to have a "Canonical-Resource" header or the responses from the targets to have an "X-Action-Name" header with the endpoint name as the value.

但header里面没有 "Canonical-Resource"or"X-Action-Name"参数,只能自定义了,

在curl中增加

java -jar diffy-server.jar -candidate=10.6.6.68:28080 -master.primary=10.6.6.115:28080 -master.secondary=10.6.6.115:28080 -service.protocol=http -serviceName=My-Service -proxy.port=:8880 -admin.port=:8881 -http.port=:8888 -rootUrl='localhost:8888' -summary.email="[email protected]" -allowHttpSideEffects=true -excludeHttpHeadersComparison=true


接口返回

增加 canonical=Canonical-Resource:execueDPL

url=http://10.6.6.44:8880/dataset/execueDPL

posttype=Content-Type:application/json;charset=utf-8

token=token:5ff8bfed4abcdae8bae44f2437a7f5a0

 canonical=Canonical-Resource:execueDPL

curl "$url" -H "$posttype" -H "$token" -H "$canonical" -d "$line"

增加 Canonical-Resource:execueDPL

增加Canonical-Resource:execueDPL后的界面

你可能感兴趣的:(diffy自动化脚本实现)