fix: 从场景测试转换的性能测试支持一键更新_补充

This commit is contained in:
chenjianxing 2021-06-23 16:09:38 +08:00 committed by jianxing
parent f3a140378d
commit c79c753654
2 changed files with 42 additions and 1 deletions

View File

@ -240,6 +240,7 @@ public class ApiAutomationService {
checkNameExist(request);
checkScenarioNum(request);
final ApiScenarioWithBLOBs scenario = buildSaveScenario(request);
scenario.setVersion(0);
scenario.setCreateTime(System.currentTimeMillis());
scenario.setNum(getNextNum(request.getProjectId()));
@ -321,6 +322,14 @@ public class ApiAutomationService {
esbApiParamService.checkScenarioRequests(request);
final ApiScenarioWithBLOBs scenario = buildSaveScenario(request);
Integer version = apiScenarioMapper.selectByPrimaryKey(request.getId()).getVersion();
if (version == null) {
scenario.setVersion(0);
} else {
scenario.setVersion(version + 1);
}
deleteUpdateBodyFile(scenario);
List<ApiMethodUrlDTO> useUrl = this.parseUrl(scenario);
scenario.setUseUrl(JSONArray.toJSONString(useUrl));
@ -1534,7 +1543,7 @@ public class ApiAutomationService {
}
public JmxInfoDTO genPerformanceTestJmx(RunScenarioRequest request) throws Exception {
public JmxInfoDTO genPerformanceTestJmx(RunScenarioRequest request) {
List<ApiScenarioWithBLOBs> apiScenarios = null;
List<String> ids = request.getIds();
apiScenarios = extApiScenarioMapper.selectIds(ids);
@ -1743,6 +1752,7 @@ public class ApiAutomationService {
scenrioExportJmx.setFiles(fileList);
}
}
scenrioExportJmx.setVersion(item.getVersion());
resList.add(scenrioExportJmx);
}
}

View File

@ -29,6 +29,15 @@
<ms-schedule-config :schedule="test.schedule" :save="saveCronExpression" @scheduleChange="saveSchedule"
v-permission="['PROJECT_PERFORMANCE_TEST:READ+SCHEDULE']"
:check-open="checkScheduleEdit" :test-id="testId" :custom-validate="durationValidate"/>
<ms-tip-button v-if="test.scenarioId"
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>
@ -65,10 +74,14 @@ import MsMainContainer from "../../common/components/MsMainContainer";
import {getCurrentProjectID, hasPermission} from "@/common/js/utils";
import MsScheduleConfig from "../../common/components/MsScheduleConfig";
import MsChangeHistory from "../../history/ChangeHistory";
import MsTableOperatorButton from "@/business/components/common/components/MsTableOperatorButton";
import MsTipButton from "@/business/components/common/components/MsTipButton";
export default {
name: "EditPerformanceTest",
components: {
MsTipButton,
MsTableOperatorButton,
MsScheduleConfig,
PerformancePressureConfig,
PerformanceBasicConfig,
@ -141,6 +154,8 @@ export default {
if (apiTest.jmx.scenarioId) {
this.$refs.basicConfig.importScenario(apiTest.jmx.scenarioId);
this.$refs.basicConfig.handleUpload();
this.$set(this.test, "scenarioId", apiTest.jmx.scenarioId);
this.$set(this.test, "scenarioVersion", apiTest.jmx.version);
}
if (apiTest.jmx.caseId) {
this.$refs.basicConfig.importCase(apiTest.jmx);
@ -237,6 +252,16 @@ export default {
}
};
},
syncScenario() {
let param = {
id: this.test.id,
scenarioId: this.test.scenarioId
};
this.result = this.$post('/performance/sync/scenario', param, () => {
this.getTest(this.$route.params.testId);
this.$success('更新成功');
});
},
cancel() {
this.$router.push({path: '/performance/test/all'});
},
@ -365,4 +390,10 @@ export default {
height: calc(100vh - 265px);
overflow: auto;
}
.sync-btn {
float: right;
margin-right: 25px;
margin-top: 5px;
}
</style>