Merge remote-tracking branch 'origin/main'

This commit is contained in:
liqiang-fit2cloud 2022-10-17 18:24:39 +08:00
commit 6f22435be4
13 changed files with 65 additions and 45 deletions

View File

@ -158,7 +158,7 @@ public class ApiScenarioExecuteService {
if (request.isRerun()) { if (request.isRerun()) {
ApiScenarioReportWithBLOBs report = new ApiScenarioReportWithBLOBs(); ApiScenarioReportWithBLOBs report = new ApiScenarioReportWithBLOBs();
report.setId(serialReportId); report.setId(serialReportId);
report.setStatus(ApiReportStatus.RUNNING.name()); report.setStatus(ApiReportStatus.RERUNNING.name());
apiScenarioReportMapper.updateByPrimaryKeySelective(report); apiScenarioReportMapper.updateByPrimaryKeySelective(report);
} else { } else {
LoggerUtil.info("Scenario run-执行脚本装载-初始化集成报告:" + serialReportId); LoggerUtil.info("Scenario run-执行脚本装载-初始化集成报告:" + serialReportId);

View File

@ -16,11 +16,6 @@ import io.metersphere.api.exec.api.ApiExecuteService;
import io.metersphere.api.exec.generator.JSONSchemaGenerator; import io.metersphere.api.exec.generator.JSONSchemaGenerator;
import io.metersphere.api.exec.queue.ExecThreadPoolExecutor; import io.metersphere.api.exec.queue.ExecThreadPoolExecutor;
import io.metersphere.api.parse.api.ApiDefinitionImport; import io.metersphere.api.parse.api.ApiDefinitionImport;
import io.metersphere.dto.BaseCase;
import io.metersphere.service.definition.ApiDefinitionService;
import io.metersphere.service.definition.ApiTestCaseService;
import io.metersphere.service.definition.EsbApiParamService;
import io.metersphere.service.definition.EsbImportService;
import io.metersphere.base.domain.ApiDefinition; import io.metersphere.base.domain.ApiDefinition;
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs; import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
import io.metersphere.base.domain.Schedule; import io.metersphere.base.domain.Schedule;
@ -28,15 +23,19 @@ import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule; import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants; import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.utils.JSONToDocumentUtil;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
import io.metersphere.dto.BaseCase;
import io.metersphere.dto.MsExecResponseDTO; import io.metersphere.dto.MsExecResponseDTO;
import io.metersphere.dto.RelationshipEdgeDTO; import io.metersphere.dto.RelationshipEdgeDTO;
import io.metersphere.environment.service.BaseEnvironmentService; import io.metersphere.environment.service.BaseEnvironmentService;
import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.notice.annotation.SendNotice; import io.metersphere.notice.annotation.SendNotice;
import io.metersphere.request.ResetOrderRequest; import io.metersphere.request.ResetOrderRequest;
import io.metersphere.commons.utils.JSONToDocumentUtil; import io.metersphere.service.definition.ApiDefinitionService;
import io.metersphere.service.definition.EsbApiParamService;
import io.metersphere.service.definition.EsbImportService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -326,7 +325,7 @@ public class ApiDefinitionController {
return apiDefinitionService.getRelationshipApi(id, relationshipType); return apiDefinitionService.getRelationshipApi(id, relationshipType);
} }
@GetMapping("/relationship/count/{id}/") @GetMapping("/relationship/count/{id}")
public int getRelationshipApi(@PathVariable("id") String id) { public int getRelationshipApi(@PathVariable("id") String id) {
return apiDefinitionService.getRelationshipCount(id); return apiDefinitionService.getRelationshipCount(id);
} }

View File

@ -297,10 +297,6 @@ public class ApiScenarioReportService {
if (StringUtils.isNotEmpty(report.getTriggerMode()) && report.getTriggerMode().equals("CASE")) { if (StringUtils.isNotEmpty(report.getTriggerMode()) && report.getTriggerMode().equals("CASE")) {
report.setTriggerMode(TriggerMode.MANUAL.name()); report.setTriggerMode(TriggerMode.MANUAL.name());
} }
// UI 调试类型报告不记录更新状态
if (report.getExecuteType().equals(ExecuteType.Debug.name()) && report.getReportType().equals(ReportTypeConstants.UI_INDEPENDENT.name())) {
return report;
}
apiScenarioReportMapper.updateByPrimaryKeySelective(report); apiScenarioReportMapper.updateByPrimaryKeySelective(report);
return report; return report;
} }

View File

@ -8,7 +8,7 @@ import io.metersphere.api.dto.automation.RunScenarioRequest;
import io.metersphere.api.exec.api.ApiCaseExecuteService; import io.metersphere.api.exec.api.ApiCaseExecuteService;
import io.metersphere.api.exec.scenario.ApiScenarioExecuteService; import io.metersphere.api.exec.scenario.ApiScenarioExecuteService;
import io.metersphere.base.domain.*; import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.ApiScenarioMapper;
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper; import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
import io.metersphere.base.mapper.ext.ExtApiScenarioReportResultMapper; import io.metersphere.base.mapper.ext.ExtApiScenarioReportResultMapper;
import io.metersphere.commons.constants.ApiRunMode; import io.metersphere.commons.constants.ApiRunMode;
@ -28,10 +28,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collections; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@ -79,7 +76,8 @@ public class ApiScenarioRerunService {
if (CollectionUtils.isNotEmpty(reportResults)) { if (CollectionUtils.isNotEmpty(reportResults)) {
List<String> resourceIds = reportResults.stream().map(ApiDefinitionExecResult::getResourceId).collect(Collectors.toList()); List<String> resourceIds = reportResults.stream().map(ApiDefinitionExecResult::getResourceId).collect(Collectors.toList());
// 执行资源 // 执行资源
Map<String, ApiDefinitionExecResultWithBLOBs> map = reportResults.stream().collect(Collectors.toMap(ApiDefinitionExecResult::getResourceId, api -> api)); LinkedHashMap<String, ApiDefinitionExecResultWithBLOBs> map = reportResults.stream().collect(
Collectors.toMap(ApiDefinitionExecResultWithBLOBs::getResourceId, order -> order, (k1, k2) -> k1, LinkedHashMap::new));
ApiCaseRunRequest request = new ApiCaseRunRequest(); ApiCaseRunRequest request = new ApiCaseRunRequest();
request.setRerun(true); request.setRerun(true);

View File

@ -424,6 +424,7 @@ public class ApiScenarioService {
* @param scenario * @param scenario
*/ */
public void deleteUpdateBodyFile(ApiScenarioWithBLOBs scenario, ApiScenarioWithBLOBs oldScenario) { public void deleteUpdateBodyFile(ApiScenarioWithBLOBs scenario, ApiScenarioWithBLOBs oldScenario) {
try {
Set<String> newRequestIds = getRequestIds(scenario.getScenarioDefinition()); Set<String> newRequestIds = getRequestIds(scenario.getScenarioDefinition());
MsTestElement msTestElement = GenerateHashTreeUtil.parseScenarioDefinition(oldScenario.getScenarioDefinition()); MsTestElement msTestElement = GenerateHashTreeUtil.parseScenarioDefinition(oldScenario.getScenarioDefinition());
List<MsHTTPSamplerProxy> oldRequests = MsHTTPSamplerProxy.findHttpSampleFromHashTree(msTestElement); List<MsHTTPSamplerProxy> oldRequests = MsHTTPSamplerProxy.findHttpSampleFromHashTree(msTestElement);
@ -432,6 +433,9 @@ public class ApiScenarioService {
FileUtils.deleteBodyFiles(item.getId()); FileUtils.deleteBodyFiles(item.getId());
} }
}); });
} catch (Exception e) {
LogUtil.error("Historical data processing exception");
}
} }
public Set<String> getRequestIds(String scenarioDefinition) { public Set<String> getRequestIds(String scenarioDefinition) {
@ -707,6 +711,7 @@ public class ApiScenarioService {
if (scenarioWithBLOBs != null && StringUtils.isNotEmpty(scenarioWithBLOBs.getScenarioDefinition())) { if (scenarioWithBLOBs != null && StringUtils.isNotEmpty(scenarioWithBLOBs.getScenarioDefinition())) {
JSONObject element = JSONUtil.parseObject(scenarioWithBLOBs.getScenarioDefinition()); JSONObject element = JSONUtil.parseObject(scenarioWithBLOBs.getScenarioDefinition());
hashTreeService.dataFormatting(element); hashTreeService.dataFormatting(element);
ElementUtil.dataFormatting(element);
scenarioWithBLOBs.setScenarioDefinition(element.toString()); scenarioWithBLOBs.setScenarioDefinition(element.toString());
} }
return scenarioWithBLOBs; return scenarioWithBLOBs;
@ -1376,6 +1381,8 @@ public class ApiScenarioService {
for (int i = 0; i < data.size(); i++) { for (int i = 0; i < data.size(); i++) {
ApiScenarioWithBLOBs item = data.get(i); ApiScenarioWithBLOBs item = data.get(i);
JSONObject jsonObject = JSONUtil.parseObject(JSON.toJSONString(item));
ElementUtil.dataFormatting(jsonObject);
if (StringUtils.isBlank(item.getName())) { if (StringUtils.isBlank(item.getName())) {
MSException.throwException(Translator.get("scenario_name_is_null")); MSException.throwException(Translator.get("scenario_name_is_null"));
} }

View File

@ -20,7 +20,7 @@
<!-- content header chart --> <!-- content header chart -->
<ms-metric-chart :content="content" :totalTime="totalTime" :report="report"/> <ms-metric-chart :content="content" :totalTime="totalTime" :report="report"/>
<el-tabs v-model="activeName" @tab-click="handleClick"> <el-tabs v-model="activeName" @tab-click="handleClick" style="min-width: 1000px">
<!-- all step--> <!-- all step-->
<el-tab-pane label="All" name="total"> <el-tab-pane label="All" name="total">
<ms-scenario-results <ms-scenario-results

View File

@ -29,7 +29,7 @@
@select-all="handleSelectAll" @select-all="handleSelectAll"
@select="handleSelect" @select="handleSelect"
:height="screenHeight" :height="screenHeight"
@filter-change="filter" @row-click="handleView"> @filter-change="filter" @row-click="handleView" v-if="loadIsOver">
<el-table-column <el-table-column
type="selection"/> type="selection"/>
<el-table-column width="40" :resizable="false" align="center"> <el-table-column width="40" :resizable="false" align="center">
@ -227,7 +227,7 @@ export default {
selectDataCounts: 0, selectDataCounts: 0,
screenHeight: 'calc(100vh - 160px)', screenHeight: 'calc(100vh - 160px)',
trashActiveDom: 'left', trashActiveDom: 'left',
userFilters: [] userFilters: [],
} }
}, },
watch: { watch: {
@ -274,12 +274,12 @@ export default {
} }
if (this.trashActiveDom === 'left') { if (this.trashActiveDom === 'left') {
this.reportTypeFilters = this.reportScenarioFilters; this.reportTypeFilters = this.reportScenarioFilters;
getReportPage(this.currentPage, this.pageSize, this.condition).then(res => { this.result = getReportPage(this.currentPage, this.pageSize, this.condition).then(res => {
this.setData(res); this.setData(res);
}) })
} else { } else {
this.reportTypeFilters = this.reportCaseFilters; this.reportTypeFilters = this.reportCaseFilters;
getApiReportPage(this.currentPage, this.pageSize, this.condition).then(res => { this.result = getApiReportPage(this.currentPage, this.pageSize, this.condition).then(res => {
this.setData(res); this.setData(res);
}) })
} }
@ -288,17 +288,12 @@ export default {
let data = response.data; let data = response.data;
this.total = data.itemCount; this.total = data.itemCount;
this.tableData = data.listObject; this.tableData = data.listObject;
this.tableData.forEach(item => {
if (item.status === 'STOP') {
item.status = 'stopped'
}
})
this.selectRows.clear(); this.selectRows.clear();
this.unSelection = data.listObject.map(s => s.id); this.unSelection = data.listObject.map(s => s.id);
}, },
handleView(report) { handleView(report) {
this.reportId = report.id; this.reportId = report.id;
if (report.status === 'Running' || report.status === 'Rerunning') { if (report.status === 'RUNNING' || report.status === 'RERUNNING') {
this.$warning(this.$t('commons.run_warning')) this.$warning(this.$t('commons.run_warning'))
return; return;
} }

View File

@ -227,4 +227,7 @@ export default {
.report-name { .report-name {
border-bottom: 1px solid var(--primary_color); border-bottom: 1px solid var(--primary_color);
} }
.report-header{
min-width: 1000px;
}
</style> </style>

View File

@ -6,13 +6,15 @@
<el-collapse-transition> <el-collapse-transition>
<el-tabs v-model="activeName" style="margin: 20px"> <el-tabs v-model="activeName" style="margin: 20px">
<el-tab-pane :label="$t('commons.remark')" name="remark" class="pane"> <el-tab-pane :label="$t('commons.remark')" name="remark" class="pane">
<form-rich-text-item class="remark-item" :disabled="readOnly && !hasPermissions" :data="api" prop="remark" label-width="0"/> <form-rich-text-item class="remark-item" :disabled="readOnly && !hasPermissions" :data="api" prop="remark"
label-width="0"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="$t('commons.relationship.name')" name="dependencies" class="pane"> <el-tab-pane :label="$t('commons.relationship.name')" name="dependencies" class="pane">
<template v-slot:label> <template v-slot:label>
<tab-pane-count :title="$t('commons.relationship.name')" :count="relationshipCount"/> <tab-pane-count :title="$t('commons.relationship.name')" :count="relationshipCount"/>
</template> </template>
<dependencies-list @setCount="setCount" :read-only="readOnly" :resource-id="api.id" resource-type="API" ref="dependencies"/> <dependencies-list @setCount="setCount" :read-only="readOnly" :resource-id="api.id" resource-type="API"
ref="dependencies"/>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</el-collapse-transition> </el-collapse-transition>
@ -29,6 +31,7 @@ import FormRichTextItem from "@/business/commons/FormRichTextItem";
import {hasPermissions} from "metersphere-frontend/src/utils/permission"; import {hasPermissions} from "metersphere-frontend/src/utils/permission";
import TabPaneCount from "@/business/commons/TabPaneCount"; import TabPaneCount from "@/business/commons/TabPaneCount";
import {getRelationshipCountApi} from "@/api/definition"; import {getRelationshipCountApi} from "@/api/definition";
export default { export default {
name: "ApiOtherInfo", name: "ApiOtherInfo",
components: {TabPaneCount, FormRichTextItem, DependenciesList, ApiInfoContainer, MsFormDivider}, components: {TabPaneCount, FormRichTextItem, DependenciesList, ApiInfoContainer, MsFormDivider},
@ -52,14 +55,21 @@ export default {
}, },
}, },
mounted() { mounted() {
getRelationshipCountApi(this.api.id, (data) => { this.$nextTick(() => {
this.relationshipCount = data; this.initRelationshipCount();
}); });
}, },
methods: { methods: {
setCount(count) { setCount(count) {
this.relationshipCount = count; this.relationshipCount = count;
}, },
initRelationshipCount() {
getRelationshipCountApi(this.api.id).then(rsp => {
let data = rsp.data;
this.relationshipCount = data;
});
}
} }
} }
</script> </script>

View File

@ -8,7 +8,7 @@
:before-close="close"> :before-close="close">
<el-form> <el-form>
<el-form-item :label="$t('commons.name')"> <el-form-item :label="$t('commons.name')">
<el-input v-model="data.name" maxlength="60" show-word-limit></el-input> <el-input v-model="data.name" :maxlength="maxLength" show-word-limit></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -28,6 +28,12 @@ export default {
data: {} data: {}
}; };
}, },
props: {
maxLength: {
type: Number,
default: 60
},
},
methods: { methods: {
open(data) { open(data) {
this.dialogVisible = true; this.dialogVisible = true;

View File

@ -171,6 +171,7 @@ export default {
{id: 'STARTING', label: 'Starting'}, {id: 'STARTING', label: 'Starting'},
{id: 'PENDING', label: 'Pending'}, {id: 'PENDING', label: 'Pending'},
{id: 'RUNNING', label: 'Running'}, {id: 'RUNNING', label: 'Running'},
{id: 'RERUNNING', label: 'Rerunning'},
{id: 'REPORTING', label: 'Reporting'}, {id: 'REPORTING', label: 'Reporting'},
{id: 'SUCCESS', label: 'Success'}, {id: 'SUCCESS', label: 'Success'},
{id: "FAKE_ERROR", label: 'FakeError'}, {id: "FAKE_ERROR", label: 'FakeError'},

View File

@ -0,0 +1,5 @@
ALTER TABLE load_test_report
MODIFY name VARCHAR(255) NOT NULL;
ALTER TABLE load_test_report
MODIFY test_name VARCHAR(255) NULL;

View File

@ -149,7 +149,7 @@
</el-card> </el-card>
</ms-main-container> </ms-main-container>
<same-test-reports ref="compareReports"/> <same-test-reports ref="compareReports"/>
<ms-rename-report-dialog ref="renameDialog" @submit="rename"></ms-rename-report-dialog> <ms-rename-report-dialog ref="renameDialog" @submit="rename" :max-length="255"></ms-rename-report-dialog>
</ms-container> </ms-container>
</template> </template>