fix(测试跟踪): 修复更改运行方式引发的执行测试计划执行问题

--bug=1026384 --user=宋天阳
【测试跟踪】项目设置资源池禁用-测试计划选择node或k8s资源池执行-测试报告显示仍为local资源池执行
https://www.tapd.cn/55049933/s/1374000;--bug=1026386 --user=宋天阳
【测试跟踪】项目设置资源池禁用-选择资源池保存并执行-再次点开运行资源池配置显示为空
https://www.tapd.cn/55049933/s/1373999
This commit is contained in:
song-tianyang 2023-05-22 17:28:57 +08:00 committed by fit2-zhao
parent e2c5207bce
commit 67f34ff496
2 changed files with 26 additions and 28 deletions

View File

@ -159,6 +159,8 @@ public class TestPlanService {
@Resource @Resource
@Lazy @Lazy
private TestPlanService testPlanService; private TestPlanService testPlanService;
@Resource
private BaseTestResourcePoolService baseTestResourcePoolService;
public TestPlan addTestPlan(AddTestPlanRequest testPlan) { public TestPlan addTestPlan(AddTestPlanRequest testPlan) {
if (getTestPlanByName(testPlan.getName()).size() > 0) { if (getTestPlanByName(testPlan.getName()).size() > 0) {
@ -936,9 +938,17 @@ public class TestPlanService {
} }
public void verifyPool(String projectId, RunModeConfigDTO runConfig) { public void verifyPool(String projectId, RunModeConfigDTO runConfig) {
if (StringUtils.isNotBlank(runConfig.getResourcePoolId())) {
//检查保存的资源池的合法性
TestResourcePool testResourcePool = baseTestResourcePoolService.getResourcePool(runConfig.getResourcePoolId());
if (!StringUtils.equalsIgnoreCase(testResourcePool.getStatus(), "VALID")) {
MSException.throwException("保存的资源池无法使用,请重新选择资源池");
}
} else {
// 检查是否禁用了本地执行 // 检查是否禁用了本地执行
apiPoolDebugService.verifyPool(projectId, runConfig); apiPoolDebugService.verifyPool(projectId, runConfig);
} }
}
/** /**
* 将测试计划运行时的triggerMode转化为性能测试中辨别更明确的值 * 将测试计划运行时的triggerMode转化为性能测试中辨别更明确的值
@ -1859,11 +1869,6 @@ public class TestPlanService {
RunModeConfigDTO runModeConfig = getRunModeConfigDTO(testplanRunRequest, envType, envMap, environmentGroupId, testPlanId); RunModeConfigDTO runModeConfig = getRunModeConfigDTO(testplanRunRequest, envType, envMap, environmentGroupId, testPlanId);
runModeConfig.setTestPlanDefaultEnvMap(testplanRunRequest.getTestPlanDefaultEnvMap()); runModeConfig.setTestPlanDefaultEnvMap(testplanRunRequest.getTestPlanDefaultEnvMap());
if (!testplanRunRequest.isRunWithinResourcePool()) {
//未勾选资源池运行时将资源池ID赋空
runModeConfig.setResourcePoolId(null);
}
//执行测试计划行为要更新TestPlan状态为进行中并重置实际结束时间 //执行测试计划行为要更新TestPlan状态为进行中并重置实际结束时间
this.updateTestPlanExecuteInfo(testPlanId, TestPlanStatus.Underway.name()); this.updateTestPlanExecuteInfo(testPlanId, TestPlanStatus.Underway.name());

View File

@ -187,26 +187,18 @@
<script> <script>
import MsDialogFooter from "metersphere-frontend/src/components/MsDialogFooter"; import MsDialogFooter from "metersphere-frontend/src/components/MsDialogFooter";
import { strMapToObj } from "metersphere-frontend/src/utils"; import {strMapToObj} from "metersphere-frontend/src/utils";
import MsTag from "metersphere-frontend/src/components/MsTag"; import MsTag from "metersphere-frontend/src/components/MsTag";
import { ENV_TYPE } from "metersphere-frontend/src/utils/constants"; import {ENV_TYPE} from "metersphere-frontend/src/utils/constants";
import { import {getCurrentProjectID, getOwnerProjects,} from "@/business/utils/sdk-utils";
getCurrentProjectID, import {getQuotaValidResourcePools} from "@/api/remote/resource-pool";
getOwnerProjects,
} from "@/business/utils/sdk-utils";
import { getQuotaValidResourcePools } from "@/api/remote/resource-pool";
import EnvGroupPopover from "@/business/plan/env/EnvGroupPopover"; import EnvGroupPopover from "@/business/plan/env/EnvGroupPopover";
import { getApiCaseEnv } from "@/api/remote/plan/test-plan-api-case"; import {getApiCaseEnv} from "@/api/remote/plan/test-plan-api-case";
import { import {getApiScenarioEnv, getPlanCaseEnv, getPlanCaseProjectIds,} from "@/api/remote/plan/test-plan";
getApiScenarioEnv,
getPlanCaseEnv,
getPlanCaseProjectIds,
} from "@/api/remote/plan/test-plan";
import EnvGroupWithOption from "../env/EnvGroupWithOption"; import EnvGroupWithOption from "../env/EnvGroupWithOption";
import EnvironmentGroup from "@/business/plan/env/EnvironmentGroupList"; import EnvironmentGroup from "@/business/plan/env/EnvironmentGroupList";
import EnvSelectPopover from "@/business/plan/env/EnvSelectPopover"; import EnvSelectPopover from "@/business/plan/env/EnvSelectPopover";
import { getSystemBaseSetting } from "metersphere-frontend/src/api/system"; import {getProjectConfig} from "@/api/project";
import { getProjectConfig } from "@/api/project";
export default { export default {
name: "MsTestPlanRunModeWithEnv", name: "MsTestPlanRunModeWithEnv",
@ -310,18 +302,19 @@ export default {
this.showPopover(); this.showPopover();
}, },
getProjectApplication() { getProjectApplication() {
this.runConfig.resourcePoolId = null;
getProjectConfig(getCurrentProjectID(), "").then((res) => { getProjectConfig(getCurrentProjectID(), "").then((res) => {
if (res.data && res.data.poolEnable && res.data.resourcePoolId) {
this.runConfig.resourcePoolId = res.data.resourcePoolId;
}
let hasPool = false; let hasPool = false;
this.resourcePools.forEach((item) => { this.resourcePools.forEach((item) => {
if (item.id === this.runConfig.resourcePoolId) { if (item.id === this.runConfig.resourcePoolId) {
hasPool = true; hasPool = true;
return;
} }
}); });
if (!hasPool) {
if (res.data && res.data.poolEnable && res.data.resourcePoolId) {
this.runConfig.resourcePoolId = res.data.resourcePoolId;
hasPool = true;
}
}
if (!hasPool) { if (!hasPool) {
this.runConfig.resourcePoolId = null; this.runConfig.resourcePoolId = null;
} }