refactor(接口测试): 优化资源池执行

This commit is contained in:
wxg0103 2023-05-16 20:11:08 +08:00 committed by fit2-zhao
parent 3236435001
commit 365ef04d12
4 changed files with 62 additions and 114 deletions

View File

@ -56,11 +56,8 @@
style="width: 100%" />
</div>
<div class="mode-row">
<el-checkbox v-model="runConfig.runWithinResourcePool" :disabled="true">
{{ $t('run_mode.run_with_resource_pool') }} </el-checkbox
><br />
<span>{{ $t('run_mode.run_with_resource_pool') }} : </span>
<el-select
:disabled="!runConfig.runWithinResourcePool"
v-model="runConfig.resourcePoolId"
size="mini"
class="mode-row"
@ -115,7 +112,6 @@ export default {
mode: 'serial',
reportType: 'iddReport',
onSampleError: false,
runWithinResourcePool: false,
resourcePoolId: null,
envMap: new Map(),
environmentGroupId: '',
@ -135,19 +131,6 @@ export default {
default: true,
},
},
watch: {
'runConfig.runWithinResourcePool'() {
if (!this.runConfig.runWithinResourcePool) {
this.runConfig = {
mode: this.runConfig.mode,
reportType: 'iddReport',
reportName: '',
runWithinResourcePool: false,
resourcePoolId: null,
};
}
},
},
methods: {
open() {
this.runModeVisible = true;
@ -166,7 +149,6 @@ export default {
reportType: 'iddReport',
reportName: '',
environmentType: ENV_TYPE.JSON,
runWithinResourcePool: false,
resourcePoolId: null,
};
this.runModeVisible = false;
@ -186,7 +168,7 @@ export default {
this.$warning(this.$t('commons.input_name'));
return;
}
if (this.runConfig.runWithinResourcePool && this.runConfig.resourcePoolId == null) {
if (this.runConfig.resourcePoolId == null) {
this.$warning(this.$t('workspace.env_group.please_select_run_within_resource_pool'));
return;
}
@ -196,20 +178,25 @@ export default {
getResourcePools() {
this.result = getTestResourcePools().then((response) => {
this.resourcePools = response.data;
this.runConfig.runWithinResourcePool = true;
this.getProjectApplication();
});
},
getProjectApplication() {
getProjectConfig(getCurrentProjectID(), '').then((res) => {
if (res.data && res.data.poolEnable && res.data.resourcePoolId) {
this.resourcePools.forEach(item => {
if (item.id === res.data.resourcePoolId) {
this.runConfig.resourcePoolId = res.data.resourcePoolId;
}
});
let hasPool = false;
this.resourcePools.forEach(item => {
if (item.id === this.runConfig.resourcePoolId) {
hasPool = true;
return;
}
});
if (!hasPool) {
this.runConfig.resourcePoolId = null;
getProjectConfig(getCurrentProjectID(), "").then((res) => {
if (res.data && res.data.poolEnable && res.data.resourcePoolId) {
this.runConfig.resourcePoolId = res.data.resourcePoolId;
}
});
}
},
setEnvGroup(id) {
this.runConfig.environmentGroupId = id;

View File

@ -68,12 +68,9 @@
</div>
<div class="ms-mode-div">
<span class="ms-mode-span">{{ $t('run_mode.other_config') }}</span>
<el-checkbox v-model="runConfig.runWithinResourcePool" :disabled="true">
{{ $t('run_mode.run_with_resource_pool') }}
</el-checkbox>
<span>{{ $t('run_mode.run_with_resource_pool') }}:</span>
<el-select
style="margin-left: 10px"
:disabled="!runConfig.runWithinResourcePool"
v-model="runConfig.resourcePoolId"
size="mini">
<el-option
@ -114,8 +111,6 @@ import { ENV_TYPE } from 'metersphere-frontend/src/utils/constants';
import EnvPopover from '@/business/automation/scenario/EnvPopover';
import { getMaintainer, getOwnerProjects, getProjectConfig } from '@/api/project';
import { getTestResourcePools } from '@/api/test-resource-pool';
import { getSystemBaseSetting } from 'metersphere-frontend/src/api/system';
function defaultCustomValidate() {
return { pass: true };
}
@ -146,11 +141,6 @@ export default {
'schedule.value'() {
this.form.cronValue = this.schedule.value;
},
'runConfig.runWithinResourcePool'() {
if (!this.runConfig.runWithinResourcePool) {
this.runConfig.resourcePoolId = null;
}
},
},
data() {
const validateCron = (rule, cronValue, callback) => {
@ -193,7 +183,6 @@ export default {
mode: 'serial',
reportType: 'iddReport',
onSampleError: false,
runWithinResourcePool: false,
resourcePoolId: null,
envMap: {},
environmentGroupId: '',
@ -206,15 +195,21 @@ export default {
},
methods: {
getProjectApplication() {
getProjectConfig(getCurrentProjectID(), '').then((res) => {
if (res.data && res.data.poolEnable && res.data.resourcePoolId) {
this.resourcePools.forEach(item => {
if (item.id === res.data.resourcePoolId) {
this.runConfig.resourcePoolId = res.data.resourcePoolId;
}
});
let hasPool = false;
this.resourcePools.forEach(item => {
if (item.id === this.runConfig.resourcePoolId) {
hasPool = true;
return;
}
});
if (!hasPool) {
this.runConfig.resourcePoolId = null;
getProjectConfig(getCurrentProjectID(), "").then((res) => {
if (res.data && res.data.poolEnable && res.data.resourcePoolId) {
this.runConfig.resourcePoolId = res.data.resourcePoolId;
}
});
}
},
currentUser: () => {
return getCurrentUser();
@ -255,7 +250,6 @@ export default {
getResourcePools() {
this.result = getTestResourcePools().then((response) => {
this.resourcePools = response.data;
this.runConfig.runWithinResourcePool = true;
this.getProjectApplication();
});
},
@ -388,7 +382,7 @@ export default {
this.$warning(this.$t('workspace.env_group.please_select_env_for_current_scenario'));
return;
}
if (this.runConfig.runWithinResourcePool && this.runConfig.resourcePoolId == null) {
if (this.runConfig.resourcePoolId == null) {
this.$warning(this.$t('workspace.env_group.please_select_run_within_resource_pool'));
return;
}

View File

@ -68,16 +68,8 @@
haveOtherExecCase
"
>
<el-checkbox
v-model="runConfig.runWithinResourcePool"
style="padding-right: 10px"
class="radio-change"
:disabled="true"
>
{{ $t("run_mode.run_with_resource_pool") }} </el-checkbox
><br />
<span>{{ $t("run_mode.run_with_resource_pool") }}: </span>
<el-select
:disabled="!runConfig.runWithinResourcePool"
v-model="runConfig.resourcePoolId"
size="mini"
style="width: 100%; margin-top: 8px"
@ -100,16 +92,8 @@
haveOtherExecCase
"
>
<el-checkbox
v-model="runConfig.runWithinResourcePool"
style="padding-right: 10px"
class="radio-change"
:disabled="true"
>
{{ $t("run_mode.run_with_resource_pool") }} </el-checkbox
><br />
<span>{{ $t("run_mode.run_with_resource_pool") }}: </span>
<el-select
:disabled="!runConfig.runWithinResourcePool"
v-model="runConfig.resourcePoolId"
size="mini"
style="width: 100%; margin-top: 8px"
@ -254,7 +238,6 @@ export default {
mode: "serial",
reportType: "iddReport",
onSampleError: false,
runWithinResourcePool: false,
resourcePoolId: null,
envMap: new Map(),
environmentGroupId: "",
@ -319,9 +302,6 @@ export default {
this.runConfig.onSampleError =
this.runConfig.onSampleError === "true" ||
this.runConfig.onSampleError === true;
this.runConfig.runWithinResourcePool =
this.runConfig.runWithinResourcePool === "true" ||
this.runConfig.runWithinResourcePool === true;
}
this.runModeVisible = true;
this.testType = testType;
@ -330,15 +310,21 @@ export default {
this.showPopover();
},
getProjectApplication() {
getProjectConfig(getCurrentProjectID(), "").then((res) => {
if (res.data && res.data.poolEnable && res.data.resourcePoolId) {
this.resourcePools.forEach(item => {
if (item.id === res.data.resourcePoolId) {
this.runConfig.resourcePoolId = res.data.resourcePoolId;
}
});
let hasPool = false;
this.resourcePools.forEach(item => {
if (item.id === this.runConfig.resourcePoolId) {
hasPool = true;
return;
}
});
if (!hasPool) {
this.runConfig.resourcePoolId = null;
getProjectConfig(getCurrentProjectID(), "").then((res) => {
if (res.data && res.data.poolEnable && res.data.resourcePoolId) {
this.runConfig.resourcePoolId = res.data.resourcePoolId;
}
});
}
},
changeMode() {
this.runConfig.onSampleError = false;
@ -348,7 +334,6 @@ export default {
mode: "serial",
reportType: "iddReport",
onSampleError: false,
runWithinResourcePool: false,
resourcePoolId: null,
envMap: new Map(),
environmentGroupId: "",
@ -366,7 +351,6 @@ export default {
getResourcePools() {
getQuotaValidResourcePools().then((response) => {
this.resourcePools = response.data;
this.runConfig.runWithinResourcePool = true;
this.getProjectApplication();
});
},
@ -445,7 +429,6 @@ export default {
},
handleCommand(command) {
if (
this.runConfig.runWithinResourcePool &&
this.runConfig.resourcePoolId == null &&
this.haveOtherExecCase
) {

View File

@ -115,15 +115,8 @@
</el-col>
<el-col :span="18">
<div v-if="testType === 'API'">
<el-checkbox
v-model="runConfig.runWithinResourcePool"
style="padding-right: 10px"
:disabled="true"
>
{{ $t("run_mode.run_with_resource_pool") }}
</el-checkbox>
<sapn>{{ $t("run_mode.run_with_resource_pool") }}: </sapn>
<el-select
:disabled="!runConfig.runWithinResourcePool"
v-model="runConfig.resourcePoolId"
size="mini"
>
@ -148,15 +141,10 @@
</el-col>
<el-col :span="18">
<div v-if="testType === 'API'">
<el-checkbox
v-model="runConfig.runWithinResourcePool"
style="padding-right: 10px"
:disabled="true"
>
{{ $t("run_mode.run_with_resource_pool") }}
</el-checkbox>
<span>
{{ $t("run_mode.run_with_resource_pool") }} :
</span>
<el-select
:disabled="!runConfig.runWithinResourcePool"
v-model="runConfig.resourcePoolId"
size="mini"
>
@ -325,11 +313,6 @@ export default {
"schedule.value"() {
this.form.cronValue = this.schedule.value;
},
"runConfig.runWithinResourcePool"() {
if (!this.runConfig.runWithinResourcePool) {
this.runConfig.resourcePoolId = null;
}
},
},
data() {
const validateCron = (rule, cronValue, callback) => {
@ -375,7 +358,6 @@ export default {
mode: "serial",
reportType: "iddReport",
onSampleError: false,
runWithinResourcePool: false,
resourcePoolId: null,
retryEnable: false,
retryNum: 1,
@ -400,15 +382,21 @@ export default {
},
methods: {
getProjectApplication() {
getProjectConfig(getCurrentProjectID(), "").then((res) => {
if (res.data && res.data.poolEnable && res.data.resourcePoolId) {
this.resourcePools.forEach(item => {
if (item.id === res.data.resourcePoolId) {
this.runConfig.resourcePoolId = res.data.resourcePoolId;
}
});
let hasPool = false;
this.resourcePools.forEach(item => {
if (item.id === this.runConfig.resourcePoolId) {
hasPool = true;
return;
}
});
if (!hasPool) {
this.runConfig.resourcePoolId = null;
getProjectConfig(getCurrentProjectID(), "").then((res) => {
if (res.data && res.data.poolEnable && res.data.resourcePoolId) {
this.runConfig.resourcePoolId = res.data.resourcePoolId;
}
});
}
},
currentUser: () => {
return getCurrentUser();
@ -495,7 +483,6 @@ export default {
},
saveCron() {
if (
this.runConfig.runWithinResourcePool &&
this.runConfig.resourcePoolId == null
) {
this.$warning(
@ -529,7 +516,6 @@ export default {
param.workspaceId = getCurrentWorkspaceId();
}
if (
this.runConfig.runWithinResourcePool &&
this.runConfig.resourcePoolId == null
) {
this.$warning(
@ -598,13 +584,11 @@ export default {
getResourcePools() {
this.result = getQuotaValidResourcePools().then((response) => {
this.resourcePools = response.data;
this.runConfig.runWithinResourcePool = true;
this.getProjectApplication();
});
},
changeMode() {
this.runConfig.onSampleError = false;
this.runConfig.runWithinResourcePool = false;
this.runConfig.resourcePoolId = null;
},
},