refactor(接口测试): 优化场景校验环境
--bug=1026626 --user=王孝刚 [接口测试]GitHub#24694场景加载环境报错,无法调试 (特殊数据) https://www.tapd.cn/55049933/s/1378398
This commit is contained in:
parent
e5a246bfc9
commit
cf4ca36b97
|
@ -133,9 +133,6 @@ public class ApiExecuteService {
|
||||||
: request.getReportId(), request.getRunMode(), null);
|
: request.getReportId(), request.getRunMode(), null);
|
||||||
if (testCase != null && StringUtils.isNotEmpty(testCase.getRequest())) {
|
if (testCase != null && StringUtils.isNotEmpty(testCase.getRequest())) {
|
||||||
try {
|
try {
|
||||||
HashTree jmeterHashTree = this.generateHashTree(request, testCase, runModeConfigDTO);
|
|
||||||
// 调用执行方法
|
|
||||||
runRequest.setHashTree(jmeterHashTree);
|
|
||||||
if (MapUtils.isNotEmpty(extendedParameters)) {
|
if (MapUtils.isNotEmpty(extendedParameters)) {
|
||||||
runRequest.setExtendedParameters(extendedParameters);
|
runRequest.setExtendedParameters(extendedParameters);
|
||||||
}
|
}
|
||||||
|
|
|
@ -801,16 +801,20 @@ public class ApiScenarioService {
|
||||||
|
|
||||||
public ParameterConfig getConfig(ApiScenarioDTO scenario) {
|
public ParameterConfig getConfig(ApiScenarioDTO scenario) {
|
||||||
try {
|
try {
|
||||||
|
ParameterConfig config = new ParameterConfig();
|
||||||
Map<String, String> environmentMap = new HashMap<>();
|
Map<String, String> environmentMap = new HashMap<>();
|
||||||
String environmentType = scenario.getEnvironmentType();
|
String environmentType = scenario.getEnvironmentType();
|
||||||
String environmentGroupId = scenario.getEnvironmentGroupId();
|
String environmentGroupId = scenario.getEnvironmentGroupId();
|
||||||
String environmentJson = scenario.getEnvironmentJson();
|
String environmentJson = scenario.getEnvironmentJson();
|
||||||
if (StringUtils.equals(environmentType, EnvironmentType.GROUP.name())) {
|
if (StringUtils.equals(environmentType, EnvironmentType.GROUP.name())
|
||||||
|
&& StringUtils.isNotEmpty(environmentGroupId)) {
|
||||||
environmentMap = environmentGroupProjectService.getEnvMap(environmentGroupId);
|
environmentMap = environmentGroupProjectService.getEnvMap(environmentGroupId);
|
||||||
} else if (StringUtils.equals(environmentType, EnvironmentType.JSON.name())) {
|
} else if (StringUtils.equals(environmentType, EnvironmentType.JSON.name())
|
||||||
|
&& StringUtils.isNotEmpty(environmentJson)) {
|
||||||
environmentMap = JSON.parseObject(environmentJson, Map.class);
|
environmentMap = JSON.parseObject(environmentJson, Map.class);
|
||||||
|
} else {
|
||||||
|
return config;
|
||||||
}
|
}
|
||||||
ParameterConfig config = new ParameterConfig();
|
|
||||||
apiScenarioEnvService.setEnvConfig(environmentMap, config);
|
apiScenarioEnvService.setEnvConfig(environmentMap, config);
|
||||||
return config;
|
return config;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -103,8 +103,20 @@ export function listWithIds(params) {
|
||||||
return post('/api/automation/list-blobs', params);
|
return post('/api/automation/list-blobs', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getUploadConfig(url, formData) {
|
||||||
|
return {
|
||||||
|
method: 'POST',
|
||||||
|
url: url,
|
||||||
|
data: formData,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': "application/octet-stream",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function getApiScenarioEnv(params) {
|
export function getApiScenarioEnv(params) {
|
||||||
return post('/api/automation/scenario-env', params);
|
let reqParams = getUploadConfig('/api/automation/scenario-env', params);
|
||||||
|
return request( reqParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function batchEditScenario(params) {
|
export function batchEditScenario(params) {
|
||||||
|
|
|
@ -1965,7 +1965,7 @@ export default {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const bytes = encoder.encode(definition, 'utf-8');
|
const bytes = encoder.encode(definition, 'utf-8');
|
||||||
getApiScenarioEnv({ definition: bytes }).then((res) => {
|
getApiScenarioEnv(bytes ).then((res) => {
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
this.projectIds = new Set(res.data.projectIds);
|
this.projectIds = new Set(res.data.projectIds);
|
||||||
this.projectIds.add(this.projectId);
|
this.projectIds.add(this.projectId);
|
||||||
|
|
Loading…
Reference in New Issue