解决异步执行线程卡住问题
This commit is contained in:
@@ -6,6 +6,7 @@ import com.test.common.core.domain.AjaxResult;
|
||||
import com.test.common.core.page.TableDataInfo;
|
||||
import com.test.common.enums.BusinessType;
|
||||
import com.test.common.utils.DateUtils;
|
||||
import com.test.common.utils.SecurityUtils;
|
||||
import com.test.common.utils.uuid.IdUtils;
|
||||
import com.test.test.domain.TestCase;
|
||||
import com.test.test.domain.TestPlanCase;
|
||||
@@ -127,6 +128,7 @@ public class TestCaseController extends BaseController {
|
||||
@PostMapping("/runTestPlanCase")
|
||||
public AjaxResult runTestPlanCase(@RequestBody TestPlanCase testPlanCase) {
|
||||
String caseSid = IdUtils.simpleUUID();
|
||||
testPlanCase.setExecuteBy(SecurityUtils.getUsername());
|
||||
// 异步执行任务
|
||||
CompletableFuture.runAsync(() -> {
|
||||
testCaseService.executeTestCaseByPlanCase(testPlanCase, jmeterHomePath, caseSid);
|
||||
|
||||
@@ -40,8 +40,8 @@ public class TestPlanCase extends BaseEntity
|
||||
private String executeResult;
|
||||
|
||||
/** 执行时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "执行时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "执行时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date executeTime;
|
||||
|
||||
/** 执行人 */
|
||||
|
||||
@@ -229,7 +229,7 @@ public class TestCaseServiceImpl implements ITestCaseService
|
||||
for (TestPlanCase input : testPlanCaseList) {
|
||||
boolean isSuccess = true;
|
||||
input.setExecuteTime(DateUtils.getNowDate());
|
||||
input.setExecuteBy(SecurityUtils.getUsername());
|
||||
input.setExecuteBy(testPlanCase.getExecuteBy());
|
||||
TestCase testCase = this.selectTestCaseById(input.getCaseId());
|
||||
Long id = input.getCaseId();
|
||||
Map<String, String> contextResultMap = new HashMap<>();
|
||||
@@ -290,13 +290,14 @@ public class TestCaseServiceImpl implements ITestCaseService
|
||||
}
|
||||
if (isSuccess) {
|
||||
testCaseLog.setOperDetail("成功");
|
||||
input.setExecuteResult("成功");
|
||||
input.setExecuteResult("1");
|
||||
} else {
|
||||
testCaseLog.setOperDetail("失败");
|
||||
input.setExecuteResult("失败");
|
||||
input.setExecuteResult("2");
|
||||
}
|
||||
testCaseLogMapper.insertTestCaseLog(testCaseLog);
|
||||
testPlanCaseMapper.updateTestPlanCase(input);
|
||||
System.out.println("111111111111111111111111");
|
||||
}
|
||||
testPlan.setUpdateTime(DateUtils.getNowDate());
|
||||
testPlan.setStatus("2");
|
||||
|
||||
Reference in New Issue
Block a user