fix(测试跟踪): 修复测试计划关联场景执行提示未选择环境的缺陷
--bug=1018843 --user=王孝刚 [测试跟踪]测试计划-关联场景用例后-列表中执行场景-提示未选运行环境 https://www.tapd.cn/55049933/s/1285306
This commit is contained in:
parent
4649e95a7d
commit
f890ce8735
|
@ -1,16 +1,16 @@
|
|||
package io.metersphere.api.dto.scenario.environment.item;
|
||||
|
||||
import io.metersphere.plugin.core.MsTestElement;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
@Data
|
||||
public class BaseEnvElement {
|
||||
// 组件类型
|
||||
private String type;
|
||||
|
||||
// 用于数据反射对象
|
||||
private String clazzName = MsTestElement.class.getCanonicalName();
|
||||
private String clazzName = BaseEnvElement.class.getCanonicalName();
|
||||
|
||||
// 自身资源ID(用例ID/接口ID/场景ID)等
|
||||
private String id;
|
||||
|
@ -39,7 +39,7 @@ public class BaseEnvElement {
|
|||
private String refType;
|
||||
|
||||
// 子组件
|
||||
private LinkedList<MsTestElement> hashTree;
|
||||
private LinkedList<BaseEnvElement> hashTree;
|
||||
|
||||
// 项目ID
|
||||
private String projectId;
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package io.metersphere.api.dto.scenario.environment.item;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class MsScenarioEnv {
|
||||
private String environmentId;
|
||||
private Map<String, String> environmentMap;
|
||||
}
|
|
@ -10,6 +10,7 @@ import io.metersphere.api.dto.definition.request.MsScenario;
|
|||
import io.metersphere.api.dto.definition.request.ParameterConfig;
|
||||
import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
|
||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||
import io.metersphere.api.dto.scenario.environment.item.MsScenarioEnv;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.ApiScenarioMapper;
|
||||
import io.metersphere.base.mapper.ApiTestCaseMapper;
|
||||
|
@ -172,6 +173,9 @@ public class ApiScenarioEnvService {
|
|||
environmentType = EnvironmentType.JSON.toString();
|
||||
}
|
||||
String definition = apiScenarioWithBLOBs.getScenarioDefinition();
|
||||
JSONObject element = JSONUtil.parseObject(definition);
|
||||
ElementUtil.dataFormatting(element);
|
||||
definition = element.toString();
|
||||
MsScenario scenario = JSON.parseObject(definition, MsScenario.class);
|
||||
GenerateHashTreeUtil.parse(definition, scenario);
|
||||
if (StringUtils.equals(environmentType, EnvironmentType.JSON.toString()) && StringUtils.isNotEmpty(environmentJson)) {
|
||||
|
@ -189,7 +193,7 @@ public class ApiScenarioEnvService {
|
|||
public boolean verifyScenarioEnv(ApiScenarioWithBLOBs apiScenarioWithBLOBs) {
|
||||
if (apiScenarioWithBLOBs != null) {
|
||||
String definition = apiScenarioWithBLOBs.getScenarioDefinition();
|
||||
MsScenario scenario = JSON.parseObject(definition, MsScenario.class);
|
||||
MsScenarioEnv scenario = JSON.parseObject(definition, MsScenarioEnv.class);
|
||||
Map<String, String> envMap = scenario.getEnvironmentMap();
|
||||
return this.check(definition, envMap, scenario.getEnvironmentId(), apiScenarioWithBLOBs.getProjectId());
|
||||
}
|
||||
|
@ -250,7 +254,7 @@ public class ApiScenarioEnvService {
|
|||
public boolean verifyPlanScenarioEnv(ApiScenarioWithBLOBs apiScenarioWithBLOBs, TestPlanApiScenario testPlanApiScenarios) {
|
||||
if (apiScenarioWithBLOBs != null) {
|
||||
String definition = apiScenarioWithBLOBs.getScenarioDefinition();
|
||||
MsScenario scenario = JSON.parseObject(definition, MsScenario.class);
|
||||
MsScenarioEnv scenario = JSON.parseObject(definition, MsScenarioEnv.class);
|
||||
Map<String, String> envMap = scenario.getEnvironmentMap();
|
||||
if (testPlanApiScenarios != null) {
|
||||
String envType = testPlanApiScenarios.getEnvironmentType();
|
||||
|
|
|
@ -186,7 +186,7 @@ public class JMeterService {
|
|||
public void run(JmeterRunRequestDTO request) {
|
||||
if (request.getPool().isPool() && StringUtils.isNotBlank(request.getRunMode())) {
|
||||
this.runNode(request);
|
||||
} else {
|
||||
} else if (request.getHashTree() != null) {
|
||||
//解析hashTree,是否含有文件库文件
|
||||
HashTreeUtil.initRepositoryFiles(request);
|
||||
CommonBeanFactory.getBean(ExecThreadPoolExecutor.class).addTask(request);
|
||||
|
|
|
@ -10,18 +10,21 @@ import io.metersphere.api.dto.definition.request.*;
|
|||
import io.metersphere.api.dto.definition.request.variable.ScenarioVariable;
|
||||
import io.metersphere.api.jmeter.NewDriverManager;
|
||||
import io.metersphere.api.jmeter.ResourcePoolCalculation;
|
||||
import io.metersphere.base.domain.TestResource;
|
||||
import io.metersphere.service.ApiExecutionQueueService;
|
||||
import io.metersphere.service.RemakeReportService;
|
||||
import io.metersphere.commons.constants.ElementConstants;
|
||||
import io.metersphere.environment.service.BaseEnvGroupProjectService;
|
||||
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
|
||||
import io.metersphere.base.domain.TestResource;
|
||||
import io.metersphere.base.domain.TestResourcePool;
|
||||
import io.metersphere.base.mapper.TestResourcePoolMapper;
|
||||
import io.metersphere.commons.constants.ElementConstants;
|
||||
import io.metersphere.commons.constants.ResourcePoolTypeEnum;
|
||||
import io.metersphere.constants.RunModeConstants;
|
||||
import io.metersphere.dto.*;
|
||||
import io.metersphere.dto.BaseSystemConfigDTO;
|
||||
import io.metersphere.dto.JmeterRunRequestDTO;
|
||||
import io.metersphere.dto.ResultDTO;
|
||||
import io.metersphere.dto.RunModeConfigDTO;
|
||||
import io.metersphere.environment.service.BaseEnvGroupProjectService;
|
||||
import io.metersphere.plugin.core.MsTestElement;
|
||||
import io.metersphere.service.ApiExecutionQueueService;
|
||||
import io.metersphere.service.RemakeReportService;
|
||||
import io.metersphere.utils.LoggerUtil;
|
||||
import io.metersphere.vo.BooleanPool;
|
||||
import io.metersphere.xpack.api.service.ApiRetryOnFailureService;
|
||||
|
@ -139,14 +142,17 @@ public class GenerateHashTreeUtil {
|
|||
MsThreadGroup group = new MsThreadGroup();
|
||||
group.setLabel(item.getName());
|
||||
group.setName(runRequest.getReportId());
|
||||
MsScenario scenario = JSON.parseObject(item.getScenarioDefinition(), MsScenario.class);
|
||||
JSONObject element = JSONUtil.parseObject(item.getScenarioDefinition());
|
||||
ElementUtil.dataFormatting(element);
|
||||
String definition = element.toString();
|
||||
MsScenario scenario = JSON.parseObject(definition, MsScenario.class);
|
||||
group.setOnSampleError(scenario.getOnSampleError());
|
||||
if (planEnvMap != null && planEnvMap.size() > 0) {
|
||||
scenario.setEnvironmentMap(planEnvMap);
|
||||
} else {
|
||||
setScenarioEnv(scenario, item);
|
||||
}
|
||||
String data = item.getScenarioDefinition();
|
||||
String data = definition;
|
||||
// 失败重试
|
||||
if (runRequest.isRetryEnable() && runRequest.getRetryNum() > 0) {
|
||||
ApiRetryOnFailureService apiRetryOnFailureService = CommonBeanFactory.getBean(ApiRetryOnFailureService.class);
|
||||
|
@ -172,6 +178,7 @@ public class GenerateHashTreeUtil {
|
|||
} catch (Exception ex) {
|
||||
remakeException(runRequest);
|
||||
LoggerUtil.error("场景资源:" + item.getName() + ", 生成执行脚本失败", runRequest.getReportId(), ex);
|
||||
return null;
|
||||
}
|
||||
|
||||
LogUtil.info(testPlan.getJmx(jmeterHashTree));
|
||||
|
|
Loading…
Reference in New Issue