fix(测试跟踪): 修复测试计划场景使用环境组时执行测试计划所选环境不对的问题
--bug=1015251 --user=宋天阳 【测试跟踪】多次切换环境后,在测试计划详情里和报告列表查看测试报告,显示的环境不一样 https://www.tapd.cn/55049933/s/1209606
This commit is contained in:
parent
ff61886ea9
commit
50d33f9521
|
@ -5,19 +5,35 @@
|
||||||
|
|
||||||
<insert id="insertIfNotExists" parameterType="io.metersphere.base.domain.TestPlanApiScenario">
|
<insert id="insertIfNotExists" parameterType="io.metersphere.base.domain.TestPlanApiScenario">
|
||||||
-- 查询没有数据再插入
|
-- 查询没有数据再插入
|
||||||
INSERT INTO test_plan_api_scenario(id, test_plan_id, api_scenario_id, create_time, update_time, environment, `order`, environment_group_id, environment_type)
|
INSERT INTO test_plan_api_scenario(id, test_plan_id, api_scenario_id, create_time, update_time, environment,
|
||||||
SELECT #{request.id}, #{request.testPlanId}, #{request.apiScenarioId}, #{request.createTime}, #{request.updateTime}, #{request.environment}, #{request.order}, #{request.environmentGroupId}, #{request.environmentType}
|
`order`, environment_group_id, environment_type)
|
||||||
|
SELECT #{request.id},
|
||||||
|
#{request.testPlanId},
|
||||||
|
#{request.apiScenarioId},
|
||||||
|
#{request.createTime},
|
||||||
|
#{request.updateTime},
|
||||||
|
#{request.environment},
|
||||||
|
#{request.order},
|
||||||
|
#{request.environmentGroupId},
|
||||||
|
#{request.environmentType}
|
||||||
FROM DUAL
|
FROM DUAL
|
||||||
WHERE NOT EXISTS(
|
WHERE NOT EXISTS(
|
||||||
SELECT id FROM
|
SELECT id
|
||||||
test_plan_api_scenario
|
FROM test_plan_api_scenario
|
||||||
WHERE test_plan_id = #{request.testPlanId} and api_scenario_id = #{request.apiScenarioId}
|
WHERE test_plan_id = #{request.testPlanId}
|
||||||
|
and api_scenario_id = #{request.apiScenarioId}
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<select id="selectLegalDataByTestPlanId" resultType="io.metersphere.track.dto.testplan.TestPlanApiScenarioInfoDTO">
|
<select id="selectLegalDataByTestPlanId" resultType="io.metersphere.track.dto.testplan.TestPlanApiScenarioInfoDTO">
|
||||||
SELECT tpas.id, tpas.api_scenario_id,tpas.environment,apis.project_id FROM
|
SELECT tpas.id,
|
||||||
test_plan_api_scenario tpas INNER JOIN api_scenario apis ON tpas.api_scenario_id = apis.id
|
tpas.api_scenario_id,
|
||||||
|
tpas.environment,
|
||||||
|
tpas.environment_type,
|
||||||
|
tpas.environment_group_id,
|
||||||
|
apis.project_id
|
||||||
|
FROM test_plan_api_scenario tpas
|
||||||
|
INNER JOIN api_scenario apis ON tpas.api_scenario_id = apis.id
|
||||||
WHERE (apis.`status` IS NULL OR apis.`status` != 'Trash')
|
WHERE (apis.`status` IS NULL OR apis.`status` != 'Trash')
|
||||||
AND tpas.test_plan_id = #{0}
|
AND tpas.test_plan_id = #{0}
|
||||||
ORDER BY tpas.`order` DESC;
|
ORDER BY tpas.`order` DESC;
|
||||||
|
@ -117,7 +133,10 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectByIds" resultType="io.metersphere.base.domain.TestPlanApiScenario">
|
<select id="selectByIds" resultType="io.metersphere.base.domain.TestPlanApiScenario">
|
||||||
select t.* from test_plan_api_scenario t where t.id in (${ids}) ORDER BY FIND_IN_SET(t.id,${oderId})
|
select t.*
|
||||||
|
from test_plan_api_scenario t
|
||||||
|
where t.id in (${ids})
|
||||||
|
ORDER BY FIND_IN_SET(t.id, ${oderId})
|
||||||
</select>
|
</select>
|
||||||
<select id="selectIds" resultType="java.lang.String">
|
<select id="selectIds" resultType="java.lang.String">
|
||||||
select
|
select
|
||||||
|
@ -207,8 +226,7 @@
|
||||||
|
|
||||||
<select id="getExecResultByPlanId" resultType="java.lang.String">
|
<select id="getExecResultByPlanId" resultType="java.lang.String">
|
||||||
select last_result
|
select last_result
|
||||||
from
|
from test_plan_api_scenario
|
||||||
test_plan_api_scenario
|
|
||||||
where test_plan_id = #{planId}
|
where test_plan_id = #{planId}
|
||||||
AND api_scenario_id in (SELECT id FROM api_scenario WHERE (`status` is null or `status` != 'Trash'))
|
AND api_scenario_id in (SELECT id FROM api_scenario WHERE (`status` is null or `status` != 'Trash'))
|
||||||
</select>
|
</select>
|
||||||
|
@ -232,9 +250,15 @@
|
||||||
where t.test_plan_id = #{planId}
|
where t.test_plan_id = #{planId}
|
||||||
</select>
|
</select>
|
||||||
<select id="selectForPlanReport" resultType="io.metersphere.track.dto.PlanReportCaseDTO">
|
<select id="selectForPlanReport" resultType="io.metersphere.track.dto.PlanReportCaseDTO">
|
||||||
select id,last_result as status, report_id, api_scenario_id as caseId from test_plan_api_scenario where test_plan_id = #{planId}
|
select id, last_result as status, report_id, api_scenario_id as caseId
|
||||||
|
from test_plan_api_scenario
|
||||||
|
where test_plan_id = #{planId}
|
||||||
and api_scenario_id IN (
|
and api_scenario_id IN (
|
||||||
SELECT id FROM api_scenario where status is null or status != 'Trash'
|
SELECT id
|
||||||
|
FROM api_scenario
|
||||||
|
where status is null
|
||||||
|
or status
|
||||||
|
!= 'Trash'
|
||||||
)
|
)
|
||||||
</select>
|
</select>
|
||||||
<select id="getFailureList" resultType="io.metersphere.api.dto.automation.TestPlanFailureScenarioDTO">
|
<select id="getFailureList" resultType="io.metersphere.api.dto.automation.TestPlanFailureScenarioDTO">
|
||||||
|
@ -290,16 +314,24 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getProjectIdById" resultType="java.lang.String">
|
<select id="getProjectIdById" resultType="java.lang.String">
|
||||||
SELECT project_id FROM test_plan WHERE id in (
|
SELECT project_id
|
||||||
SELECT test_plan_id FROM test_plan_api_scenario WHERE id = #{0}
|
FROM test_plan
|
||||||
|
WHERE id in (
|
||||||
|
SELECT test_plan_id
|
||||||
|
FROM test_plan_api_scenario
|
||||||
|
WHERE id = #{0}
|
||||||
)
|
)
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectPlanIds" resultType="java.lang.String">
|
<select id="selectPlanIds" resultType="java.lang.String">
|
||||||
select DISTINCT test_plan_id from test_plan_api_scenario;
|
select DISTINCT test_plan_id
|
||||||
|
from test_plan_api_scenario;
|
||||||
</select>
|
</select>
|
||||||
<select id="getIdsOrderByUpdateTime" resultType="java.lang.String">
|
<select id="getIdsOrderByUpdateTime" resultType="java.lang.String">
|
||||||
select id from test_plan_api_scenario where test_plan_id = #{planId} order by update_time ASC;
|
select id
|
||||||
|
from test_plan_api_scenario
|
||||||
|
where test_plan_id = #{planId}
|
||||||
|
order by update_time ASC;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getLastOrder" resultType="java.lang.Long">
|
<select id="getLastOrder" resultType="java.lang.Long">
|
||||||
|
|
|
@ -10,4 +10,6 @@ public class TestPlanApiScenarioInfoDTO {
|
||||||
private String apiScenarioId;
|
private String apiScenarioId;
|
||||||
private String environment;
|
private String environment;
|
||||||
private String projectId;
|
private String projectId;
|
||||||
|
private String environmentType;
|
||||||
|
private String environmentGroupId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,11 +299,20 @@ public class TestPlanReportService {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (TestPlanApiScenarioInfoDTO model : testPlanApiScenarioList) {
|
for (TestPlanApiScenarioInfoDTO model : testPlanApiScenarioList) {
|
||||||
|
Map<String, String> envMap = null;
|
||||||
|
if (StringUtils.equalsIgnoreCase("group", model.getEnvironmentType()) && StringUtils.isNotEmpty(model.getEnvironmentGroupId())) {
|
||||||
|
envMap = environmentGroupProjectService.getEnvMap(model.getEnvironmentGroupId());
|
||||||
|
} else {
|
||||||
if (MapUtils.isNotEmpty(selectEnvMap) && selectEnvMap.containsKey(model.getProjectId())) {
|
if (MapUtils.isNotEmpty(selectEnvMap) && selectEnvMap.containsKey(model.getProjectId())) {
|
||||||
runInfoDTO.putScenarioRunInfo(model.getId(), model.getProjectId(), selectEnvMap.get(model.getProjectId()));
|
runInfoDTO.putScenarioRunInfo(model.getId(), model.getProjectId(), selectEnvMap.get(model.getProjectId()));
|
||||||
} else if (StringUtils.isNotEmpty(model.getEnvironment())) {
|
} else if (StringUtils.isNotEmpty(model.getEnvironment())) {
|
||||||
try {
|
try {
|
||||||
Map<String, String> envMap = JSONObject.parseObject(model.getEnvironment(), Map.class);
|
envMap = JSONObject.parseObject(model.getEnvironment(), Map.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.error("解析场景环境失败!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (MapUtils.isNotEmpty(envMap)) {
|
if (MapUtils.isNotEmpty(envMap)) {
|
||||||
for (Map.Entry<String, String> entry : envMap.entrySet()) {
|
for (Map.Entry<String, String> entry : envMap.entrySet()) {
|
||||||
String projectId = entry.getKey();
|
String projectId = entry.getKey();
|
||||||
|
@ -311,9 +320,6 @@ public class TestPlanReportService {
|
||||||
runInfoDTO.putScenarioRunInfo(model.getId(), projectId, envIdStr);
|
runInfoDTO.putScenarioRunInfo(model.getId(), projectId, envIdStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ignore) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (TestPlanApiCaseInfoDTO model : testPlanApiCaseList) {
|
for (TestPlanApiCaseInfoDTO model : testPlanApiCaseList) {
|
||||||
if (MapUtils.isNotEmpty(selectEnvMap) && selectEnvMap.containsKey(model.getProjectId())) {
|
if (MapUtils.isNotEmpty(selectEnvMap) && selectEnvMap.containsKey(model.getProjectId())) {
|
||||||
|
|
Loading…
Reference in New Issue