fix(UI自动化): UI并发独立报告剔除排队时间

This commit is contained in:
zhangyong 2022-11-01 18:54:07 +08:00 committed by zhangyongfit2cloud
parent 68ccaa2a1f
commit 19e33cd332
3 changed files with 19 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import io.metersphere.api.exec.utils.GenerateHashTreeUtil;
import io.metersphere.api.jmeter.utils.ServerConfig;
import io.metersphere.api.jmeter.utils.SmoothWeighted;
import io.metersphere.api.service.RemakeReportService;
import io.metersphere.base.mapper.ext.ExtApiScenarioReportMapper;
import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.ParamConstants;
import io.metersphere.commons.utils.CommonBeanFactory;
@ -52,6 +53,8 @@ public class JMeterService {
private RestTemplate restTemplate;
@Resource
private RedisTemplate<String, Object> redisTemplate;
@Resource
private ExtApiScenarioReportMapper extApiScenarioReportMapper;
@PostConstruct
private void init() {
@ -130,6 +133,14 @@ public class JMeterService {
JMeterBase.addBackendListener(request, request.getHashTree(), MsApiBackendListener.class.getCanonicalName());
}
if(request.getRunMode().startsWith(ParamConstants.MODEL.RUN_MODEL_UI.getValue()) &&
StringUtils.equals(request.getRunType(), RunModeConstants.PARALLEL.toString()) &&
StringUtils.equals(request.getReportType(), RunModeConstants.INDEPENDENCE.toString())){
String poolId = request.getPoolId();
Long time = System.currentTimeMillis();
extApiScenarioReportMapper.updateExecuteTime(poolId,time);
}
LoggerUtil.info("资源:[" + request.getTestId() + "] 加入JMETER中开始执行", request.getReportId());
LocalRunner runner = new LocalRunner(request.getHashTree());
runner.run(request.getReportId());

View File

@ -50,4 +50,6 @@ public interface ExtApiScenarioReportMapper {
List<String> selectByProjectIdAndLessThanTime(@Param("projectId") String projectId, @Param("time") long time);
void updateAllStatus();
void updateExecuteTime(@Param("id") String id,@Param("time") Long time);
}

View File

@ -492,4 +492,10 @@
where status in ('Rerunning', 'Running', 'Waiting')
</update>
<update id="updateExecuteTime">
update api_scenario_report
set create_time = #{time},update_time = #{time}
where id = #{id}
</update>
</mapper>