Merge branch 'dev' of https://github.com/metersphere/server into dev
This commit is contained in:
commit
2f6c95d137
|
@ -17,4 +17,6 @@ public interface ExtLoadTestReportMapper {
|
|||
LoadTestReport selectByPrimaryKey(String id);
|
||||
|
||||
List<DashboardTestDTO> selectDashboardTests(@Param("workspaceId") String workspaceId, @Param("startTimestamp") long startTimestamp);
|
||||
|
||||
List<String> selectResourceId(@Param("reportId") String reportId);
|
||||
}
|
||||
|
|
|
@ -77,4 +77,11 @@
|
|||
GROUP BY x
|
||||
</select>
|
||||
|
||||
<select id="selectResourceId" resultType="string">
|
||||
SELECT resource_id
|
||||
FROM load_test_report_log
|
||||
WHERE report_id = #{reportId}
|
||||
GROUP BY resource_id
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -15,7 +15,12 @@
|
|||
and w.id = #{proRequest.workspaceId}
|
||||
</if>
|
||||
</where>
|
||||
order by p.update_time desc
|
||||
<if test="proRequest.orders != null and proRequest.orders.size() > 0">
|
||||
order by
|
||||
<foreach collection="proRequest.orders" separator="," item="order">
|
||||
p.${order.name} ${order.type}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
<select id="getProjectIdByWorkspaceId" resultType="java.lang.String">
|
||||
select id
|
||||
|
|
|
@ -3,9 +3,12 @@ package io.metersphere.controller.request;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ProjectRequest {
|
||||
private String workspaceId;
|
||||
private String name;
|
||||
private List<OrderRequest> orders;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package io.metersphere.performance.controller;
|
|||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.base.domain.LoadTestReport;
|
||||
import io.metersphere.base.domain.LoadTestReportLog;
|
||||
import io.metersphere.commons.constants.RoleConstants;
|
||||
import io.metersphere.commons.utils.PageUtils;
|
||||
import io.metersphere.commons.utils.Pager;
|
||||
|
@ -19,9 +20,10 @@ import org.springframework.http.MediaType;
|
|||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "performance/report")
|
||||
public class PerformanceReportController {
|
||||
|
@ -99,9 +101,15 @@ public class PerformanceReportController {
|
|||
return reportService.getLoadTestReport(reportId);
|
||||
}
|
||||
|
||||
@GetMapping("log/{reportId}")
|
||||
public List<LogDetailDTO> logs(@PathVariable String reportId) {
|
||||
return reportService.logs(reportId);
|
||||
@GetMapping("log/resource/{reportId}")
|
||||
public List<LogDetailDTO> getResourceIds(@PathVariable String reportId) {
|
||||
return reportService.getReportLogResource(reportId);
|
||||
}
|
||||
|
||||
@GetMapping("log/{reportId}/{resourceId}/{goPage}")
|
||||
public Pager<List<LoadTestReportLog>> logs(@PathVariable String reportId, @PathVariable String resourceId, @PathVariable int goPage) {
|
||||
Page<Object> page = PageHelper.startPage(goPage, 10, true);
|
||||
return PageUtils.setPageInfo(page, reportService.getReportLogs(reportId, resourceId));
|
||||
}
|
||||
|
||||
@GetMapping("log/download/{reportId}/{resourceId}")
|
||||
|
|
|
@ -11,6 +11,7 @@ import io.metersphere.commons.exception.MSException;
|
|||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.commons.utils.ServiceUtils;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.controller.request.OrderRequest;
|
||||
import io.metersphere.dto.DashboardTestDTO;
|
||||
import io.metersphere.dto.LoadTestDTO;
|
||||
import io.metersphere.i18n.Translator;
|
||||
|
@ -29,10 +30,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import javax.annotation.Resource;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
|
@ -251,6 +249,12 @@ public class PerformanceTestService {
|
|||
|
||||
public List<LoadTestDTO> recentTestPlans(QueryTestPlanRequest request) {
|
||||
// 查询最近的测试计划
|
||||
List<OrderRequest> orders = new ArrayList<>();
|
||||
OrderRequest orderRequest = new OrderRequest();
|
||||
orderRequest.setName("update_time");
|
||||
orderRequest.setType("desc");
|
||||
orders.add(orderRequest);
|
||||
request.setOrders(orders);
|
||||
return extLoadTestMapper.list(request);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import io.metersphere.commons.constants.ReportKeys;
|
|||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.commons.utils.ServiceUtils;
|
||||
import io.metersphere.controller.request.OrderRequest;
|
||||
import io.metersphere.dto.LogDetailDTO;
|
||||
import io.metersphere.dto.ReportDTO;
|
||||
import io.metersphere.performance.base.*;
|
||||
|
@ -24,11 +25,10 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
@ -48,6 +48,12 @@ public class ReportService {
|
|||
private TestResourceService testResourceService;
|
||||
|
||||
public List<ReportDTO> getRecentReportList(ReportRequest request) {
|
||||
List<OrderRequest> orders = new ArrayList<>();
|
||||
OrderRequest orderRequest = new OrderRequest();
|
||||
orderRequest.setName("update_time");
|
||||
orderRequest.setType("desc");
|
||||
orders.add(orderRequest);
|
||||
request.setOrders(orders);
|
||||
return extLoadTestReportMapper.getReportList(request);
|
||||
}
|
||||
|
||||
|
@ -161,21 +167,13 @@ public class ReportService {
|
|||
return extLoadTestReportMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<LogDetailDTO> logs(String reportId) {
|
||||
LoadTestReportLogExample example = new LoadTestReportLogExample();
|
||||
example.createCriteria().andReportIdEqualTo(reportId);
|
||||
example.setOrderByClause("part");
|
||||
List<LoadTestReportLog> loadTestReportLogs = loadTestReportLogMapper.selectByExampleWithBLOBs(example);
|
||||
Map<String, List<LoadTestReportLog>> reportLogs = loadTestReportLogs.stream().collect(Collectors.groupingBy(LoadTestReportLog::getResourceId));
|
||||
public List<LogDetailDTO> getReportLogResource(String reportId) {
|
||||
List<LogDetailDTO> result = new ArrayList<>();
|
||||
reportLogs.forEach((resourceId, resourceLogs) -> {
|
||||
List<String> resourceIds = extLoadTestReportMapper.selectResourceId(reportId);
|
||||
resourceIds.forEach(resourceId -> {
|
||||
LogDetailDTO detailDTO = new LogDetailDTO();
|
||||
TestResource testResource = testResourceService.getTestResource(resourceId);
|
||||
String content = resourceLogs.stream().map(LoadTestReportLog::getContent).reduce("", (a, b) -> a + b);
|
||||
// 显示前 2048
|
||||
content = StringUtils.substring(content, 0, 2048);
|
||||
detailDTO.setResourceId(resourceId);
|
||||
detailDTO.setContent(content);
|
||||
if (testResource == null) {
|
||||
detailDTO.setResourceName(resourceId);
|
||||
result.add(detailDTO);
|
||||
|
@ -201,6 +199,12 @@ public class ReportService {
|
|||
return result;
|
||||
}
|
||||
|
||||
public List<LoadTestReportLog> getReportLogs(String reportId, String resourceId) {
|
||||
LoadTestReportLogExample example = new LoadTestReportLogExample();
|
||||
example.createCriteria().andReportIdEqualTo(reportId).andResourceIdEqualTo(resourceId);
|
||||
example.setOrderByClause("part desc");
|
||||
return loadTestReportLogMapper.selectByExampleWithBLOBs(example);
|
||||
}
|
||||
|
||||
public byte[] downloadLog(String reportId, String resourceId) {
|
||||
LoadTestReportLogExample example = new LoadTestReportLogExample();
|
||||
|
|
|
@ -10,6 +10,7 @@ import io.metersphere.base.mapper.LoadTestMapper;
|
|||
import io.metersphere.base.mapper.ProjectMapper;
|
||||
import io.metersphere.base.mapper.ext.*;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.ServiceUtils;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.controller.request.ProjectRequest;
|
||||
import io.metersphere.dto.ProjectDTO;
|
||||
|
@ -81,6 +82,7 @@ public class ProjectService {
|
|||
if (StringUtils.isNotBlank(request.getName())) {
|
||||
request.setName(StringUtils.wrapIfMissing(request.getName(), "%"));
|
||||
}
|
||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||
return extProjectMapper.getProjectWithWorkspace(request);
|
||||
}
|
||||
|
||||
|
|
|
@ -231,6 +231,7 @@ export class HTTPSamplerProxy extends DefaultTestElement {
|
|||
}
|
||||
|
||||
this.boolProp("HTTPSampler.follow_redirects", this.request.follow, true);
|
||||
this.boolProp("HTTPSampler.use_keepalive", this.request.keepalive, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
<template>
|
||||
<div v-loading="result.loading">
|
||||
<el-tabs type="border-card" :stretch="true">
|
||||
<el-tab-pane v-for="item in logContent" :key="item.resourceId" :label="item.resourceName" class="logging-content">
|
||||
{{item.content}}...
|
||||
<el-tab-pane v-for="item in resource" :key="item.resourceId" :label="item.resourceName" class="logging-content">
|
||||
<ul class="infinite-list" v-infinite-scroll="load(item.resourceId)" infinite-scroll-disabled="disabled">
|
||||
<li class="infinite-list-item" v-for="log in logContent" :key="log.id">{{ log.content }}</li>
|
||||
</ul>
|
||||
<el-link type="primary" @click="downloadLogFile(item)">{{$t('load_test.download_log_file')}}</el-link>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
@ -14,17 +16,40 @@
|
|||
name: "LogDetails",
|
||||
data() {
|
||||
return {
|
||||
logContent: null,
|
||||
resource: [],
|
||||
logContent: [],
|
||||
result: {},
|
||||
id: ''
|
||||
id: '',
|
||||
page: 1,
|
||||
pageCount: 1,
|
||||
loading: false,
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
disabled() {
|
||||
return this.loading || this.page > this.pageCount;
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
initTableData() {
|
||||
this.result = this.$get("/performance/report/log/" + this.id).then(res => {
|
||||
this.logContent = res.data.data;
|
||||
}).catch(() => {
|
||||
this.logContent = null;
|
||||
getResource() {
|
||||
this.result = this.$get("/performance/report/log/resource/" + this.id, data => {
|
||||
this.resource = data.data;
|
||||
})
|
||||
},
|
||||
load(resourceId) {
|
||||
if (this.loading || this.page > this.pageCount) return;
|
||||
this.loading = true;
|
||||
let url = "/performance/report/log/" + this.id + "/" + resourceId + "/" + this.page;
|
||||
this.$get(url, res => {
|
||||
let data = res.data;
|
||||
this.pageCount = data.pageCount;
|
||||
data.listObject.forEach(log => {
|
||||
this.logContent.push(log);
|
||||
})
|
||||
this.page++;
|
||||
this.loading = false;
|
||||
})
|
||||
},
|
||||
downloadLogFile(item) {
|
||||
|
@ -53,16 +78,16 @@
|
|||
},
|
||||
watch: {
|
||||
report: {
|
||||
handler(val){
|
||||
handler(val) {
|
||||
let status = val.status;
|
||||
this.id = val.id;
|
||||
if (status === "Completed") {
|
||||
this.initTableData();
|
||||
this.getResource();
|
||||
} else {
|
||||
this.logContent = null;
|
||||
this.resource = [];
|
||||
}
|
||||
},
|
||||
deep:true
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
props: ['report']
|
||||
|
@ -75,4 +100,16 @@
|
|||
overflow: auto;
|
||||
}
|
||||
|
||||
.infinite-list {
|
||||
height: 500px;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
list-style: none;
|
||||
overflow: auto
|
||||
}
|
||||
|
||||
.infinite-list-item {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="search" @create="create"
|
||||
:create-tip="btnTips" :title="title"/>
|
||||
</template>
|
||||
<el-table :data="items" style="width: 100%">
|
||||
<el-table :data="items" style="width: 100%" @sort-change="sort">
|
||||
<el-table-column prop="name" :label="$t('commons.name')">
|
||||
<template v-slot:default="scope">
|
||||
<el-link type="info" @click="link(scope.row)">{{ scope.row.name }}</el-link>
|
||||
|
@ -15,6 +15,8 @@
|
|||
<el-table-column prop="description" :label="$t('commons.description')"/>
|
||||
<!--<el-table-column prop="workspaceName" :label="$t('project.owning_workspace')"/>-->
|
||||
<el-table-column
|
||||
sortable
|
||||
prop="createTime"
|
||||
:label="$t('commons.create_time')"
|
||||
show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
|
@ -22,6 +24,8 @@
|
|||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
sortable
|
||||
prop="updateTime"
|
||||
:label="$t('commons.update_time')"
|
||||
show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
|
@ -67,7 +71,7 @@
|
|||
import MsTableHeader from "../common/components/MsTableHeader";
|
||||
import MsTableOperator from "../common/components/MsTableOperator";
|
||||
import MsDialogFooter from "../common/components/MsDialogFooter";
|
||||
import {getCurrentUser} from "../../../common/js/utils";
|
||||
import {_sort, getCurrentUser} from "../../../common/js/utils";
|
||||
import MsContainer from "../common/components/MsContainer";
|
||||
import MsMainContainer from "../common/components/MsMainContainer";
|
||||
|
||||
|
@ -228,7 +232,11 @@
|
|||
path: '/api/test/list/' + row.id
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
sort(column) {
|
||||
_sort(column, this.condition);
|
||||
this.list();
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue