fix(测试跟踪): 测试计划性能测试定时任务未执行

--bug=1012775 --user=李玉号 【测试跟踪】测试计划关联性能测试,设置定时任务,执行完没生成测试报告
https://www.tapd.cn/55049933/s/1148393
This commit is contained in:
shiziyuan9527 2022-04-26 17:34:27 +08:00 committed by shiziyuan9527
parent cdc3f6b9d6
commit e635eaea4e
5 changed files with 10 additions and 9 deletions

View File

@ -171,7 +171,7 @@ public class ApiScenarioImportUtil {
public static ApiDefinitionResult structureApiDefinitionByJson(int i,ApiDefinitionService apiDefinitionService,JSONObject object, String versionId, String projectId,ApiDefinitionMapper apiDefinitionMapper,Map<String,ApiDefinition>definitionMap) { public static ApiDefinitionResult structureApiDefinitionByJson(int i,ApiDefinitionService apiDefinitionService,JSONObject object, String versionId, String projectId,ApiDefinitionMapper apiDefinitionMapper,Map<String,ApiDefinition>definitionMap) {
ApiDefinitionResult test = new ApiDefinitionResult(); ApiDefinitionResult test = new ApiDefinitionResult();
apiDefinitionService.checkQuota(); apiDefinitionService.checkQuota(projectId);
String protocal = object.getString("protocal"); String protocal = object.getString("protocal");
if (StringUtils.equals(protocal, "DUBBO")) { if (StringUtils.equals(protocal, "DUBBO")) {
test.setMethod("dubbo://"); test.setMethod("dubbo://");

View File

@ -236,7 +236,7 @@ public class ApiAutomationService {
} }
public ApiScenario create(SaveApiScenarioRequest request, List<MultipartFile> bodyFiles, List<MultipartFile> scenarioFiles) { public ApiScenario create(SaveApiScenarioRequest request, List<MultipartFile> bodyFiles, List<MultipartFile> scenarioFiles) {
checkQuota(); checkQuota(request.getProjectId());
request.setId(UUID.randomUUID().toString()); request.setId(UUID.randomUUID().toString());
if (request.getScenarioDefinition() == null) { if (request.getScenarioDefinition() == null) {
MsScenario msScenario = new MsScenario(); MsScenario msScenario = new MsScenario();
@ -272,10 +272,10 @@ public class ApiAutomationService {
return scenario; return scenario;
} }
private void checkQuota() { private void checkQuota(String projectId) {
QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class); QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class);
if (quotaService != null) { if (quotaService != null) {
quotaService.checkAPIAutomationQuota(); quotaService.checkAPIAutomationQuota(projectId);
} }
} }

View File

@ -319,7 +319,7 @@ public class ApiDefinitionService {
} }
public ApiDefinitionWithBLOBs create(SaveApiDefinitionRequest request, List<MultipartFile> bodyFiles) { public ApiDefinitionWithBLOBs create(SaveApiDefinitionRequest request, List<MultipartFile> bodyFiles) {
checkQuota(); checkQuota(request.getProjectId());
if (StringUtils.equals(request.getProtocol(), "DUBBO")) { if (StringUtils.equals(request.getProtocol(), "DUBBO")) {
request.setMethod("dubbo://"); request.setMethod("dubbo://");
} }
@ -348,10 +348,10 @@ public class ApiDefinitionService {
return getBLOBs(returnModel.getId()); return getBLOBs(returnModel.getId());
} }
public void checkQuota() { public void checkQuota(String projectId) {
QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class); QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class);
if (quotaService != null) { if (quotaService != null) {
quotaService.checkAPIDefinitionQuota(); quotaService.checkAPIDefinitionQuota(projectId);
} }
} }

View File

@ -536,6 +536,7 @@ public class PerformanceTestService {
RunTestPlanRequest checkRequest = new RunTestPlanRequest(); RunTestPlanRequest checkRequest = new RunTestPlanRequest();
QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class); QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class);
checkRequest.setLoadConfiguration(testReport.getLoadConfiguration()); checkRequest.setLoadConfiguration(testReport.getLoadConfiguration());
checkRequest.setProjectId(testReport.getProjectId());
if (quotaService != null) { if (quotaService != null) {
quotaService.checkLoadTestQuota(checkRequest, false); quotaService.checkLoadTestQuota(checkRequest, false);
String projectId = testReport.getProjectId(); String projectId = testReport.getProjectId();

View File

@ -17,12 +17,12 @@ public interface QuotaService {
/** /**
* api配额检查 * api配额检查
*/ */
void checkAPIDefinitionQuota(); void checkAPIDefinitionQuota(String projectId);
/** /**
* api配额检查 * api配额检查
*/ */
void checkAPIAutomationQuota(); void checkAPIAutomationQuota(String projectId);
/** /**
* 性能测试配额检查 * 性能测试配额检查