parent
02d9925d7c
commit
ebb933379c
|
@ -4,12 +4,14 @@ import io.metersphere.api.dto.JmxInfoDTO;
|
|||
import io.metersphere.api.dto.definition.RunDefinitionRequest;
|
||||
import io.metersphere.api.dto.definition.request.ParameterConfig;
|
||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||
import io.metersphere.api.exec.engine.EngineSourceParserFactory;
|
||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||
import io.metersphere.base.domain.FileMetadata;
|
||||
import io.metersphere.base.mapper.FileMetadataMapper;
|
||||
import io.metersphere.commons.constants.ElementConstants;
|
||||
import io.metersphere.environment.service.BaseEnvironmentService;
|
||||
import io.metersphere.metadata.service.FileMetadataService;
|
||||
import io.metersphere.api.exec.engine.EngineSourceParserFactory;
|
||||
import io.metersphere.request.BodyFile;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
@ -21,10 +23,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DataFormattingUtil {
|
||||
|
@ -111,6 +110,7 @@ public class DataFormattingUtil {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error("获取CSV文件异常!", e);
|
||||
}
|
||||
} else if (StringUtils.equals(qname, ElementConstants.HTTP_SAMPLER)) {
|
||||
List<Element> elementPropElementList = parentElement.elements("elementProp");
|
||||
|
@ -188,9 +188,22 @@ public class DataFormattingUtil {
|
|||
config.setConfig(envConfig);
|
||||
}
|
||||
HashTree hashTree = runRequest.getTestElement().generateHashTree(config);
|
||||
List<BodyFile> files = new LinkedList<>();
|
||||
ApiFileUtil.getFiles(hashTree, files);
|
||||
String jmxString = runRequest.getTestElement().getJmx(hashTree);
|
||||
//将jmx处理封装为通用方法
|
||||
JmxInfoDTO dto = updateJmxString(jmxString, true);
|
||||
FileMetadataMapper fileMetadataMapper = CommonBeanFactory.getBean(FileMetadataMapper.class);
|
||||
if (fileMetadataMapper != null && CollectionUtils.isNotEmpty(files)) {
|
||||
for (BodyFile file : files) {
|
||||
if (StringUtils.isNotBlank(file.getFileId()) && file.isRef()) {
|
||||
FileMetadata fileMetadata = fileMetadataMapper.selectByPrimaryKey(file.getFileId());
|
||||
if (fileMetadata != null && !dto.getAttachFiles().containsKey(fileMetadata.getId())) {
|
||||
dto.getAttachFiles().put(fileMetadata.getId(), fileMetadata.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dto.setName(runRequest.getName() + ".jmx");
|
||||
return dto;
|
||||
}
|
||||
|
|
|
@ -5,83 +5,179 @@
|
|||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form :inline="true">
|
||||
<el-form-item :label="$t('load_test.name') ">
|
||||
<el-input :disabled="isReadOnly" :placeholder="$t('load_test.input_name')" v-model="test.name"
|
||||
class="input-with-select"
|
||||
size="small"
|
||||
maxlength="255" show-word-limit/>
|
||||
<el-form-item :label="$t('load_test.name')">
|
||||
<el-input
|
||||
:disabled="isReadOnly"
|
||||
:placeholder="$t('load_test.input_name')"
|
||||
v-model="test.name"
|
||||
class="input-with-select"
|
||||
size="small"
|
||||
maxlength="255"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12">
|
||||
<el-tooltip :content="$t('commons.follow')" placement="bottom" effect="dark" v-if="!showFollow">
|
||||
<i class="el-icon-star-off"
|
||||
style="color: #783987; font-size: 25px; margin-right: 15px;cursor: pointer;position: relative; top: 5px; "
|
||||
@click="saveFollow"/>
|
||||
<el-tooltip
|
||||
:content="$t('commons.follow')"
|
||||
placement="bottom"
|
||||
effect="dark"
|
||||
v-if="!showFollow"
|
||||
>
|
||||
<i
|
||||
class="el-icon-star-off"
|
||||
style="
|
||||
color: #783987;
|
||||
font-size: 25px;
|
||||
margin-right: 15px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
top: 5px;
|
||||
"
|
||||
@click="saveFollow"
|
||||
/>
|
||||
</el-tooltip>
|
||||
<el-tooltip :content="$t('commons.cancel')" placement="bottom" effect="dark" v-if="showFollow">
|
||||
<i class="el-icon-star-on"
|
||||
style="color: #783987; font-size: 28px; margin-right: 15px;cursor: pointer;position: relative; top: 5px; "
|
||||
@click="saveFollow"/>
|
||||
<el-tooltip
|
||||
:content="$t('commons.cancel')"
|
||||
placement="bottom"
|
||||
effect="dark"
|
||||
v-if="showFollow"
|
||||
>
|
||||
<i
|
||||
class="el-icon-star-on"
|
||||
style="
|
||||
color: #783987;
|
||||
font-size: 28px;
|
||||
margin-right: 15px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
top: 5px;
|
||||
"
|
||||
@click="saveFollow"
|
||||
/>
|
||||
</el-tooltip>
|
||||
|
||||
<el-link type="primary" size="small" style="margin-right: 5px" @click="openHis" v-if="test.id">
|
||||
{{ $t('operating_log.change_history') }}
|
||||
<el-link
|
||||
type="primary"
|
||||
size="small"
|
||||
style="margin-right: 5px"
|
||||
@click="openHis"
|
||||
v-if="test.id"
|
||||
>
|
||||
{{ $t("operating_log.change_history") }}
|
||||
</el-link>
|
||||
<mx-version-history v-xpack
|
||||
ref="versionHistory"
|
||||
:version-data="versionData"
|
||||
:current-id="testId"
|
||||
:is-read="isReadOnly"
|
||||
:has-latest="hasLatest"
|
||||
@setLatest="setLatest"
|
||||
@compare="compare" @checkout="checkout" @create="create" @del="del"/>
|
||||
<el-button :disabled="isReadOnly" type="primary" size="small" plain @click="save"
|
||||
v-permission="['PROJECT_PERFORMANCE_TEST:READ+EDIT']"
|
||||
>{{ $t('commons.save') }}
|
||||
<mx-version-history
|
||||
v-xpack
|
||||
ref="versionHistory"
|
||||
:version-data="versionData"
|
||||
:current-id="testId"
|
||||
:is-read="isReadOnly"
|
||||
:has-latest="hasLatest"
|
||||
@setLatest="setLatest"
|
||||
@compare="compare"
|
||||
@checkout="checkout"
|
||||
@create="create"
|
||||
@del="del"
|
||||
/>
|
||||
<el-button
|
||||
:disabled="isReadOnly"
|
||||
type="primary"
|
||||
size="small"
|
||||
plain
|
||||
@click="save"
|
||||
v-permission="['PROJECT_PERFORMANCE_TEST:READ+EDIT']"
|
||||
>{{ $t("commons.save") }}
|
||||
</el-button>
|
||||
<el-button :disabled="isReadOnly" size="small" type="primary" plain @click="saveAndRun"
|
||||
v-permission="['PROJECT_PERFORMANCE_TEST:READ+RUN']">
|
||||
{{ $t('load_test.save_and_run') }}
|
||||
<el-button
|
||||
:disabled="isReadOnly"
|
||||
size="small"
|
||||
type="primary"
|
||||
plain
|
||||
@click="saveAndRun"
|
||||
v-permission="['PROJECT_PERFORMANCE_TEST:READ+RUN']"
|
||||
>
|
||||
{{ $t("load_test.save_and_run") }}
|
||||
</el-button>
|
||||
<el-button :disabled="isReadOnly" size="small" type="warning" plain @click="cancel">
|
||||
{{ $t('commons.cancel') }}
|
||||
<el-button
|
||||
:disabled="isReadOnly"
|
||||
size="small"
|
||||
type="warning"
|
||||
plain
|
||||
@click="cancel"
|
||||
>
|
||||
{{ $t("commons.cancel") }}
|
||||
</el-button>
|
||||
|
||||
<schedule-config :schedule="test.schedule" :save="saveCronExpression" @scheduleChange="saveSchedule"
|
||||
v-if="hasPermission('PROJECT_PERFORMANCE_TEST:READ+SCHEDULE')"
|
||||
:check-open="checkScheduleEdit" :test-id="testId" :custom-validate="durationValidate"/>
|
||||
|
||||
<ms-tip-button v-if="test.isNeedUpdate && hasPermission('PROJECT_PERFORMANCE_TEST:READ+EDIT')"
|
||||
class="sync-btn" type="primary" size="small" circle
|
||||
icon="el-icon-connection"
|
||||
@click="syncScenario"
|
||||
:plain="!test.isNeedUpdate"
|
||||
:disabled="!test.isNeedUpdate"
|
||||
:tip="'同步场景测试最新变更'"/>
|
||||
<schedule-config
|
||||
:schedule="test.schedule"
|
||||
:save="saveCronExpression"
|
||||
@scheduleChange="saveSchedule"
|
||||
v-if="hasPermission('PROJECT_PERFORMANCE_TEST:READ+SCHEDULE')"
|
||||
:check-open="checkScheduleEdit"
|
||||
:test-id="testId"
|
||||
:custom-validate="durationValidate"
|
||||
/>
|
||||
|
||||
<ms-tip-button
|
||||
v-if="
|
||||
test.isNeedUpdate &&
|
||||
hasPermission('PROJECT_PERFORMANCE_TEST:READ+EDIT')
|
||||
"
|
||||
class="sync-btn"
|
||||
type="primary"
|
||||
size="small"
|
||||
circle
|
||||
icon="el-icon-connection"
|
||||
@click="syncScenario"
|
||||
:plain="!test.isNeedUpdate"
|
||||
:disabled="!test.isNeedUpdate"
|
||||
:tip="'同步场景测试最新变更'"
|
||||
/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-tabs v-model="active" @tab-click="clickTab">
|
||||
<el-tab-pane :label="$t('load_test.basic_config')" class="advanced-config">
|
||||
<performance-basic-config :is-read-only="isReadOnly" :test="test" ref="basicConfig"
|
||||
@tgTypeChange="tgTypeChange"
|
||||
@fileChange="fileChange"/>
|
||||
<el-tab-pane
|
||||
:label="$t('load_test.basic_config')"
|
||||
class="advanced-config"
|
||||
>
|
||||
<performance-basic-config
|
||||
:is-read-only="isReadOnly"
|
||||
:test="test"
|
||||
ref="basicConfig"
|
||||
@tgTypeChange="tgTypeChange"
|
||||
@fileChange="fileChange"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('load_test.pressure_config')" class="advanced-config">
|
||||
<performance-pressure-config :is-read-only="isReadOnly" :test="test" :test-id="testId"
|
||||
@fileChange="fileChange"
|
||||
ref="pressureConfig" @changeActive="changeTabActive"/>
|
||||
<el-tab-pane
|
||||
:label="$t('load_test.pressure_config')"
|
||||
class="advanced-config"
|
||||
>
|
||||
<performance-pressure-config
|
||||
:is-read-only="isReadOnly"
|
||||
:test="test"
|
||||
:test-id="testId"
|
||||
@fileChange="fileChange"
|
||||
ref="pressureConfig"
|
||||
@changeActive="changeTabActive"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('load_test.advanced_config')" class="advanced-config">
|
||||
<performance-advanced-config :read-only="isReadOnly" :test-id="testId" ref="advancedConfig"/>
|
||||
<el-tab-pane
|
||||
:label="$t('load_test.advanced_config')"
|
||||
class="advanced-config"
|
||||
>
|
||||
<performance-advanced-config
|
||||
:read-only="isReadOnly"
|
||||
:test-id="testId"
|
||||
ref="advancedConfig"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-card>
|
||||
|
||||
<ms-change-history ref="changeHistory"/>
|
||||
<ms-change-history ref="changeHistory" />
|
||||
|
||||
<el-dialog
|
||||
:fullscreen="true"
|
||||
|
@ -89,10 +185,14 @@
|
|||
:destroy-on-close="true"
|
||||
width="100%"
|
||||
>
|
||||
<diff-version v-if="dialogVisible" :old-data="oldData" :show-follow="showFollow" :new-data="newData"
|
||||
:new-show-follow="newShowFollow"></diff-version>
|
||||
<diff-version
|
||||
v-if="dialogVisible"
|
||||
:old-data="oldData"
|
||||
:show-follow="showFollow"
|
||||
:new-data="newData"
|
||||
:new-show-follow="newShowFollow"
|
||||
></diff-version>
|
||||
</el-dialog>
|
||||
|
||||
</ms-main-container>
|
||||
</ms-container>
|
||||
</template>
|
||||
|
@ -103,16 +203,23 @@ import PerformancePressureConfig from "./components/PerformancePressureConfig";
|
|||
import PerformanceAdvancedConfig from "./components/PerformanceAdvancedConfig";
|
||||
import MsContainer from "metersphere-frontend/src/components/MsContainer";
|
||||
import MsMainContainer from "metersphere-frontend/src/components/MsMainContainer";
|
||||
import {getCurrentProjectID, getCurrentUser, getCurrentWorkspaceId} from "metersphere-frontend/src/utils/token";
|
||||
import {hasLicense, hasPermission} from "metersphere-frontend/src/utils/permission";
|
||||
import {
|
||||
getCurrentProjectID,
|
||||
getCurrentUser,
|
||||
getCurrentWorkspaceId,
|
||||
} from "metersphere-frontend/src/utils/token";
|
||||
import {
|
||||
hasLicense,
|
||||
hasPermission,
|
||||
} from "metersphere-frontend/src/utils/permission";
|
||||
import ScheduleConfig from "./components/ScheduleConfig";
|
||||
import MsChangeHistory from "metersphere-frontend/src/components/history/ChangeHistory";
|
||||
import MsTableOperatorButton from "metersphere-frontend/src/components/MsTableOperatorButton";
|
||||
import MsTipButton from "metersphere-frontend/src/components/MsTipButton";
|
||||
import MxVersionHistory from "metersphere-frontend/src/components/version/MxVersionHistory";
|
||||
import DiffVersion from "./DiffVersion";
|
||||
import {PROJECT_ID} from "metersphere-frontend/src/utils/constants";
|
||||
import {getProjectUsers} from "metersphere-frontend/src/api/user";
|
||||
import { PROJECT_ID } from "metersphere-frontend/src/utils/constants";
|
||||
import { getProjectUsers } from "metersphere-frontend/src/api/user";
|
||||
import {
|
||||
deleteCurrentVersionTest,
|
||||
getFollows,
|
||||
|
@ -123,9 +230,12 @@ import {
|
|||
saveFollows,
|
||||
saveSchedule,
|
||||
saveTest,
|
||||
syncScenario
|
||||
syncScenario,
|
||||
} from "@/api/performance";
|
||||
import {getDefaultVersion, setLatestVersionById} from 'metersphere-frontend/src/api/version';
|
||||
import {
|
||||
getDefaultVersion,
|
||||
setLatestVersionById,
|
||||
} from "metersphere-frontend/src/api/version";
|
||||
|
||||
export default {
|
||||
name: "EditPerformanceTest",
|
||||
|
@ -140,76 +250,77 @@ export default {
|
|||
MsMainContainer,
|
||||
MsChangeHistory,
|
||||
DiffVersion,
|
||||
MxVersionHistory
|
||||
MxVersionHistory,
|
||||
},
|
||||
inject: [
|
||||
'reload'
|
||||
],
|
||||
inject: ["reload"],
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
loading: false,
|
||||
test: {schedule: {}, follows: []},
|
||||
oldData: {schedule: {}, follows: []},
|
||||
newData: {schedule: {}, follows: []},
|
||||
test: { schedule: {}, follows: [] },
|
||||
oldData: { schedule: {}, follows: [] },
|
||||
newData: { schedule: {}, follows: [] },
|
||||
newShowFollow: false,
|
||||
savePath: "/performance/save",
|
||||
editPath: "/performance/edit",
|
||||
projects: [],
|
||||
active: '0',
|
||||
testId: '',
|
||||
active: "0",
|
||||
testId: "",
|
||||
isReadOnly: false,
|
||||
showFollow: false,
|
||||
tabs: [{
|
||||
title: this.$t('load_test.basic_config'),
|
||||
id: '0',
|
||||
component: 'PerformanceBasicConfig'
|
||||
}, {
|
||||
title: this.$t('load_test.pressure_config'),
|
||||
id: '1',
|
||||
component: 'PerformancePressureConfig'
|
||||
}, {
|
||||
title: this.$t('load_test.advanced_config'),
|
||||
id: '2',
|
||||
component: 'PerformanceAdvancedConfig'
|
||||
}],
|
||||
tabs: [
|
||||
{
|
||||
title: this.$t("load_test.basic_config"),
|
||||
id: "0",
|
||||
component: "PerformanceBasicConfig",
|
||||
},
|
||||
{
|
||||
title: this.$t("load_test.pressure_config"),
|
||||
id: "1",
|
||||
component: "PerformancePressureConfig",
|
||||
},
|
||||
{
|
||||
title: this.$t("load_test.advanced_config"),
|
||||
id: "2",
|
||||
component: "PerformanceAdvancedConfig",
|
||||
},
|
||||
],
|
||||
maintainerOptions: [],
|
||||
versionData: [],
|
||||
projectEnvMap: {},
|
||||
latestVersionId: '',
|
||||
hasLatest: false
|
||||
latestVersionId: "",
|
||||
hasLatest: false,
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
'$route'(to) {
|
||||
$route(to) {
|
||||
// 如果是创建测试
|
||||
if (to.path.startsWith('/performance/test/create')) {
|
||||
if (to.path.startsWith("/performance/test/create")) {
|
||||
this.reload();
|
||||
}
|
||||
|
||||
if (!to.path.startsWith('/performance/test/edit')) {
|
||||
if (!to.path.startsWith("/performance/test/edit")) {
|
||||
return;
|
||||
}
|
||||
this.reload();
|
||||
this.isReadOnly = false;
|
||||
this.getTest(to.params.testId);
|
||||
}
|
||||
|
||||
},
|
||||
},
|
||||
created() {
|
||||
let projectId = this.$route.query.projectId;
|
||||
if (projectId && projectId !== getCurrentProjectID()) {
|
||||
sessionStorage.setItem(PROJECT_ID, projectId);
|
||||
}
|
||||
this.isReadOnly = !hasPermission('PROJECT_PERFORMANCE_TEST:READ+EDIT');
|
||||
this.isReadOnly = !hasPermission("PROJECT_PERFORMANCE_TEST:READ+EDIT");
|
||||
this.getTest(this.$route.params.testId);
|
||||
if (hasLicense()) {
|
||||
this.getDefaultVersion();
|
||||
}
|
||||
this.$EventBus.$on('projectChange', this.handleProjectChange);
|
||||
this.$EventBus.$on("projectChange", this.handleProjectChange);
|
||||
},
|
||||
destroyed() {
|
||||
this.$EventBus.$off('projectChange', this.handleProjectChange);
|
||||
this.$EventBus.$off("projectChange", this.handleProjectChange);
|
||||
},
|
||||
mounted() {
|
||||
// todo
|
||||
|
@ -222,17 +333,21 @@ export default {
|
|||
return getCurrentUser();
|
||||
},
|
||||
getMaintainerOptions() {
|
||||
getProjectUsers()
|
||||
.then(res => {
|
||||
this.maintainerOptions = res.data;
|
||||
});
|
||||
getProjectUsers().then((res) => {
|
||||
this.maintainerOptions = res.data;
|
||||
});
|
||||
},
|
||||
openHis() {
|
||||
this.$refs.changeHistory.open(this.test.id, ["性能测试", "性能測試", "Performance test", "PERFORMANCE_TEST"]);
|
||||
this.$refs.changeHistory.open(this.test.id, [
|
||||
"性能测试",
|
||||
"性能測試",
|
||||
"Performance test",
|
||||
"PERFORMANCE_TEST",
|
||||
]);
|
||||
},
|
||||
importAPITest() {
|
||||
// 先用 sessionStorage
|
||||
let apiTest = JSON.parse(sessionStorage.getItem('LOAD_TEST'))?.test;
|
||||
let apiTest = JSON.parse(sessionStorage.getItem("LOAD_TEST"))?.test;
|
||||
if (apiTest && apiTest.name) {
|
||||
this.$set(this.test, "name", apiTest.name);
|
||||
if (apiTest.jmx.projectEnvMap) {
|
||||
|
@ -245,7 +360,7 @@ export default {
|
|||
relateApiList.push({
|
||||
apiId: apiTest.jmx.scenarioId,
|
||||
apiVersion: apiTest.jmx.version,
|
||||
type: 'SCENARIO'
|
||||
type: "SCENARIO",
|
||||
});
|
||||
this.$set(this.test, "apiList", relateApiList);
|
||||
}
|
||||
|
@ -256,7 +371,7 @@ export default {
|
|||
apiId: apiTest.jmx.caseId,
|
||||
apiVersion: apiTest.jmx.version,
|
||||
envId: apiTest.jmx.envId,
|
||||
type: 'API_CASE'
|
||||
type: "API_CASE",
|
||||
});
|
||||
this.$set(this.test, "apiList", relateApiList);
|
||||
}
|
||||
|
@ -265,12 +380,17 @@ export default {
|
|||
for (let fileID in apiTest.jmx.attachFiles) {
|
||||
attachFiles.push(fileID);
|
||||
}
|
||||
if (attachFiles.length > 0) {
|
||||
this.$refs.basicConfig.selectAttachFileById(attachFiles);
|
||||
}
|
||||
}
|
||||
this.active = '1';
|
||||
sessionStorage.removeItem('LOAD_TEST');
|
||||
this.active = "1";
|
||||
sessionStorage.removeItem("LOAD_TEST");
|
||||
} else {
|
||||
// 先用 sessionStorage
|
||||
let scenarioJmxs = JSON.parse(sessionStorage.getItem('LOAD_TEST'))?.scenarioJmxs;
|
||||
let scenarioJmxs = JSON.parse(
|
||||
sessionStorage.getItem("LOAD_TEST")
|
||||
)?.scenarioJmxs;
|
||||
if (scenarioJmxs && scenarioJmxs.name) {
|
||||
this.$set(this.test, "name", scenarioJmxs.name);
|
||||
let relateApiList = [];
|
||||
|
@ -278,13 +398,13 @@ export default {
|
|||
this.projectEnvMap = scenarioJmxs.projectEnvMap;
|
||||
}
|
||||
if (scenarioJmxs.jmxs) {
|
||||
scenarioJmxs.jmxs.forEach(item => {
|
||||
scenarioJmxs.jmxs.forEach((item) => {
|
||||
if (item.scenarioId) {
|
||||
this.$refs.basicConfig.importScenario(item.scenarioId);
|
||||
relateApiList.push({
|
||||
apiId: item.scenarioId,
|
||||
apiVersion: item.version,
|
||||
type: 'SCENARIO'
|
||||
type: "SCENARIO",
|
||||
});
|
||||
}
|
||||
if (item.caseId) {
|
||||
|
@ -299,8 +419,8 @@ export default {
|
|||
this.$set(this.test, "apiList", relateApiList);
|
||||
});
|
||||
this.$refs.basicConfig.handleUpload();
|
||||
this.active = '1';
|
||||
sessionStorage.removeItem('LOAD_TEST');
|
||||
this.active = "1";
|
||||
sessionStorage.removeItem("LOAD_TEST");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -310,36 +430,34 @@ export default {
|
|||
this.test.follows = [];
|
||||
this.showFollow = false;
|
||||
this.testId = testId;
|
||||
this.loading = getTest(testId)
|
||||
.then(response => {
|
||||
if (response.data) {
|
||||
this.test = response.data;
|
||||
if (!this.test.schedule) {
|
||||
this.test.schedule = {};
|
||||
}
|
||||
if (this.test.envInfo) {
|
||||
try {
|
||||
this.projectEnvMap = JSON.parse(this.test.envInfo);
|
||||
} catch (e) {
|
||||
this.projectEnvMap = null;
|
||||
}
|
||||
}
|
||||
this.getDefaultFollow(testId);
|
||||
this.loading = getTest(testId).then((response) => {
|
||||
if (response.data) {
|
||||
this.test = response.data;
|
||||
if (!this.test.schedule) {
|
||||
this.test.schedule = {};
|
||||
}
|
||||
});
|
||||
if (this.test.envInfo) {
|
||||
try {
|
||||
this.projectEnvMap = JSON.parse(this.test.envInfo);
|
||||
} catch (e) {
|
||||
this.projectEnvMap = null;
|
||||
}
|
||||
}
|
||||
this.getDefaultFollow(testId);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
getDefaultFollow(testId) {
|
||||
getFollows(testId)
|
||||
.then(response => {
|
||||
this.$set(this.test, 'follows', response.data);
|
||||
for (let i = 0; i < this.test.follows.length; i++) {
|
||||
if (this.test.follows[i] === this.currentUser().id) {
|
||||
this.showFollow = true;
|
||||
break;
|
||||
}
|
||||
getFollows(testId).then((response) => {
|
||||
this.$set(this.test, "follows", response.data);
|
||||
for (let i = 0; i < this.test.follows.length; i++) {
|
||||
if (this.test.follows[i] === this.currentUser().id) {
|
||||
this.showFollow = true;
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
save(newVersion) {
|
||||
if (!this.validTest()) {
|
||||
|
@ -349,20 +467,23 @@ export default {
|
|||
return;
|
||||
}
|
||||
if (!this.test.versionId) {
|
||||
if (this.$refs.versionHistory && this.$refs.versionHistory.currentVersion) {
|
||||
if (
|
||||
this.$refs.versionHistory &&
|
||||
this.$refs.versionHistory.currentVersion
|
||||
) {
|
||||
this.test.versionId = this.$refs.versionHistory.currentVersion.id;
|
||||
}
|
||||
}
|
||||
let formData = this.getSaveOption();
|
||||
|
||||
this.loading = saveTest(this.test, formData)
|
||||
.then(({data}) => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
.then(({ data }) => {
|
||||
this.$success(this.$t("commons.save_success"));
|
||||
this.test.id = data.data.id;
|
||||
this.$refs.advancedConfig.cancelAllEdit();
|
||||
if (this.$route.path.indexOf('/performance/test/edit/') < 0) {
|
||||
if (this.$route.path.indexOf("/performance/test/edit/") < 0) {
|
||||
this.$router.push({
|
||||
path: '/performance/test/edit/' + data.data.id,
|
||||
path: "/performance/test/edit/" + data.data.id,
|
||||
});
|
||||
} else {
|
||||
this.$refs.basicConfig.uploadList = [];
|
||||
|
@ -370,7 +491,7 @@ export default {
|
|||
}
|
||||
this.getVersionHistory();
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
if (this.$refs.versionHistory) {
|
||||
this.$refs.versionHistory.loading = false;
|
||||
}
|
||||
|
@ -382,73 +503,80 @@ export default {
|
|||
}
|
||||
|
||||
let formData = this.getSaveOption();
|
||||
this.loading = saveTest(this.test, formData)
|
||||
.then(({data}) => {
|
||||
this.test.id = data.data.id;
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
runTest(this.test)
|
||||
.then(response => {
|
||||
let reportId = response.data;
|
||||
this.$router.push({path: '/performance/report/view/' + reportId});
|
||||
});
|
||||
this.loading = saveTest(this.test, formData).then(({ data }) => {
|
||||
this.test.id = data.data.id;
|
||||
this.$success(this.$t("commons.save_success"));
|
||||
runTest(this.test).then((response) => {
|
||||
let reportId = response.data;
|
||||
this.$router.push({ path: "/performance/report/view/" + reportId });
|
||||
});
|
||||
});
|
||||
},
|
||||
getSaveOption() {
|
||||
let formData = new FormData();
|
||||
|
||||
if (this.$refs.basicConfig.uploadList.length > 0) {
|
||||
this.$refs.basicConfig.uploadList.forEach(f => {
|
||||
this.$refs.basicConfig.uploadList.forEach((f) => {
|
||||
formData.append("file", f);
|
||||
});
|
||||
}
|
||||
// 基本配置
|
||||
this.test.updatedFileList = this.$refs.basicConfig.updatedFileList();
|
||||
this.test.fileSorts = this.$refs.basicConfig.fileSorts();
|
||||
this.test.conversionFileIdList = this.$refs.basicConfig.conversionMetadataIdList();
|
||||
this.test.conversionFileIdList =
|
||||
this.$refs.basicConfig.conversionMetadataIdList();
|
||||
// 压力配置
|
||||
this.test.loadConfiguration = JSON.stringify(this.$refs.pressureConfig.convertProperty());
|
||||
this.test.loadConfiguration = JSON.stringify(
|
||||
this.$refs.pressureConfig.convertProperty()
|
||||
);
|
||||
this.test.testResourcePoolId = this.$refs.pressureConfig.resourcePool;
|
||||
// 高级配置
|
||||
this.test.advancedConfiguration = JSON.stringify(this.$refs.advancedConfig.configurations());
|
||||
this.test.advancedConfiguration = JSON.stringify(
|
||||
this.$refs.advancedConfig.configurations()
|
||||
);
|
||||
this.test.projectEnvMap = this.projectEnvMap;
|
||||
// file属性不需要json化
|
||||
let requestJson = JSON.stringify(this.test, function (key, value) {
|
||||
return key === "file" ? undefined : value;
|
||||
});
|
||||
formData.append('request', new Blob([requestJson], {
|
||||
type: "application/json"
|
||||
}));
|
||||
formData.append(
|
||||
"request",
|
||||
new Blob([requestJson], {
|
||||
type: "application/json",
|
||||
})
|
||||
);
|
||||
return formData;
|
||||
},
|
||||
syncScenario() {
|
||||
if (!hasPermission('PROJECT_API_SCENARIO:READ+CREATE')) {
|
||||
this.$warning(this.$t('performance_test.sync_scenario_no_permission_tips'));
|
||||
if (!hasPermission("PROJECT_API_SCENARIO:READ+CREATE")) {
|
||||
this.$warning(
|
||||
this.$t("performance_test.sync_scenario_no_permission_tips")
|
||||
);
|
||||
return;
|
||||
}
|
||||
let param = {
|
||||
id: this.test.id,
|
||||
scenarioId: this.test.scenarioId
|
||||
scenarioId: this.test.scenarioId,
|
||||
};
|
||||
syncScenario(param)
|
||||
.then(() => {
|
||||
this.getTest(this.$route.params.testId);
|
||||
this.$success('commons.save_success');
|
||||
});
|
||||
syncScenario(param).then(() => {
|
||||
this.getTest(this.$route.params.testId);
|
||||
this.$success("commons.save_success");
|
||||
});
|
||||
},
|
||||
cancel() {
|
||||
this.$router.push({path: '/performance/test/all'});
|
||||
this.$router.push({ path: "/performance/test/all" });
|
||||
},
|
||||
validTest() {
|
||||
let currentProjectId = getCurrentProjectID();
|
||||
this.test.projectId = currentProjectId;
|
||||
|
||||
if (!this.test.name) {
|
||||
this.$error(this.$t('load_test.test_name_is_null'));
|
||||
this.$error(this.$t("load_test.test_name_is_null"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.test.projectId) {
|
||||
this.$error(this.$t('load_test.project_is_null'));
|
||||
this.$error(this.$t("load_test.project_is_null"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -494,22 +622,21 @@ export default {
|
|||
param.enable = true;
|
||||
}
|
||||
|
||||
saveSchedule(param)
|
||||
.then(response => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.getTest(this.test.id);
|
||||
});
|
||||
saveSchedule(param).then((response) => {
|
||||
this.$success(this.$t("commons.save_success"));
|
||||
this.getTest(this.test.id);
|
||||
});
|
||||
},
|
||||
checkScheduleEdit() {
|
||||
if (!this.test.id) {
|
||||
this.$message(this.$t('api_test.environment.please_save_test'));
|
||||
this.$message(this.$t("api_test.environment.please_save_test"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
durationValidate(intervalTime) {
|
||||
let duration = 0;
|
||||
this.$refs.pressureConfig.threadGroups.forEach(tg => {
|
||||
this.$refs.pressureConfig.threadGroups.forEach((tg) => {
|
||||
let d = this.$refs.pressureConfig.getDuration(tg);
|
||||
if (duration < d) {
|
||||
duration = d;
|
||||
|
@ -518,36 +645,36 @@ export default {
|
|||
if (intervalTime < duration * 1000) {
|
||||
return {
|
||||
pass: false,
|
||||
info: this.$t('load_test.schedule_tip')
|
||||
info: this.$t("load_test.schedule_tip"),
|
||||
};
|
||||
}
|
||||
return {
|
||||
pass: true
|
||||
pass: true,
|
||||
};
|
||||
},
|
||||
fileChange(threadGroups) {
|
||||
let handler = this.$refs.pressureConfig;
|
||||
let csvSet = new Set;
|
||||
threadGroups.forEach(tg => {
|
||||
let csvSet = new Set();
|
||||
threadGroups.forEach((tg) => {
|
||||
tg.threadNumber = tg.threadNumber || 10;
|
||||
tg.duration = tg.duration || 10;
|
||||
tg.durationHours = Math.floor(tg.duration / 3600);
|
||||
tg.durationMinutes = Math.floor((tg.duration / 60 % 60));
|
||||
tg.durationSeconds = Math.floor((tg.duration % 60));
|
||||
tg.durationMinutes = Math.floor((tg.duration / 60) % 60);
|
||||
tg.durationSeconds = Math.floor(tg.duration % 60);
|
||||
tg.rampUpTime = tg.rampUpTime || 5;
|
||||
tg.step = tg.step || 5;
|
||||
tg.rpsLimit = tg.rpsLimit || 10;
|
||||
tg.threadType = tg.threadType || 'DURATION';
|
||||
tg.threadType = tg.threadType || "DURATION";
|
||||
tg.iterateNum = tg.iterateNum || 1;
|
||||
tg.iterateRampUp = tg.iterateRampUp || 10;
|
||||
|
||||
if (tg.csvFiles) {
|
||||
tg.csvFiles.map(item => csvSet.add(item));
|
||||
tg.csvFiles.map((item) => csvSet.add(item));
|
||||
}
|
||||
});
|
||||
let csvFiles = [];
|
||||
for (const f of csvSet) {
|
||||
csvFiles.push({name: f, csvSplit: false, csvHasHeader: true});
|
||||
csvFiles.push({ name: f, csvSplit: false, csvHasHeader: true });
|
||||
}
|
||||
|
||||
this.$set(handler, "threadGroups", threadGroups);
|
||||
|
@ -564,7 +691,7 @@ export default {
|
|||
handler.calculateTotalChart();
|
||||
},
|
||||
clickTab(tab) {
|
||||
if (tab.index === '1') {
|
||||
if (tab.index === "1") {
|
||||
this.$refs.pressureConfig.calculateTotalChart();
|
||||
}
|
||||
},
|
||||
|
@ -578,10 +705,9 @@ export default {
|
|||
}
|
||||
}
|
||||
if (this.testId) {
|
||||
saveFollows(this.testId, this.test.follows)
|
||||
.then(() => {
|
||||
this.$success(this.$t('commons.cancel_follow_success'));
|
||||
});
|
||||
saveFollows(this.testId, this.test.follows).then(() => {
|
||||
this.$success(this.$t("commons.cancel_follow_success"));
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.showFollow = true;
|
||||
|
@ -590,60 +716,58 @@ export default {
|
|||
}
|
||||
this.test.follows.push(this.currentUser().id);
|
||||
if (this.testId) {
|
||||
saveFollows(this.testId, this.test.follows)
|
||||
.then(() => {
|
||||
this.$success(this.$t('commons.follow_success'));
|
||||
});
|
||||
saveFollows(this.testId, this.test.follows).then(() => {
|
||||
this.$success(this.$t("commons.follow_success"));
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
getDefaultVersion() {
|
||||
getDefaultVersion(getCurrentProjectID())
|
||||
.then(response => {
|
||||
this.latestVersionId = response.data;
|
||||
this.getVersionHistory();
|
||||
});
|
||||
getDefaultVersion(getCurrentProjectID()).then((response) => {
|
||||
this.latestVersionId = response.data;
|
||||
this.getVersionHistory();
|
||||
});
|
||||
},
|
||||
getVersionHistory() {
|
||||
let testId = undefined;
|
||||
if (this.testId) {
|
||||
testId = this.testId;
|
||||
}
|
||||
getTestVersionHistory(testId)
|
||||
.then(response => {
|
||||
this.versionData = response.data;
|
||||
let latestVersionData = response.data.filter((v) => v.versionId === this.latestVersionId);
|
||||
if (latestVersionData.length > 0) {
|
||||
this.hasLatest = false
|
||||
} else {
|
||||
this.hasLatest = true;
|
||||
}
|
||||
});
|
||||
getTestVersionHistory(testId).then((response) => {
|
||||
this.versionData = response.data;
|
||||
let latestVersionData = response.data.filter(
|
||||
(v) => v.versionId === this.latestVersionId
|
||||
);
|
||||
if (latestVersionData.length > 0) {
|
||||
this.hasLatest = false;
|
||||
} else {
|
||||
this.hasLatest = true;
|
||||
}
|
||||
});
|
||||
},
|
||||
compare(row) {
|
||||
this.oldData = this.test;
|
||||
this.oldData.createTime = this.$refs.versionHistory.versionOptions.filter(v => v.id === this.test.versionId)[0].createTime;
|
||||
getTestByVersion(row.id, this.test.refId)
|
||||
.then(response => {
|
||||
getTest(response.data.id)
|
||||
.then(res => {
|
||||
if (res.data) {
|
||||
this.newData = res.data;
|
||||
this.newData.createTime = row.createTime;
|
||||
getFollows(response.data.id)
|
||||
.then(resp => {
|
||||
if (resp.data && resp.data.follows) {
|
||||
for (let i = 0; i < resp.data.follows.length; i++) {
|
||||
if (resp.data.follows[i] === this.currentUser().id) {
|
||||
this.newShowFollow = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
this.oldData.createTime = this.$refs.versionHistory.versionOptions.filter(
|
||||
(v) => v.id === this.test.versionId
|
||||
)[0].createTime;
|
||||
getTestByVersion(row.id, this.test.refId).then((response) => {
|
||||
getTest(response.data.id).then((res) => {
|
||||
if (res.data) {
|
||||
this.newData = res.data;
|
||||
this.newData.createTime = row.createTime;
|
||||
getFollows(response.data.id).then((resp) => {
|
||||
if (resp.data && resp.data.follows) {
|
||||
for (let i = 0; i < resp.data.follows.length; i++) {
|
||||
if (resp.data.follows[i] === this.currentUser().id) {
|
||||
this.newShowFollow = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
if (this.newData) {
|
||||
this.dialogVisible = true;
|
||||
}
|
||||
|
@ -651,14 +775,16 @@ export default {
|
|||
checkout(row) {
|
||||
//let test = this.versionData.filter(v => v.versionId === row.id)[0];
|
||||
this.test.versionId = row.id;
|
||||
this.loading = getTestByVersion(this.test.versionId, this.test.refId)
|
||||
.then(response => {
|
||||
this.testId = response.data.id;
|
||||
this.$router.push({
|
||||
path: '/performance/test/edit/' + this.testId,
|
||||
});
|
||||
this.getVersionHistory();
|
||||
this.loading = getTestByVersion(
|
||||
this.test.versionId,
|
||||
this.test.refId
|
||||
).then((response) => {
|
||||
this.testId = response.data.id;
|
||||
this.$router.push({
|
||||
path: "/performance/test/edit/" + this.testId,
|
||||
});
|
||||
this.getVersionHistory();
|
||||
});
|
||||
},
|
||||
create(row) {
|
||||
// 创建新版本
|
||||
|
@ -666,45 +792,49 @@ export default {
|
|||
this.save(true);
|
||||
},
|
||||
del(row) {
|
||||
this.$alert(this.$t('load_test.delete_confirm') + ' ' + row.name + " ?", '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
deleteCurrentVersionTest({versionId: row.id, refId: this.test.refId})
|
||||
.then(response => {
|
||||
this.$success(this.$t('load_test.delete_success'));
|
||||
this.$alert(
|
||||
this.$t("load_test.delete_confirm") + " " + row.name + " ?",
|
||||
"",
|
||||
{
|
||||
confirmButtonText: this.$t("commons.confirm"),
|
||||
callback: (action) => {
|
||||
if (action === "confirm") {
|
||||
deleteCurrentVersionTest({
|
||||
versionId: row.id,
|
||||
refId: this.test.refId,
|
||||
}).then((response) => {
|
||||
this.$success(this.$t("load_test.delete_success"));
|
||||
this.getVersionHistory();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
},
|
||||
setLatest(row) {
|
||||
let param = {
|
||||
projectId: getCurrentProjectID(),
|
||||
type: 'PERFORMANCE',
|
||||
type: "PERFORMANCE",
|
||||
versionId: row.id,
|
||||
resourceId: this.test.id
|
||||
}
|
||||
resourceId: this.test.id,
|
||||
};
|
||||
setLatestVersionById(param).then(() => {
|
||||
this.$success(this.$t('commons.modify_success'));
|
||||
this.$success(this.$t("commons.modify_success"));
|
||||
this.checkout(row);
|
||||
});
|
||||
},
|
||||
handleProjectChange() {
|
||||
if (this.$route.path.startsWith('/performance/test/edit')) {
|
||||
if (this.$route.path.startsWith("/performance/test/edit")) {
|
||||
this.$nextTick(() => {
|
||||
this.$router.push('/performance/test/all');
|
||||
})
|
||||
this.$router.push("/performance/test/all");
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
|
||||
.el-select {
|
||||
min-width: 130px;
|
||||
}
|
||||
|
@ -723,5 +853,4 @@ export default {
|
|||
margin-right: 25px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
Loading…
Reference in New Issue