refactor: 性能测试删除支持指定版本

This commit is contained in:
CaptainB 2022-01-20 15:01:42 +08:00 committed by 刘瑞斌
parent 3c1de5cdb0
commit 74c9847501
7 changed files with 70 additions and 59 deletions

View File

@ -130,17 +130,22 @@ public class PerformanceTestService {
}
public void delete(DeleteTestPlanRequest request) {
String testId = request.getId();
LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(request.getId());
LoadTestExample example = new LoadTestExample();
example.createCriteria().andRefIdEqualTo(loadTest.getRefId());
List<LoadTest> loadTests = loadTestMapper.selectByExample(example);
loadTests.forEach(test -> {
if (!request.isForceDelete()) {
testCaseService.checkIsRelateTest(testId);
testCaseService.checkIsRelateTest(test.getId());
}
// 删除时保存jmx内容
List<FileMetadata> fileMetadataList = getFileMetadataByTestId(testId);
List<FileMetadata> fileMetadataList = getFileMetadataByTestId(test.getId());
List<FileMetadata> jmxFiles = fileMetadataList.stream().filter(f -> StringUtils.equalsIgnoreCase(f.getType(), FileType.JMX.name())).collect(Collectors.toList());
byte[] bytes = EngineFactory.mergeJmx(jmxFiles);
LoadTestReportExample loadTestReportExample = new LoadTestReportExample();
loadTestReportExample.createCriteria().andTestIdEqualTo(testId);
loadTestReportExample.createCriteria().andTestIdEqualTo(test.getId());
List<LoadTestReport> loadTestReports = loadTestReportMapper.selectByExample(loadTestReportExample);
loadTestReports.forEach(loadTestReport -> {
LoadTestReportWithBLOBs record = new LoadTestReportWithBLOBs();
@ -149,16 +154,17 @@ public class PerformanceTestService {
extLoadTestReportMapper.updateJmxContentIfAbsent(record);
});
//delete scheduleFunctionalCases
scheduleService.deleteByResourceId(testId, ScheduleGroup.PERFORMANCE_TEST.name());
scheduleService.deleteByResourceId(test.getId(), ScheduleGroup.PERFORMANCE_TEST.name());
// delete load_test
loadTestMapper.deleteByPrimaryKey(request.getId());
loadTestMapper.deleteByPrimaryKey(test.getId());
testPlanLoadCaseService.deleteByTestId(testId);
testPlanLoadCaseService.deleteByTestId(test.getId());
detachFileByTestId(request.getId());
detachFileByTestId(test.getId());
deleteFollows(request.getId());
deleteFollows(test.getId());
});
}
private void deleteFollows(String testId) {

View File

@ -290,7 +290,7 @@
<ms-task-center ref="taskCenter" :show-menu="false"/>
<relationship-graph-drawer :graph-data="graphData" ref="relationshipGraph"/>
<!-- 删除接口提示 -->
<api-delete-confirm ref="apiDeleteConfirm" @handleDelete="_handleDelete"/>
<list-item-delete-confirm ref="apiDeleteConfirm" @handleDelete="_handleDelete"/>
</div>
</template>
@ -316,7 +316,7 @@ import axios from "axios";
import {getGraphByCondition} from "@/network/graph";
import MsTableSearchBar from "@/business/components/common/components/MsTableSearchBar";
import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar";
import ApiDeleteConfirm from "@/business/components/api/definition/components/list/ApiDeleteConfirm";
import ListItemDeleteConfirm from "@/business/components/common/components/ListItemDeleteConfirm";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComponent("./graph/RelationshipGraphDrawer.vue") : {};
@ -324,7 +324,7 @@ const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComp
export default {
name: "MsApiScenarioList",
components: {
ApiDeleteConfirm,
ListItemDeleteConfirm,
MsTableAdvSearchBar,
MsTableSearchBar,
MsTable,

View File

@ -207,7 +207,7 @@
<relationship-graph-drawer :graph-data="graphData" ref="relationshipGraph"/>
<!-- 删除接口提示 -->
<api-delete-confirm ref="apiDeleteConfirm" @handleDelete="_handleDelete"/>
<list-item-delete-confirm ref="apiDeleteConfirm" @handleDelete="_handleDelete"/>
</span>
</template>
@ -227,7 +227,7 @@ import MsTableColumn from "@/business/components/common/components/table/MsTable
import MsBottomContainer from "../BottomContainer";
import MsBatchEdit from "../basis/BatchEdit";
import {API_METHOD_COLOUR, API_STATUS, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData";
import {downloadFile, getCurrentProjectID, getUUID, hasLicense} from "@/common/js/utils";
import {downloadFile, getCurrentProjectID, hasLicense} from "@/common/js/utils";
import {API_LIST} from '@/common/js/constants';
import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover";
import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus";
@ -247,7 +247,7 @@ import {Body} from "@/business/components/api/definition/model/ApiTestModel";
import {editApiDefinitionOrder} from "@/network/api";
import {getProtocolFilter} from "@/business/components/api/definition/api-definition";
import {getGraphByCondition} from "@/network/graph";
import ApiDeleteConfirm from "@/business/components/api/definition/components/list/ApiDeleteConfirm";
import ListItemDeleteConfirm from "@/business/components/common/components/ListItemDeleteConfirm";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComponent("./graph/RelationshipGraphDrawer.vue") : {};
@ -256,7 +256,7 @@ const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComp
export default {
name: "ApiList",
components: {
ApiDeleteConfirm,
ListItemDeleteConfirm,
HeaderLabelOperate,
CaseBatchMove,
ApiStatus,

View File

@ -23,7 +23,7 @@
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
export default {
name: "ApiDeleteConfirm",
name: "ListItemDeleteConfirm",
components: {MsDialogFooter},
data() {
return {

View File

@ -22,7 +22,7 @@
<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: 20px" @click="openHis" v-if="test.id">
<el-link type="primary" size="small" style="margin-right: 5px" @click="openHis" v-if="test.id">
{{ $t('operating_log.change_history') }}
</el-link>
<ms-version-history v-xpack

View File

@ -106,6 +106,8 @@
:total="total"/>
</el-card>
</ms-main-container>
<!-- 删除接口提示 -->
<list-item-delete-confirm ref="apiDeleteConfirm" @handleDelete="_handleDelete"/>
</ms-container>
</template>
@ -122,9 +124,11 @@ import {TEST_CONFIGS} from "../../common/components/search/search-components";
import {getLastTableSortField} from "@/common/js/tableUtils";
import MsTable from "@/business/components/common/components/table/MsTable";
import {editLoadTestCaseOrder} from "@/network/load-test";
import ListItemDeleteConfirm from "@/business/components/common/components/ListItemDeleteConfirm";
export default {
components: {
ListItemDeleteConfirm,
MsTable,
MsTableHeader,
MsPerformanceTestStatus,
@ -252,24 +256,24 @@ export default {
});
},
handleDelete(test) {
this.$alert(this.$t('load_test.delete_confirm') + test.name + "", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
this._handleDelete(test);
}
}
});
//
this.$refs.apiDeleteConfirm.open(test, this.$t('load_test.delete_confirm'));
},
_handleDelete(test) {
_handleDelete(test, deleteCurrentVersion) {
if (deleteCurrentVersion) {
this.$get('performance/delete/' + test.id + '/' + test.refId, () => {
this.$success(this.$t('commons.delete_success'));
this.getVersionHistory();
});
} else {
let data = {
id: test.id
};
this.result = this.$post(this.deletePath, data, () => {
this.$success(this.$t('commons.delete_success'));
this.initTableData();
});
}
},
link(row) {
this.$router.push({

View File

@ -227,7 +227,7 @@
<!--高级搜索-->
<ms-table-adv-search-bar :condition.sync="condition" :showLink="false" ref="searchBar" @search="search"/>
<!-- 删除接口提示 -->
<api-delete-confirm ref="apiDeleteConfirm" @handleDelete="_handleDeleteVersion"/>
<list-item-delete-confirm ref="apiDeleteConfirm" @handleDelete="_handleDeleteVersion"/>
</span>
</template>
@ -259,14 +259,15 @@ import {
deepClone,
getCustomFieldBatchEditOption,
getCustomFieldValue,
getCustomTableWidth, getLastTableSortField,
getCustomTableWidth,
getLastTableSortField,
getPageInfo,
getTableHeaderWithCustomFields,
initCondition,
} from "@/common/js/tableUtils";
import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate";
import PlanStatusTableItem from "@/business/components/track/common/tableItems/plan/PlanStatusTableItem";
import {getCurrentProjectID, getCurrentUserId, getCurrentWorkspaceId, hasLicense} from "@/common/js/utils";
import {getCurrentProjectID, getCurrentUserId, getCurrentWorkspaceId, getUUID, hasLicense} from "@/common/js/utils";
import {getTestTemplate} from "@/network/custom-field-template";
import {getProjectMember} from "@/network/user";
import MsTable from "@/business/components/common/components/table/MsTable";
@ -277,14 +278,15 @@ import TestCasePreview from "@/business/components/track/case/components/TestCas
import {editTestCaseOrder} from "@/network/testCase";
import {getGraphByCondition} from "@/network/graph";
import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar";
import {getUUID} from "@/common/js/utils";
import ApiDeleteConfirm from "@/business/components/api/definition/components/list/ApiDeleteConfirm";
import ListItemDeleteConfirm from "@/business/components/common/components/ListItemDeleteConfirm";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComponent("./graph/RelationshipGraphDrawer.vue") : {};
export default {
name: "TestCaseList",
components: {
ListItemDeleteConfirm,
MsTableAdvSearchBar,
TestCasePreview,
BatchMove,
@ -310,7 +312,6 @@ export default {
ReviewStatus,
MsTag, ApiStatus,
"relationshipGraphDrawer": relationshipGraphDrawer.default,
ApiDeleteConfirm
},
data() {
return {