Merge remote-tracking branch 'origin/master' into master

# Conflicts:
#	backend/src/main/java/io/metersphere/xpack
This commit is contained in:
Captain.B 2020-11-05 15:18:12 +08:00
commit ff6015754a
9 changed files with 51 additions and 29 deletions

View File

@ -104,9 +104,8 @@ public class APITestController {
@PostMapping("/delete") @PostMapping("/delete")
public void delete(@RequestBody DeleteAPITestRequest request) { public void delete(@RequestBody DeleteAPITestRequest request) {
String testId = request.getId(); checkownerService.checkApiTestOwner(request.getId());
checkownerService.checkApiTestOwner(testId); apiTestService.delete(request);
apiTestService.delete(testId);
} }
@PostMapping(value = "/run") @PostMapping(value = "/run")

View File

@ -8,4 +8,8 @@ import lombok.Setter;
public class DeleteAPITestRequest { public class DeleteAPITestRequest {
private String id; private String id;
/**
* 是否强制删除删除项目时不检查关联关系强制删除资源
*/
private boolean forceDelete = false;
} }

View File

@ -193,8 +193,11 @@ public class APITestService {
return extApiTestMapper.getApiTestByProjectId(projectId); return extApiTestMapper.getApiTestByProjectId(projectId);
} }
public void delete(String testId) { public void delete(DeleteAPITestRequest request) {
testCaseService.checkIsRelateTest(testId); String testId = request.getId();
if (!request.isForceDelete()) {
testCaseService.checkIsRelateTest(testId);
}
deleteFileByTestId(testId); deleteFileByTestId(testId);
apiReportService.deleteByTestId(testId); apiReportService.deleteByTestId(testId);
scheduleService.deleteByResourceId(testId); scheduleService.deleteByResourceId(testId);

View File

@ -47,27 +47,26 @@ public class PerformanceNoticeTask {
} }
public void registerNoticeTask(LoadTestReportWithBLOBs loadTestReport) { public void registerNoticeTask(LoadTestReportWithBLOBs loadTestReport) {
executorService.submit(() -> { int count = 20;
while (isRunning) { while (count-- > 0) {
LoadTestReportWithBLOBs loadTestReportFromDatabase = loadTestReportMapper.selectByPrimaryKey(loadTestReport.getId()); LoadTestReportWithBLOBs loadTestReportFromDatabase = loadTestReportMapper.selectByPrimaryKey(loadTestReport.getId());
if (StringUtils.equals(loadTestReportFromDatabase.getStatus(), PerformanceTestStatus.Completed.name())) {
if (StringUtils.equals(loadTestReportFromDatabase.getStatus(), PerformanceTestStatus.Completed.name())) { isRunning = false;
isRunning = false; sendSuccessNotice(loadTestReportFromDatabase);
sendSuccessNotice(loadTestReportFromDatabase); return;
return;
}
if (StringUtils.equals(loadTestReportFromDatabase.getStatus(), PerformanceTestStatus.Error.name())) {
isRunning = false;
sendFailNotice(loadTestReportFromDatabase);
return;
}
try {
Thread.sleep(1000 * 60);// 每分钟检查 loadtest 的状态
} catch (InterruptedException e) {
LogUtil.error(e);
}
} }
}); if (StringUtils.equals(loadTestReportFromDatabase.getStatus(), PerformanceTestStatus.Error.name())) {
isRunning = false;
sendFailNotice(loadTestReportFromDatabase);
return;
}
count--;
try {
Thread.sleep(1000 * 4L);// 每分钟检查 loadtest 的状态
} catch (InterruptedException e) {
LogUtil.error(e);
}
}
} }
public void sendSuccessNotice(LoadTestReportWithBLOBs loadTestReport) { public void sendSuccessNotice(LoadTestReportWithBLOBs loadTestReport) {

View File

@ -85,7 +85,9 @@ public class PerformanceTestService {
public void delete(DeleteTestPlanRequest request) { public void delete(DeleteTestPlanRequest request) {
String testId = request.getId(); String testId = request.getId();
testCaseService.checkIsRelateTest(testId); if (!request.isForceDelete()) {
testCaseService.checkIsRelateTest(testId);
}
LoadTestReportExample loadTestReportExample = new LoadTestReportExample(); LoadTestReportExample loadTestReportExample = new LoadTestReportExample();
loadTestReportExample.createCriteria().andTestIdEqualTo(testId); loadTestReportExample.createCriteria().andTestIdEqualTo(testId);

View File

@ -1,5 +1,6 @@
package io.metersphere.service; package io.metersphere.service;
import io.metersphere.api.dto.DeleteAPITestRequest;
import io.metersphere.api.dto.QueryAPITestRequest; import io.metersphere.api.dto.QueryAPITestRequest;
import io.metersphere.api.service.APITestService; import io.metersphere.api.service.APITestService;
import io.metersphere.base.domain.LoadTest; import io.metersphere.base.domain.LoadTest;
@ -96,6 +97,7 @@ public class ProjectService {
loadTestIdList.forEach(loadTestId -> { loadTestIdList.forEach(loadTestId -> {
DeleteTestPlanRequest deleteTestPlanRequest = new DeleteTestPlanRequest(); DeleteTestPlanRequest deleteTestPlanRequest = new DeleteTestPlanRequest();
deleteTestPlanRequest.setId(loadTestId); deleteTestPlanRequest.setId(loadTestId);
deleteTestPlanRequest.setForceDelete(true);
performanceTestService.delete(deleteTestPlanRequest); performanceTestService.delete(deleteTestPlanRequest);
}); });
@ -122,7 +124,10 @@ public class ProjectService {
QueryAPITestRequest request = new QueryAPITestRequest(); QueryAPITestRequest request = new QueryAPITestRequest();
request.setProjectId(projectId); request.setProjectId(projectId);
apiTestService.list(request).forEach(test -> { apiTestService.list(request).forEach(test -> {
apiTestService.delete(test.getId()); DeleteAPITestRequest deleteAPITestRequest = new DeleteAPITestRequest();
deleteAPITestRequest.setId(test.getId());
deleteAPITestRequest.setForceDelete(true);
apiTestService.delete(deleteAPITestRequest);
}); });
} }

View File

@ -1,4 +1,13 @@
package io.metersphere.track.request.testplan; package io.metersphere.track.request.testplan;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class DeleteTestPlanRequest extends TestPlanRequest { public class DeleteTestPlanRequest extends TestPlanRequest {
/**
* 是否强制删除删除项目时不检查关联关系强制删除资源
*/
private boolean forceDelete = false;
} }

View File

@ -368,8 +368,9 @@ export default {
} }
], ],
phone: [ phone: [
{required: true, message: this.$t('user.input_phone'), trigger: 'blur'},
{ {
required: false, required: true,
pattern: '^1(3|4|5|7|8)\\d{9}$', pattern: '^1(3|4|5|7|8)\\d{9}$',
message: this.$t('user.mobile_number_format_is_incorrect'), message: this.$t('user.mobile_number_format_is_incorrect'),
trigger: 'blur' trigger: 'blur'

@ -1 +1 @@
Subproject commit b9091a47b197faef77c72b134b7cf604fe3209f0 Subproject commit f6f172c6451d0f9c51f5e3246a66dde9edcd7a5d