提交 e018f744 编写于 作者: C chenjianxing

Merge branch 'dev' of https://github.com/fit2cloudrd/metersphere-server into dev

......@@ -3,8 +3,6 @@ package io.metersphere.commons.constants;
public class RoleConstants {
public final static String ADMIN = "admin";
public final static String ORG_ADMIN = "org_admin";
// 组织内其它角色
public final static String ORG_OTHER = "org_other";
public final static String TEST_VIEWER = "test_viewer";
public final static String TEST_MANAGER = "test_manager";
public final static String TEST_USER = "test_user";
......
......@@ -82,6 +82,11 @@ public class ReportController {
return reportService.getLoadChartData(reportId);
}
@GetMapping("/content/res_chart/{reportId}")
public ChartsData getResponseTimeChartData(@PathVariable String reportId) {
return reportService.getResponseTimeChartData(reportId);
}
@GetMapping("/{reportId}")
public LoadTestReport getLoadTestReport(@PathVariable String reportId) {
return reportService.getLoadTestReport(reportId);
......
......@@ -89,7 +89,8 @@ public class JmeterDocumentParser implements DocumentParser {
processCheckoutConfigTestElement(ele);
processCheckoutDnsCacheManager(ele);
processCheckoutArguments(ele);
processCheckoutResponseAssertion(ele);
// TODO: 2020/4/3 使用断言导致backend-listener不可用
// processCheckoutResponseAssertion(ele);
} else if (nodeNameEquals(ele, CONCURRENCY_THREAD_GROUP)) {
processConcurrencyThreadGroup(ele);
processCheckoutTimer(ele);
......@@ -111,7 +112,8 @@ public class JmeterDocumentParser implements DocumentParser {
} else if (nodeNameEquals(ele, ARGUMENTS)) {
processArguments(ele);
} else if (nodeNameEquals(ele, RESPONSE_ASSERTION)) {
processResponseAssertion(ele);
// TODO: 2020/4/3 使用断言导致backend-listener不可用
// processResponseAssertion(ele);
}
}
}
......@@ -123,13 +125,12 @@ public class JmeterDocumentParser implements DocumentParser {
for (int i = 0; i < childNodes.getLength(); i++) {
Node item = childNodes.item(i);
if (item instanceof Element && nodeNameEquals(item, "collectionProp")) {
removeChildren(item);
Document document = item.getOwnerDocument();
Object params = context.getProperty("statusCode");
if (params instanceof List) {
HashSet set = new HashSet((List) params);
for (Object p : set) {
element.appendChild(createStringProp(document, p.toString(), p.toString()));
item.appendChild(createStringProp(document, p.toString(), p.toString()));
}
}
}
......@@ -152,6 +153,15 @@ public class JmeterDocumentParser implements DocumentParser {
Node item = childNodes.item(i);
if (nodeNameEquals(item, RESPONSE_ASSERTION)) {
// 如果已经存在,不再添加
removeChildren(item);
Element collectionProp = document.createElement(COLLECTION_PROP);
collectionProp.setAttribute("name", "Asserion.test_strings");
//
item.appendChild(collectionProp);
item.appendChild(createStringProp(document, "Assertion.custom_message", ""));
item.appendChild(createStringProp(document, "Assertion.test_field", "Assertion.response_code"));
item.appendChild(createBoolProp(document, "Assertion.assume_success", false));
item.appendChild(createIntProp(document, "Assertion.test_type", 40));
return;
}
}
......@@ -179,9 +189,9 @@ public class JmeterDocumentParser implements DocumentParser {
//
responseAssertion.appendChild(collectionProp);
responseAssertion.appendChild(createStringProp(document, "Assertion.custom_message", ""));
responseAssertion.appendChild(createStringProp(document, "Assertion.test_field", ""));
responseAssertion.appendChild(createStringProp(document, "Assertion.test_field", "Assertion.response_code"));
responseAssertion.appendChild(createBoolProp(document, "Assertion.assume_success", false));
responseAssertion.appendChild(createIntProp(document, "Assertion.test_type", 33));
responseAssertion.appendChild(createIntProp(document, "Assertion.test_type", 40));
hashTree.appendChild(responseAssertion);
hashTree.appendChild(document.createElement(HASH_TREE_ELEMENT));
}
......@@ -352,7 +362,7 @@ public class JmeterDocumentParser implements DocumentParser {
for (int i = 0; i < childNodes.getLength(); i++) {
Node item = childNodes.item(i);
if (item instanceof Element && nodeNameEquals(item, "collectionProp")) {
removeChildren(item);
//
Document document = item.getOwnerDocument();
Object params = context.getProperty("params");
if (params instanceof List) {
......@@ -377,31 +387,33 @@ public class JmeterDocumentParser implements DocumentParser {
private void processDnsCacheManager(Element ele) {
Object domains = context.getProperty("domains");
if (!(domains instanceof List)) {
return;
}
if (((List) domains).size() == 0) {
return;
}
NodeList childNodes = ele.getChildNodes();
for (int i = 0, size = childNodes.getLength(); i < size; i++) {
Node item = childNodes.item(i);
if (item instanceof Element && nodeNameEquals(item, "collectionProp")
&& org.apache.commons.lang3.StringUtils.equals(((Element) item).getAttribute("name"), "DNSCacheManager.hosts")) {
removeChildren(item);
Document document = item.getOwnerDocument();
Object domains = context.getProperty("domains");
if (domains instanceof List) {
for (Object d : (List) domains) {
JSONObject jsonObject = JSON.parseObject(d.toString());
if (!jsonObject.getBooleanValue("enable")) {
continue;
}
Element elementProp = document.createElement("elementProp");
elementProp.setAttribute("name", jsonObject.getString("domain"));
elementProp.setAttribute("elementType", "StaticHost");
elementProp.appendChild(createStringProp(document, "StaticHost.Name", jsonObject.getString("domain")));
elementProp.appendChild(createStringProp(document, "StaticHost.Address", jsonObject.getString("ip")));
item.appendChild(elementProp);
for (Object d : (List) domains) {
JSONObject jsonObject = JSON.parseObject(d.toString());
if (!jsonObject.getBooleanValue("enable")) {
continue;
}
Element elementProp = document.createElement("elementProp");
elementProp.setAttribute("name", jsonObject.getString("domain"));
elementProp.setAttribute("elementType", "StaticHost");
elementProp.appendChild(createStringProp(document, "StaticHost.Name", jsonObject.getString("domain")));
elementProp.appendChild(createStringProp(document, "StaticHost.Address", jsonObject.getString("ip")));
item.appendChild(elementProp);
}
}
if (item instanceof Element && nodeNameEquals(item, "boolProp")
&& org.apache.commons.lang3.StringUtils.equals(((Element) item).getAttribute("name"), "DNSCacheManager.isCustomResolver")) {
item.getFirstChild().setNodeValue("true");
......
......@@ -5,6 +5,7 @@ import io.metersphere.base.domain.LoadTestReportExample;
import io.metersphere.base.domain.LoadTestReportWithBLOBs;
import io.metersphere.base.mapper.LoadTestReportMapper;
import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper;
import io.metersphere.commons.constants.TestStatus;
import io.metersphere.commons.exception.MSException;
import io.metersphere.controller.request.ReportRequest;
import io.metersphere.dto.ReportDTO;
......@@ -52,6 +53,7 @@ public class ReportService {
}
public RequestStatisticsDTO getReport(String id) {
checkReportStatus(id);
LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(id);
String content = loadTestReport.getContent();
RequestStatisticsDTO requestStatistics = JtlResolver.getRequestStatistics(content);
......@@ -59,6 +61,7 @@ public class ReportService {
}
public List<Errors> getReportErrors(String id) {
checkReportStatus(id);
LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(id);
String content = loadTestReport.getContent();
List<Errors> errors = JtlResolver.getErrorsList(content);
......@@ -66,6 +69,7 @@ public class ReportService {
}
public ErrorsTop5DTO getReportErrorsTOP5(String id) {
checkReportStatus(id);
LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(id);
String content = loadTestReport.getContent();
ErrorsTop5DTO errors = JtlResolver.getErrorsTop5DTO(content);
......@@ -73,6 +77,7 @@ public class ReportService {
}
public TestOverview getTestOverview(String id) {
checkReportStatus(id);
LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(id);
String content = loadTestReport.getContent();
TestOverview testOverview = JtlResolver.getTestOverview(content);
......@@ -80,19 +85,30 @@ public class ReportService {
}
public ChartsData getLoadChartData(String id) {
checkReportStatus(id);
LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(id);
String content = loadTestReport.getContent();
ChartsData chartsData = JtlResolver.getLoadChartData(content);
return chartsData;
}
// public void checkReportStatus(String id) {
// LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(id);
// String status=loadTestReport.getStatus();
// if (StringUtils.equals("Error",status)) {
// MSException.throwException("test run error!");
// }
// }
public ChartsData getResponseTimeChartData(String id) {
checkReportStatus(id);
LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(id);
String content = loadTestReport.getContent();
ChartsData chartsData = JtlResolver.getResponseTimeChartData(content);
return chartsData;
}
public void checkReportStatus(String reportId) {
LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId);
String reportStatus = loadTestReport.getStatus();
if (StringUtils.equals(TestStatus.Running.name(), reportStatus)) {
MSException.throwException("Reporting in progress...");
} else if (StringUtils.equals(TestStatus.Error.name(), reportStatus)) {
MSException.throwException("Report generation error!");
}
}
public LoadTestReport getLoadTestReport(String id) {
return extLoadTestReportMapper.selectByPrimaryKey(id);
......
......@@ -129,7 +129,21 @@
data() {
return {
tableData: [{},{},{},{},{}],
errorTotal: {},
errorTotal: {
label: '',
totalSamples: '',
totalErrors: '',
error1: '',
error1Size: '',
error2: '',
error2Size: '',
error3: '',
error3Size: '',
error4: '',
error4Size: '',
error5: '',
error5Size: ''
},
errorTop5: []
}
},
......
......@@ -80,7 +80,19 @@
data() {
return {
tableData: [{},{},{},{},{}],
totalInfo: {}
totalInfo: {
totalLabel: '',
totalSamples: '',
totalErrors: '',
totalAverage: '',
totalMin: '',
totalMax: '',
totalTP90: '',
totalTP95: '',
totalTP99: '',
totalAvgHits: '',
totalAvgBandwidth: ''
}
}
},
methods: {
......
......@@ -22,11 +22,6 @@
width="150"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="description"
:label="$t('commons.description')"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="projectName"
:label="$t('load_test.project_name')"
......@@ -47,6 +42,29 @@
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column
prop="status"
:label="$t('commons.status')">
<template v-slot:default="{row}">
<el-tag size="mini" type="primary" v-if="row.status === 'Starting'">
{{ row.status }}
</el-tag>
<el-tag size="mini" type="success" v-else-if="row.status === 'Running'">
{{ row.status }}
</el-tag>
<el-tooltip placement="top" v-else-if="row.status === 'Error'" effect="light">
<template v-slot:content>
<div>{{row.description}}</div>
</template>
<el-tag size="mini" type="danger">
{{ row.status }}
</el-tag>
</el-tooltip>
<el-tag size="mini" type="info" v-else>
{{ row.status }}
</el-tag>
</template>
</el-table-column>
<el-table-column
width="150"
:label="$t('commons.operating')">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册