fix(通用功能): 任务中心停止全部,没有根据过滤条件停止
--bug=1043678 --user=陈建星 【任务中心】github#31896,测试计划是admin执行,使用其他用户lijx,点击全部停止,admin的任务也停止了。应只停止当前用户的测试任务。 https://www.tapd.cn/55049933/s/1545276
This commit is contained in:
parent
f1aad6bc36
commit
4fd265573f
|
@ -281,6 +281,15 @@
|
||||||
<foreach collection="request.projects" item="id" separator="," open="(" close=")">
|
<foreach collection="request.projects" item="id" separator="," open="(" close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
<if test="request.userId != null and request.userId != ''">
|
||||||
|
and user_id = #{request.userId}
|
||||||
|
</if>
|
||||||
|
<if test="request.triggerMode != null and request.triggerMode != ''">
|
||||||
|
and trigger_mode = #{request.triggerMode}
|
||||||
|
</if>
|
||||||
|
<if test="request.executionStatus != null and request.executionStatus != ''">
|
||||||
|
and status = #{request.executionStatus}
|
||||||
|
</if>
|
||||||
</select>
|
</select>
|
||||||
<select id="selectResourceId" resultType="java.lang.String">
|
<select id="selectResourceId" resultType="java.lang.String">
|
||||||
SELECT resource_id
|
SELECT resource_id
|
||||||
|
|
|
@ -476,6 +476,15 @@
|
||||||
<foreach collection="request.projects" item="id" separator="," open="(" close=")">
|
<foreach collection="request.projects" item="id" separator="," open="(" close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
<if test="request.userId != null and request.userId != ''">
|
||||||
|
and user_id = #{request.userId}
|
||||||
|
</if>
|
||||||
|
<if test="request.triggerMode != null and request.triggerMode != ''">
|
||||||
|
and trigger_mode = #{request.triggerMode}
|
||||||
|
</if>
|
||||||
|
<if test="request.executionStatus != null and request.executionStatus != ''">
|
||||||
|
and status = #{request.executionStatus}
|
||||||
|
</if>
|
||||||
</select>
|
</select>
|
||||||
<select id="selectByProjectIdAndLessThanTime" resultType="java.lang.String">
|
<select id="selectByProjectIdAndLessThanTime" resultType="java.lang.String">
|
||||||
select id
|
select id
|
||||||
|
|
|
@ -139,8 +139,12 @@ public class ExtApiTaskService extends TaskService {
|
||||||
Map<String, TaskRequestDTO> taskRequestMap = taskRequests.stream().collect(Collectors.toMap(TaskRequestDTO::getType, taskRequest -> taskRequest));
|
Map<String, TaskRequestDTO> taskRequestMap = taskRequests.stream().collect(Collectors.toMap(TaskRequestDTO::getType, taskRequest -> taskRequest));
|
||||||
// 获取工作空间项目
|
// 获取工作空间项目
|
||||||
LoggerUtil.info("获取工作空间对应的项目");
|
LoggerUtil.info("获取工作空间对应的项目");
|
||||||
|
TaskRequestDTO taskRequest = taskRequestMap.get(ElementConstants.SCENARIO_UPPER);
|
||||||
TaskCenterRequest taskCenterRequest = new TaskCenterRequest();
|
TaskCenterRequest taskCenterRequest = new TaskCenterRequest();
|
||||||
taskCenterRequest.setProjects(this.getOwnerProjectIds(taskRequestMap.get(ElementConstants.SCENARIO_UPPER).getUserId()));
|
taskCenterRequest.setProjects(this.getOwnerProjectIds(taskRequest.getUserId()));
|
||||||
|
taskCenterRequest.setUserId(taskRequest.getUserId());
|
||||||
|
taskCenterRequest.setTriggerMode(taskRequest.getTriggerMode());
|
||||||
|
taskCenterRequest.setExecutionStatus(taskRequest.getExecutionStatus());
|
||||||
|
|
||||||
// 结束掉未分发完成的任务
|
// 结束掉未分发完成的任务
|
||||||
LoggerUtil.info("结束正在进行中的计划任务队列");
|
LoggerUtil.info("结束正在进行中的计划任务队列");
|
||||||
|
|
|
@ -341,22 +341,26 @@ export default {
|
||||||
array.push({
|
array.push({
|
||||||
type: "API",
|
type: "API",
|
||||||
projectId: getCurrentProjectID(),
|
projectId: getCurrentProjectID(),
|
||||||
userId: getCurrentUser().id,
|
userId: this.condition.executor,
|
||||||
});
|
});
|
||||||
array.push({
|
array.push({
|
||||||
type: "SCENARIO",
|
type: "SCENARIO",
|
||||||
projectId: getCurrentProjectID(),
|
projectId: getCurrentProjectID(),
|
||||||
userId: getCurrentUser().id,
|
userId: this.condition.executor,
|
||||||
});
|
});
|
||||||
array.push({
|
array.push({
|
||||||
type: "PERFORMANCE",
|
type: "PERFORMANCE",
|
||||||
projectId: getCurrentProjectID(),
|
projectId: getCurrentProjectID(),
|
||||||
userId: getCurrentUser().id,
|
userId: this.condition.executor,
|
||||||
});
|
});
|
||||||
array.push({
|
array.push({
|
||||||
type: "UI_SCENARIO",
|
type: "UI_SCENARIO",
|
||||||
projectId: getCurrentProjectID(),
|
projectId: getCurrentProjectID(),
|
||||||
userId: getCurrentUser().id,
|
userId: this.condition.executor,
|
||||||
|
});
|
||||||
|
array.forEach(item => {
|
||||||
|
item.triggerMode = this.condition.triggerMode;
|
||||||
|
item.executionStatus = this.condition.executionStatus;
|
||||||
});
|
});
|
||||||
stopBatchTask(array).then((response) => {
|
stopBatchTask(array).then((response) => {
|
||||||
this.$success(this.$t("report.test_stop_success"));
|
this.$success(this.$t("report.test_stop_success"));
|
||||||
|
@ -365,9 +369,12 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getMaintainerOptions() {
|
getMaintainerOptions() {
|
||||||
getProjectUsers().then((response) => {
|
return new Promise(resolve => {
|
||||||
this.maintainerOptions = response.data;
|
getProjectUsers().then((response) => {
|
||||||
this.condition.executor = getCurrentUser().id;
|
this.maintainerOptions = response.data;
|
||||||
|
this.condition.executor = getCurrentUser().id;
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
initWebSocket() {
|
initWebSocket() {
|
||||||
|
@ -398,7 +405,6 @@ export default {
|
||||||
},
|
},
|
||||||
showTaskCenter() {
|
showTaskCenter() {
|
||||||
this.getTaskRunning();
|
this.getTaskRunning();
|
||||||
this.getMaintainerOptions();
|
|
||||||
window.addEventListener("resize", this.listenScreenChange, false);
|
window.addEventListener("resize", this.listenScreenChange, false);
|
||||||
this.taskVisible = true;
|
this.taskVisible = true;
|
||||||
},
|
},
|
||||||
|
@ -411,10 +417,11 @@ export default {
|
||||||
this.websocket.close();
|
this.websocket.close();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
open(activeName) {
|
async open(activeName) {
|
||||||
if (activeName) {
|
if (activeName) {
|
||||||
this.activeName = activeName;
|
this.activeName = activeName;
|
||||||
}
|
}
|
||||||
|
await this.getMaintainerOptions();
|
||||||
this.init(true);
|
this.init(true);
|
||||||
this.taskVisible = true;
|
this.taskVisible = true;
|
||||||
setTimeout(this.showTaskCenter, 2000);
|
setTimeout(this.showTaskCenter, 2000);
|
||||||
|
@ -529,7 +536,9 @@ export default {
|
||||||
return mode;
|
return mode;
|
||||||
},
|
},
|
||||||
getTaskRunning() {
|
getTaskRunning() {
|
||||||
this.initWebSocket();
|
if (this.condition.executor) {
|
||||||
|
this.initWebSocket();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
nextPage(currentPage, pageSize) {
|
nextPage(currentPage, pageSize) {
|
||||||
this.currentPage = currentPage;
|
this.currentPage = currentPage;
|
||||||
|
|
|
@ -301,6 +301,15 @@
|
||||||
<foreach collection="request.projects" item="id" separator="," open="(" close=")">
|
<foreach collection="request.projects" item="id" separator="," open="(" close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
<if test="request.userId != null and request.userId != ''">
|
||||||
|
and user_id = #{request.userId}
|
||||||
|
</if>
|
||||||
|
<if test="request.triggerMode != null and request.triggerMode != ''">
|
||||||
|
and trigger_mode = #{request.triggerMode}
|
||||||
|
</if>
|
||||||
|
<if test="request.executionStatus != null and request.executionStatus != ''">
|
||||||
|
and status = #{request.executionStatus}
|
||||||
|
</if>
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
|
@ -310,5 +319,14 @@
|
||||||
<foreach collection="request.projects" item="id" separator="," open="(" close=")">
|
<foreach collection="request.projects" item="id" separator="," open="(" close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
<if test="request.userId != null and request.userId != ''">
|
||||||
|
and user_id = #{request.userId}
|
||||||
|
</if>
|
||||||
|
<if test="request.triggerMode != null and request.triggerMode != ''">
|
||||||
|
and trigger_mode = #{request.triggerMode}
|
||||||
|
</if>
|
||||||
|
<if test="request.executionStatus != null and request.executionStatus != ''">
|
||||||
|
and status = #{request.executionStatus}
|
||||||
|
</if>
|
||||||
</update>
|
</update>
|
||||||
</mapper>
|
</mapper>
|
|
@ -8,5 +8,7 @@ public class TaskRequestDTO {
|
||||||
private String reportId;
|
private String reportId;
|
||||||
private String projectId;
|
private String projectId;
|
||||||
private String userId;
|
private String userId;
|
||||||
|
private String triggerMode;
|
||||||
|
private String executionStatus;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import io.metersphere.base.domain.FileMetadata;
|
||||||
import io.metersphere.base.domain.LoadTestReport;
|
import io.metersphere.base.domain.LoadTestReport;
|
||||||
import io.metersphere.base.domain.LoadTestReportWithBLOBs;
|
import io.metersphere.base.domain.LoadTestReportWithBLOBs;
|
||||||
import io.metersphere.dto.DashboardTestDTO;
|
import io.metersphere.dto.DashboardTestDTO;
|
||||||
import io.metersphere.dto.PlanReportCaseDTO;
|
|
||||||
import io.metersphere.dto.ReportDTO;
|
import io.metersphere.dto.ReportDTO;
|
||||||
import io.metersphere.request.ReportRequest;
|
import io.metersphere.request.ReportRequest;
|
||||||
|
import io.metersphere.task.dto.TaskRequestDTO;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -23,7 +23,7 @@ public interface ExtLoadTestReportMapper {
|
||||||
|
|
||||||
void updateJmxContentIfAbsent(LoadTestReportWithBLOBs record);
|
void updateJmxContentIfAbsent(LoadTestReportWithBLOBs record);
|
||||||
|
|
||||||
List<LoadTestReport> selectReportByProjectId(String projectId);
|
List<LoadTestReport> selectReportByProjectId(@Param("request") TaskRequestDTO request);
|
||||||
|
|
||||||
int updateReportVumStatus(String reportId, String reportKey, String nextStatus, String preStatus);
|
int updateReportVumStatus(String reportId, String reportKey, String nextStatus, String preStatus);
|
||||||
|
|
||||||
|
|
|
@ -227,9 +227,17 @@
|
||||||
left join `user` t1 ON t.user_id = t1.id
|
left join `user` t1 ON t.user_id = t1.id
|
||||||
left join test_resource_pool t2 on t.test_resource_pool_id = t2.id
|
left join test_resource_pool t2 on t.test_resource_pool_id = t2.id
|
||||||
where to_days(FROM_UNIXTIME(t.create_time / 1000)) = to_days(now())
|
where to_days(FROM_UNIXTIME(t.create_time / 1000)) = to_days(now())
|
||||||
and t.project_id = #{projectId}
|
and t.project_id = #{request.projectId}
|
||||||
and t.status = 'running'
|
and t.status in ("Running","Starting","Pending")
|
||||||
|
<if test="request.userId != null and request.userId != ''">
|
||||||
|
and t.user_id = #{request.userId}
|
||||||
|
</if>
|
||||||
|
<if test="request.triggerMode != null and request.triggerMode != ''">
|
||||||
|
and t.trigger_mode = #{request.triggerMode}
|
||||||
|
</if>
|
||||||
|
<if test="request.executionStatus != null and request.executionStatus != ''">
|
||||||
|
and t.status = #{request.executionStatus}
|
||||||
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="updateJmxContentIfAbsent">
|
<update id="updateJmxContentIfAbsent">
|
||||||
|
|
|
@ -973,7 +973,7 @@ public class PerformanceTestService {
|
||||||
if (StringUtils.isNotEmpty(taskRequestDTO.getReportId())) {
|
if (StringUtils.isNotEmpty(taskRequestDTO.getReportId())) {
|
||||||
this.stopTest(taskRequestDTO.getReportId(), false);
|
this.stopTest(taskRequestDTO.getReportId(), false);
|
||||||
} else {
|
} else {
|
||||||
List<LoadTestReport> loadTestReports = extLoadTestReportMapper.selectReportByProjectId(taskRequestDTO.getProjectId());
|
List<LoadTestReport> loadTestReports = extLoadTestReportMapper.selectReportByProjectId(taskRequestDTO);
|
||||||
loadTestReports.forEach(loadTestReport -> {
|
loadTestReports.forEach(loadTestReport -> {
|
||||||
this.stopTest(loadTestReport.getId(), false);
|
this.stopTest(loadTestReport.getId(), false);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue