Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Captain.B 2020-04-20 17:20:34 +08:00
commit c50b8f2836
5 changed files with 166 additions and 100 deletions

View File

@ -1,14 +1,16 @@
package io.metersphere.service;
import io.metersphere.base.domain.LoadTestReport;
import io.metersphere.base.domain.LoadTestReportExample;
import io.metersphere.base.domain.LoadTestReportWithBLOBs;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.LoadTestMapper;
import io.metersphere.base.mapper.LoadTestReportMapper;
import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper;
import io.metersphere.commons.constants.PerformanceTestStatus;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.controller.request.ReportRequest;
import io.metersphere.dto.ReportDTO;
import io.metersphere.engine.Engine;
import io.metersphere.engine.EngineFactory;
import io.metersphere.report.JtlResolver;
import io.metersphere.report.base.ChartsData;
import io.metersphere.report.base.Errors;
@ -31,6 +33,8 @@ public class ReportService {
private LoadTestReportMapper loadTestReportMapper;
@Resource
private ExtLoadTestReportMapper extLoadTestReportMapper;
@Resource
private LoadTestMapper loadTestMapper;
public List<LoadTestReport> getRecentReportList(ReportRequest request) {
LoadTestReportExample example = new LoadTestReportExample();
@ -46,9 +50,38 @@ public class ReportService {
}
public void deleteReport(String reportId) {
if (StringUtils.isBlank(reportId)) {
MSException.throwException("report id cannot be null");
}
LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId);
LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(loadTestReport.getTestId());
LogUtil.info("Delete report started, report ID: %s" + reportId);
final Engine engine = EngineFactory.createEngine(loadTest);
if (engine == null) {
MSException.throwException(String.format("Delete report fail. create engine failreport ID%s", reportId));
}
String reportStatus = loadTestReport.getStatus();
boolean isRunning = StringUtils.equals(reportStatus, PerformanceTestStatus.Running.name());
boolean isStarting = StringUtils.equals(reportStatus, PerformanceTestStatus.Starting.name());
boolean isError = StringUtils.equals(reportStatus, PerformanceTestStatus.Error.name());
if (isRunning || isStarting || isError) {
LogUtil.info("Start stop engine, report status: %s" + reportStatus);
stopEngine(loadTest, engine);
}
loadTestReportMapper.deleteByPrimaryKey(reportId);
}
private void stopEngine(LoadTestWithBLOBs loadTest, Engine engine) {
engine.stop();
loadTest.setStatus(PerformanceTestStatus.Saved.name());
loadTestMapper.updateByPrimaryKeySelective(loadTest);
}
public ReportDTO getReportTestAndProInfo(String reportId) {
return extLoadTestReportMapper.getReportTestAndProInfo(reportId);
}

View File

@ -1,27 +1,25 @@
<template>
<div class="container">
<div class="main-content">
<el-container>
<el-aside width="250px">
<el-card>
<el-container class="case-container">
<el-aside class="tree-aside">
<select-menu
:data="projects"
:current-data="currentProject"
:title="$t('test_track.project')"
@dataChange="changeProject">
</select-menu>
<node-tree class="node-tree"
:current-project="currentProject"
@nodeSelectEvent="refreshTable"
@refresh="refreshTable"
ref="nodeTree">
</node-tree>
</el-aside>
<el-main class="main-content">
<el-main class="case-main">
<test-case-list
:current-project="currentProject"
@openTestCaseEditDialog="openTestCaseEditDialog"
@ -30,7 +28,6 @@
ref="testCaseList">
</test-case-list>
</el-main>
</el-container>
<test-case-edit
@ -38,6 +35,7 @@
ref="testCaseEditDialog">
</test-case-edit>
</el-card>
</div>
</div>
</template>
@ -174,7 +172,6 @@
openRecentTestCaseEditDialog() {
let caseId = this.$route.params.caseId;
this.getProjectByCaseId(caseId);
// this.refresh();
this.$get('/test/case/get/' + caseId, response => {
if (response.data) {
this.openTestCaseEditDialog(response.data);
@ -206,20 +203,25 @@
<style scoped>
.main-content {
width: 100%;
height: 100%;
background: white;
height: 1000px;
.node-tree {
margin: 3%;
}
.tree-aside {
position: relative;
border-radius: 4px;
border: 1px solid #EBEEF5;
box-sizing: border-box;
}
.node-tree {
margin: 5%;
.case-container {
height: calc(100vh - 150px);
min-height: 600px;
}
.container {
padding: 0px;
.case-main {
padding-top: 0;
}
</style>

View File

@ -1,8 +1,9 @@
<template>
<div class="container">
<div class="main-content">
<el-container>
<el-aside class="aside-container" width="250px">
<el-card>
<el-container class="view-container">
<el-aside class="tree-aside">
<select-menu
:data="testPlans"
:current-data="currentPlan"
@ -19,7 +20,7 @@
</el-aside>
<el-main>
<el-main class="view-main">
<test-plan-test-case-list
@openTestCaseRelevanceDialog="openTestCaseRelevanceDialog"
@refresh="refresh"
@ -31,8 +32,9 @@
<test-case-relevance
@refresh="refresh"
:plan-id="planId"
ref="testCaseRelevance"></test-case-relevance>
ref="testCaseRelevance">
</test-case-relevance>
</el-card>
</div>
</div>
@ -98,22 +100,25 @@
<style scoped>
.main-content {
padding: 0px;
background: white;
height: 600px;
}
.container {
padding: 0px;
}
.aside-container {
margin-left: 15px;
}
.node-tree {
margin: 3%;
}
.view-container {
height: calc(100vh - 150px);
min-height: 600px;
}
.tree-aside {
position: relative;
border-radius: 4px;
border: 1px solid #EBEEF5;
box-sizing: border-box;
}
.view-main {
padding-top: 0;
}
</style>

View File

@ -11,7 +11,7 @@
<el-header>
<el-row type="flex" style="margin-top: 1%" justify="end">
<el-row type="flex" class="head-bar">
<el-col :span="12">
<el-button plain size="mini"
@ -20,11 +20,11 @@
</el-col>
<el-col :span="12" class="head-right">
<span v-if="index + 1 == tableData.length">
上一条用例 : {{tableData[index - 1].name}}
<span class="head-right-tip" v-if="index + 1 == tableData.length">
上一条用例 : {{tableData ? tableData[index - 1].name : ''}}
</span>
<span v-if="index + 1 < tableData.length">
下一条用例 : {{tableData[index + 1].name}}
<span class="head-right-tip" v-if="index + 1 < tableData.length">
下一条用例 : {{tableData ? tableData[index + 1].name : ''}}
</span>
<el-button plain size="mini" icon="el-icon-arrow-up"
@ -90,7 +90,7 @@
class="tb-edit"
size="mini"
height="250px"
border="true"
:border="true"
:default-sort = "{prop: 'num', order: 'ascending'}"
highlight-current-row>
<el-table-column :label="$t('test_track.number')" prop="num" min-width="5%"></el-table-column>
@ -121,10 +121,10 @@
<el-select
v-model="scope.row.executeResult"
size="mini">
<el-option :label="$t('test_track.pass')" value="Pass"></el-option>
<el-option :label="$t('test_track.failure')" value="Failure"></el-option>
<el-option :label="$t('test_track.blocking')" value="Blocking"></el-option>
<el-option :label="$t('test_track.skip')" value="Skip"></el-option>
<el-option :label="$t('test_track.pass')" value="Pass" style="color: #7ebf50;"></el-option>
<el-option :label="$t('test_track.failure')" value="Failure" style="color: #e57471;"></el-option>
<el-option :label="$t('test_track.blocking')" value="Blocking" style="color: #dda451;"></el-option>
<el-option :label="$t('test_track.skip')" value="Skip" style="color: #919399;"></el-option>
</el-select>
</template>
</el-table-column>
@ -263,7 +263,14 @@
.status-button {
float: right;
margin-right: 1px;
}
.head-bar {
margin-top: 1%;
}
.head-right-tip {
color: darkgrey;
}
</style>

View File

@ -1,6 +1,6 @@
<template>
<el-main class="main-content">
<el-main>
<el-card v-loading="result.loading">
<template v-slot:header>
<div>
@ -67,6 +67,24 @@
<el-table-column
prop="priority"
:label="$t('test_track.priority')">
<template v-slot:default="scope">
<el-tag v-if="scope.row.priority == 'P0'"
type="danger"
effect="dark"
size="mini">{{scope.row.priority}}</el-tag>
<el-tag v-if="scope.row.priority == 'P1'"
type="danger"
effect="light"
size="mini">{{scope.row.priority}}</el-tag>
<el-tag v-if="scope.row.priority == 'P2'"
type="warning"
effect="dark"
size="mini">{{scope.row.priority}}</el-tag>
<el-tag v-if="scope.row.priority == 'P3'"
type="warning"
effect="light"
size="mini">{{scope.row.priority}}</el-tag>
</template>
</el-table-column>
<el-table-column
@ -101,7 +119,8 @@
:label="$t('test_track.execute_result')">
<template v-slot:default="scope">
<el-tag v-if="scope.row.status == 'Prepare'"
e ffect="info"
type="info"
effect="dark"
size="mini">{{$t('test_track.plan_status_prepare')}}</el-tag>
<el-tag v-if="scope.row.status == 'Pass'"
type="success"