一. 录制
配置:
需要在repeater-config.json 中配置httpEntrancePatterns (接口地址) 配置增强的方法 以及子调用的方法(List)排列。
志文覆写了新的回放和查看回放结果的请求(在repeater-console\repeater-console-start\src\main\java\com\alibaba\repeater\console\start\controller\web\ReplayWebController.java)中
查看回放结果详情接口路径为:http://hostname/repeater/replay/detail post请求
{
"repeatId": "repeatId"
}
repeatId的value在回放的表中获取
执行回放:[http://hostname/repeater/replay/execute] post请求
{
"ip": "ip",
"appName": "repeater",
"traceId": "traceId",
"mock": true
}
进行录制:[http://hostname/repeater/regress/slogan]
实际配置的接口
修改配置: http://hostname/repeater/config/saveOrUpdate //志文重写的接口 也可以调用原始的请求
{
"appName":"unknown",
"environment":"unknown",
"config":"{\"degrade\":false,\"exceptionThreshold\":1000,\"httpEntrancePatterns\":[\"^/api/.*$\"],\"javaSubInvokeBehaviors\": [{\"classPattern\":\"path", \"includeSubClasses\": false,\"methodPatterns\":[\"getByCompanyId\"]}],\"pluginIdentities\": [\"http\",\"java-entrance\",\"java-subInvoke\",\"mybatis\",\"ibatis\",\"dubbo-provider\",\"dubboconsumer\"],\"repeatIdentities\": [\"java\",\"http\",\"dubbo\"],\"sampleRate\": 10000,\"useTtl\": true}"}
原生的修改配置 http://hostname/repeater/config/add.htm
@RequestMapping("add.htm")
public String add(Model model) {
RepeaterConfig defaultConf = new RepeaterConfig();
List<Behavior> behaviors = Lists.newArrayList();
defaultConf.setPluginIdentities(Lists.newArrayList( "http", "java-entrance", "java-subInvoke"));
defaultConf.setRepeatIdentities(Lists.newArrayList("java", "http"));
defaultConf.setUseTtl(true);
defaultConf.setHttpEntrancePatterns(Lists.newArrayList("^/regress/.*$"));
behaviors.add(new Behavior("com.alibaba.repeater.console.service.impl.RegressServiceImpl", "getRegress"));
defaultConf.setJavaEntranceBehaviors(behaviors);
List<Behavior> subBehaviors = Lists.newArrayList();
subBehaviors.add(new Behavior("com.alibaba.repeater.console.service.impl.RegressServiceImpl", "getRegressInner", "findPartner","slogan"));
defaultConf.setJavaSubInvokeBehaviors(subBehaviors);
try {
model.addAttribute("config", JacksonUtil.serialize(defaultConf));
} catch (SerializeException e) {
model.addAttribute("errorMessage", e.getMessage());
return "/error/404";
}
return "config/add";
}
自己修改配置。
如不重启服务则需要调用push生效
http://hostname/repeater/config/push //目录:com.alibaba.repeater.console.start.controller.web;
body{
和saveOrUpdate 的请求体一样。
}
配置文件详解:
{
"degrade":false, 改为true后不在录制
"exceptionThreshold":1000, 异常发生阈值;默认1000当ExceptionAware感知到异常次数超过阈值后,会降级模块
"httpEntrancePatterns":[ 需要录制和回放的http接口需要同时在pluginIdedentities和repeatIdentities中都配置了http这个配置才生效
"^/regress/.*$"
],
"javaSubInvokeBehaviors":[ 需要录制和mock的java方法的配需要
{
"classPattern":"packpagePath",
"includeSubClasses":false,
"methodPatterns":[ 方法配置
"getByCompanyId"
]
}
],
"pluginIdentities":[
"http",
"java-entrance",
"java-subInvoke",
"mybatis",
"ibatis",
"dubbo-provider",
"dubboconsumer"
],
"repeatIdentities":[
"java",
"http",
"dubbo"
],
"sampleRate":10000,
"useTtl":true
}
更详细的配置见:[https://testerhome.com/topics/20869]