adjust the report and remove some bugs
This commit is contained in:
parent
c75675145a
commit
0591a35e22
|
@ -162,12 +162,17 @@ public class TestPlanController extends BaseController {
|
||||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
ScriptBriefResultModel result = new ScriptBriefResultModel();
|
||||||
|
|
||||||
TestPlanContext context = this.getTestPlanContainer()
|
TestPlanContext context = this.getTestPlanContainer()
|
||||||
.getRunningTestPlans().get(testPlanId);
|
.getRunningTestPlans().get(testPlanId);
|
||||||
|
if (context == null) {
|
||||||
|
result.setFinished(true);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
RunningScriptModel scriptModel = context.getRunningScriptMap().get(
|
RunningScriptModel scriptModel = context.getRunningScriptMap().get(
|
||||||
new Integer(scriptId));
|
new Integer(scriptId));
|
||||||
if (scriptModel == null || scriptModel.isFinish()) {
|
if (scriptModel == null || scriptModel.isFinish()) {
|
||||||
ScriptBriefResultModel result = new ScriptBriefResultModel();
|
|
||||||
result.setFinished(true);
|
result.setFinished(true);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,9 @@ import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.bench4q.master.communication.agent.scriptrecord.UsePluginModel;
|
||||||
|
import org.bench4q.master.communication.agent.scriptrecord.UserBehaviorModel;
|
||||||
|
|
||||||
@XmlRootElement(name = "runScenario")
|
@XmlRootElement(name = "runScenario")
|
||||||
public class RunScenarioModel {
|
public class RunScenarioModel {
|
||||||
private int poolSize;
|
private int poolSize;
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package org.bench4q.master.communication.agent.scriptrecord;
|
||||||
|
|
||||||
|
public abstract class BehaviorBaseModel {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
package org.bench4q.master.communication.agent.scriptrecord;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.xml.bind.JAXBContext;
|
||||||
|
import javax.xml.bind.JAXBException;
|
||||||
|
import javax.xml.bind.Marshaller;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.bench4q.master.communication.agent.ParameterModel;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "timerBehavior")
|
||||||
|
public class TimerBehaviorModel {
|
||||||
|
private String use;
|
||||||
|
private String name;
|
||||||
|
private List<ParameterModel> parameters;
|
||||||
|
|
||||||
|
@XmlElement
|
||||||
|
public String getUse() {
|
||||||
|
return use;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUse(String use) {
|
||||||
|
this.use = use;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElementWrapper(name = "parameters")
|
||||||
|
@XmlElement(name = "parameter")
|
||||||
|
public List<ParameterModel> getParameters() {
|
||||||
|
return parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParameters(List<ParameterModel> parameters) {
|
||||||
|
this.parameters = parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModelString() throws JAXBException {
|
||||||
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
|
Marshaller marshaller = JAXBContext.newInstance(this.getClass())
|
||||||
|
.createMarshaller();
|
||||||
|
marshaller.marshal(this, os);
|
||||||
|
return os.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package org.bench4q.master.communication.agent;
|
package org.bench4q.master.communication.agent.scriptrecord;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.bench4q.master.communication.agent.ParameterModel;
|
||||||
|
|
||||||
@XmlRootElement(name = "usePlugin")
|
@XmlRootElement(name = "usePlugin")
|
||||||
public class UsePluginModel {
|
public class UsePluginModel {
|
||||||
private String id;
|
private String id;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.bench4q.master.communication.agent;
|
package org.bench4q.master.communication.agent.scriptrecord;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -10,8 +10,10 @@ import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.bench4q.master.communication.agent.ParameterModel;
|
||||||
|
|
||||||
@XmlRootElement(name = "userBehavior")
|
@XmlRootElement(name = "userBehavior")
|
||||||
public class UserBehaviorModel {
|
public class UserBehaviorModel extends BehaviorBaseModel {
|
||||||
private String use;
|
private String use;
|
||||||
private String name;
|
private String name;
|
||||||
private List<ParameterModel> parameters;
|
private List<ParameterModel> parameters;
|
|
@ -0,0 +1,36 @@
|
||||||
|
package org.bench4q.master.entity.db;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "fortest")
|
||||||
|
public class ForTest {
|
||||||
|
private int id;
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "id", nullable = false)
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Column(name = "content", columnDefinition = "LONGTEXT", nullable = false)
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -51,7 +51,7 @@ public class MonitorResult {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "content", columnDefinition = "TEXT", nullable = false)
|
@Column(name = "content", columnDefinition = "LONGTEXT", nullable = false)
|
||||||
public String getContent() {
|
public String getContent() {
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class Script {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "scriptContent", columnDefinition = "TEXT", nullable = false)
|
@Column(name = "scriptContent", columnDefinition = "LONGTEXT", nullable = false)
|
||||||
@XmlElement
|
@XmlElement
|
||||||
public String getScriptContent() {
|
public String getScriptContent() {
|
||||||
return scriptContent;
|
return scriptContent;
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class TestPlan {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "testPlanModelContent", columnDefinition = "Text", nullable = false)
|
@Column(name = "testPlanModelContent", columnDefinition = "LONGText", nullable = false)
|
||||||
public String getTestPlanModelContent() {
|
public String getTestPlanModelContent() {
|
||||||
return testPlanModelContent;
|
return testPlanModelContent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,17 @@ import javax.persistence.Table;
|
||||||
public class TestPlanScriptResult {
|
public class TestPlanScriptResult {
|
||||||
private int id;
|
private int id;
|
||||||
private TestPlanScript testPlanScript;
|
private TestPlanScript testPlanScript;
|
||||||
private long totalSuccessCount;
|
private long totalSuccessCountFromBegin;
|
||||||
private long totalFailCount;
|
private long totalFailCountFromBegin;
|
||||||
private long totalFinishedCount;
|
|
||||||
private long averageResponseTime;
|
private long averageResponseTime;
|
||||||
|
private long maxResponseTime;
|
||||||
|
private long minResposneTime;
|
||||||
|
private long successThroughputThisTime;
|
||||||
|
private long failThroughputThisTime;
|
||||||
|
private long responseTimeDeviationThisTime;
|
||||||
|
private long failRateThisTime;
|
||||||
|
|
||||||
private long averageElapsedTime;
|
private long averageElapsedTime;
|
||||||
private Date createDatetime;
|
private Date createDatetime;
|
||||||
|
|
||||||
|
@ -44,31 +51,22 @@ public class TestPlanScriptResult {
|
||||||
this.testPlanScript = testPlanScript;
|
this.testPlanScript = testPlanScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "totalSuccessCount", nullable = false)
|
@Column(name = "totalSuccessCountFromBegin", nullable = false)
|
||||||
public long getTotalSuccessCount() {
|
public long getTotalSuccessCountFromBegin() {
|
||||||
return totalSuccessCount;
|
return totalSuccessCountFromBegin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTotalSuccessCount(long totalSuccessCount) {
|
public void setTotalSuccessCountFromBegin(long totalSuccessCountFromBegin) {
|
||||||
this.totalSuccessCount = totalSuccessCount;
|
this.totalSuccessCountFromBegin = totalSuccessCountFromBegin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "totalFailCount", nullable = false)
|
@Column(name = "totalFailCountFromBegin", nullable = false)
|
||||||
public long getTotalFailCount() {
|
public long getTotalFailCountFromBegin() {
|
||||||
return totalFailCount;
|
return totalFailCountFromBegin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTotalFailCount(long totalFailCount) {
|
public void setTotalFailCountFromBegin(long totalFailCountFromBegin) {
|
||||||
this.totalFailCount = totalFailCount;
|
this.totalFailCountFromBegin = totalFailCountFromBegin;
|
||||||
}
|
|
||||||
|
|
||||||
@Column(name = "totalFinishedCount", nullable = false)
|
|
||||||
public long getTotalFinishedCount() {
|
|
||||||
return totalFinishedCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotalFinishedCount(long totalFinishedCount) {
|
|
||||||
this.totalFinishedCount = totalFinishedCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "averageResponseTime", nullable = false)
|
@Column(name = "averageResponseTime", nullable = false)
|
||||||
|
@ -80,6 +78,61 @@ public class TestPlanScriptResult {
|
||||||
this.averageResponseTime = averageResponseTime;
|
this.averageResponseTime = averageResponseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Column(name = "maxResponseTime", nullable = false)
|
||||||
|
public long getMaxResponseTime() {
|
||||||
|
return maxResponseTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxResponseTime(long maxResponseTime) {
|
||||||
|
this.maxResponseTime = maxResponseTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Column(name = "minResposneTime", nullable = false)
|
||||||
|
public long getMinResposneTime() {
|
||||||
|
return minResposneTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinResposneTime(long minResposneTime) {
|
||||||
|
this.minResposneTime = minResposneTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Column(name = "successThroughputThisTime", nullable = false)
|
||||||
|
public long getSuccessThroughputThisTime() {
|
||||||
|
return successThroughputThisTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuccessThroughputThisTime(long successThroughputThisTime) {
|
||||||
|
this.successThroughputThisTime = successThroughputThisTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Column(name = "failThroughputThisTime", nullable = false)
|
||||||
|
public long getFailThroughputThisTime() {
|
||||||
|
return failThroughputThisTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFailThroughputThisTime(long failThroughputThisTime) {
|
||||||
|
this.failThroughputThisTime = failThroughputThisTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Column(name = "responseTimeDeviationThisTime", nullable = false)
|
||||||
|
public long getResponseTimeDeviationThisTime() {
|
||||||
|
return responseTimeDeviationThisTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResponseTimeDeviationThisTime(
|
||||||
|
long responseTimeDeviationThisTime) {
|
||||||
|
this.responseTimeDeviationThisTime = responseTimeDeviationThisTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Column(name = "failRateThisTime", nullable = false)
|
||||||
|
public long getFailRateThisTime() {
|
||||||
|
return failRateThisTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFailRateThisTime(long failRateThisTime) {
|
||||||
|
this.failRateThisTime = failRateThisTime;
|
||||||
|
}
|
||||||
|
|
||||||
@Column(name = "averageElapsedTime", nullable = false)
|
@Column(name = "averageElapsedTime", nullable = false)
|
||||||
public long getAverageElapsedTime() {
|
public long getAverageElapsedTime() {
|
||||||
return averageElapsedTime;
|
return averageElapsedTime;
|
||||||
|
|
|
@ -28,10 +28,10 @@ import com.lowagie.text.Document;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class MonitorReportService {
|
public class MonitorReportService {
|
||||||
public static String Processor = "ProcessorTimePercent";
|
public static String Processor = "ProcessorTimePercent (unit: %)";
|
||||||
public static String Memory = "Memory";
|
public static String Memory = "Memory Available Memory(unit: KiloByte)";
|
||||||
public static String logical_Disk = "logicalDisk";
|
public static String logical_Disk = "logicalDisk IO (unit: Byte)";
|
||||||
public static String network_Interface = "networkInterface";
|
public static String network_Interface = "networkInterface IO (unit: Byte/second)";
|
||||||
private TestPlanScriptService testPlanScriptService;
|
private TestPlanScriptService testPlanScriptService;
|
||||||
private TestPlanService testPlanService;
|
private TestPlanService testPlanService;
|
||||||
private MonitorResultService monitorResultService;
|
private MonitorResultService monitorResultService;
|
||||||
|
@ -166,14 +166,14 @@ public class MonitorReportService {
|
||||||
int seriesCount = list.get(0).getProcessorModel()
|
int seriesCount = list.get(0).getProcessorModel()
|
||||||
.getProcessorModelList().size();
|
.getProcessorModelList().size();
|
||||||
|
|
||||||
TimeSeries[] timeSeriesArray = ReportService.buildSeries(seriesCount,
|
List<TimeSeries> timeSeriesArray = ReportService.buildSeries(
|
||||||
Processor);
|
seriesCount, Processor);
|
||||||
|
|
||||||
for (MonitorProcessorResponseModel model : list) {
|
for (MonitorProcessorResponseModel model : list) {
|
||||||
for (int i = 0; i < timeSeriesArray.length; i++) {
|
for (int i = 0; i < timeSeriesArray.size(); i++) {
|
||||||
timeSeriesArray[i].addOrUpdate(
|
timeSeriesArray.get(i).addOrUpdate(
|
||||||
new Second(model.getCreateDatetime()), model
|
new Second(model.getCreateDatetime()),
|
||||||
.getProcessorModel().getProcessorModelList()
|
model.getProcessorModel().getProcessorModelList()
|
||||||
.get(i).getProcessorTimePercent());
|
.get(i).getProcessorTimePercent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,13 +190,13 @@ public class MonitorReportService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int seriesCount = 1;
|
int seriesCount = 1;
|
||||||
TimeSeries[] timeSeriesArray = ReportService.buildSeries(seriesCount,
|
List<TimeSeries> timeSeriesArray = ReportService.buildSeries(
|
||||||
Memory);
|
seriesCount, Memory);
|
||||||
for (MonitorMemoryResponseModel model : list) {
|
for (MonitorMemoryResponseModel model : list) {
|
||||||
for (int i = 0; i < timeSeriesArray.length; i++) {
|
for (int i = 0; i < timeSeriesArray.size(); i++) {
|
||||||
timeSeriesArray[i].addOrUpdate(
|
timeSeriesArray.get(i).addOrUpdate(
|
||||||
new Second(model.getCreateDatetime()), model
|
new Second(model.getCreateDatetime()),
|
||||||
.getMemoryModel().getPagesPerSecond());
|
model.getMemoryModel().getAvailableKiloBytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ReportService.writeImageIntoPdf(
|
ReportService.writeImageIntoPdf(
|
||||||
|
@ -212,15 +212,15 @@ public class MonitorReportService {
|
||||||
}
|
}
|
||||||
int seriesCount = list.get(0).getLogicalDiskModel()
|
int seriesCount = list.get(0).getLogicalDiskModel()
|
||||||
.getLogicalDiskList().size();
|
.getLogicalDiskList().size();
|
||||||
TimeSeries[] timeSeriesArray = ReportService.buildSeries(seriesCount,
|
List<TimeSeries> timeSeriesArray = ReportService.buildSeries(
|
||||||
logical_Disk);
|
seriesCount, logical_Disk);
|
||||||
|
|
||||||
for (MonitorLogicalDiskResponseModel model : list) {
|
for (MonitorLogicalDiskResponseModel model : list) {
|
||||||
for (int i = 0; i < timeSeriesArray.length; i++) {
|
for (int i = 0; i < timeSeriesArray.size(); i++) {
|
||||||
timeSeriesArray[i].addOrUpdate(
|
timeSeriesArray.get(i).addOrUpdate(
|
||||||
new Second(model.getCreateDatetime()), model
|
new Second(model.getCreateDatetime()),
|
||||||
.getLogicalDiskModel().getLogicalDiskList()
|
model.getLogicalDiskModel().getLogicalDiskList().get(i)
|
||||||
.get(i).getDiskTimePercent());
|
.getDiskBytesPerSecond());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,19 +229,27 @@ public class MonitorReportService {
|
||||||
timeSeriesArray, logical_Disk).toByteArray(), document);
|
timeSeriesArray, logical_Disk).toByteArray(), document);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* refactor this kind of use
|
||||||
|
*
|
||||||
|
* @param list
|
||||||
|
* @param document
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
|
||||||
private void createNetworkImage(List<MonitorNetWorkReponseModel> list,
|
private void createNetworkImage(List<MonitorNetWorkReponseModel> list,
|
||||||
Document document) throws Exception {
|
Document document) throws Exception {
|
||||||
if (list == null || list.size() == 0) {
|
if (list == null || list.size() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int seriesCount = list.get(0).getModel().getNetworkList().size();
|
int seriesCount = list.get(0).getModel().getNetworkList().size();
|
||||||
TimeSeries[] timeSeriesArray = ReportService.buildSeries(seriesCount,
|
List<TimeSeries> timeSeriesArray = ReportService.buildSeries(
|
||||||
network_Interface);
|
seriesCount, network_Interface);
|
||||||
for (MonitorNetWorkReponseModel model : list) {
|
for (MonitorNetWorkReponseModel model : list) {
|
||||||
for (int i = 0; i < timeSeriesArray.length; i++) {
|
for (int i = 0; i < timeSeriesArray.size(); i++) {
|
||||||
timeSeriesArray[i].addOrUpdate(
|
timeSeriesArray.get(i).addOrUpdate(
|
||||||
new Second(model.getCreateDatetime()), model.getModel()
|
new Second(model.getCreateDatetime()),
|
||||||
.getNetworkList().get(i)
|
model.getModel().getNetworkList().get(i)
|
||||||
.getBytesTotalPerSecond());
|
.getBytesTotalPerSecond());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,22 @@
|
||||||
package org.bench4q.master.report;
|
package org.bench4q.master.report;
|
||||||
|
|
||||||
|
import java.awt.BasicStroke;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Font;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.jfree.chart.ChartFactory;
|
import org.jfree.chart.ChartFactory;
|
||||||
import org.jfree.chart.ChartUtilities;
|
import org.jfree.chart.ChartUtilities;
|
||||||
import org.jfree.chart.JFreeChart;
|
import org.jfree.chart.JFreeChart;
|
||||||
|
import org.jfree.chart.plot.XYPlot;
|
||||||
|
import org.jfree.chart.title.TextTitle;
|
||||||
import org.jfree.data.time.TimeSeries;
|
import org.jfree.data.time.TimeSeries;
|
||||||
import org.jfree.data.time.TimeSeriesCollection;
|
import org.jfree.data.time.TimeSeriesCollection;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -25,10 +32,11 @@ import com.lowagie.text.pdf.PdfWriter;
|
||||||
@Component
|
@Component
|
||||||
public class ReportService {
|
public class ReportService {
|
||||||
public static String Time = "time";
|
public static String Time = "time";
|
||||||
// public static String Pdf_Path = "test.pdf";
|
|
||||||
public static String PDF_FOLDER = "report";
|
public static String PDF_FOLDER = "report";
|
||||||
private ScriptReportService scriptReportService;
|
private ScriptReportService scriptReportService;
|
||||||
private MonitorReportService monitorReportService;
|
private MonitorReportService monitorReportService;
|
||||||
|
private static int PICTURE_WIDTH = 500;
|
||||||
|
private static int PICTURE_HIGHT = 600;
|
||||||
|
|
||||||
public ScriptReportService getScriptReportService() {
|
public ScriptReportService getScriptReportService() {
|
||||||
return scriptReportService;
|
return scriptReportService;
|
||||||
|
@ -91,39 +99,62 @@ public class ReportService {
|
||||||
document.add(paragraph);
|
document.add(paragraph);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ByteArrayOutputStream buildChartStream(Document document,
|
public static ByteArrayOutputStream buildChartStream(Document document,
|
||||||
int seriesCount, TimeSeries[] timeSeriesArray, String value)
|
int seriesCount, List<TimeSeries> timeSeriesArray, String value)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
JFreeChart chart = ChartFactory.createTimeSeriesChart(value,
|
JFreeChart chart = ChartFactory.createTimeSeriesChart(value,
|
||||||
ReportService.Time, value, buildDataSet(timeSeriesArray), true,
|
ReportService.Time, value, buildDataSet(timeSeriesArray), true,
|
||||||
true, true);
|
true, true);
|
||||||
chart.setBackgroundPaint(java.awt.Color.white);
|
adjustChartFont(value, chart);
|
||||||
ChartUtilities.writeChartAsPNG(outputStream, chart, 400, 300);
|
|
||||||
|
ChartUtilities.writeChartAsPNG(outputStream, chart, PICTURE_WIDTH,
|
||||||
|
PICTURE_HIGHT);
|
||||||
return outputStream;
|
return outputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TimeSeries[] buildSeries(int seriesCount, String mainTitle) {
|
private static void adjustChartFont(String value, JFreeChart chart) {
|
||||||
TimeSeries[] timeSeriesArray = new TimeSeries[seriesCount];
|
Font xfont = new Font("ËÎÌå", Font.CENTER_BASELINE, 14);// X
|
||||||
|
Font yfont = new Font("ËÎÌå", Font.CENTER_BASELINE, 14);// Y
|
||||||
|
Font kfont = new Font("ËÎÌå", Font.CENTER_BASELINE, 12);//
|
||||||
|
Font titleFont = new Font("΢ÈíÑźÚ", Font.CENTER_BASELINE, 16); // title
|
||||||
|
|
||||||
|
chart.setBorderStroke(new BasicStroke(1));
|
||||||
|
chart.setBorderVisible(true);
|
||||||
|
chart.setBorderPaint(Color.cyan);
|
||||||
|
|
||||||
|
chart.setTitle(new TextTitle(value, titleFont));
|
||||||
|
XYPlot plot = chart.getXYPlot();
|
||||||
|
plot.getRangeAxis().setLabelFont(yfont);
|
||||||
|
plot.getRangeAxis().setTickLabelFont(kfont);
|
||||||
|
plot.getDomainAxis().setLabelFont(xfont);
|
||||||
|
plot.getDomainAxis().setTickLabelFont(kfont);
|
||||||
|
chart.setBackgroundPaint(java.awt.Color.white);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<TimeSeries> buildSeries(int seriesCount, String mainTitle) {
|
||||||
|
List<TimeSeries> timeSeriesArray = new ArrayList<TimeSeries>(
|
||||||
|
seriesCount);
|
||||||
for (int i = 0; i < seriesCount; i++) {
|
for (int i = 0; i < seriesCount; i++) {
|
||||||
timeSeriesArray[i] = new TimeSeries(mainTitle + "-" + i);
|
timeSeriesArray.add(new TimeSeries(mainTitle + "-" + i));
|
||||||
}
|
}
|
||||||
return timeSeriesArray;
|
return timeSeriesArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TimeSeriesCollection buildDataSet(final TimeSeries[] timeSeriesArray) {
|
static TimeSeriesCollection buildDataSet(
|
||||||
|
final List<TimeSeries> timeSeriesArray) {
|
||||||
TimeSeriesCollection lineDataset = new TimeSeriesCollection();
|
TimeSeriesCollection lineDataset = new TimeSeriesCollection();
|
||||||
if (timeSeriesArray == null) {
|
if (timeSeriesArray == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < timeSeriesArray.length; i++) {
|
for (TimeSeries timeSeries : timeSeriesArray) {
|
||||||
lineDataset.addSeries(timeSeriesArray[i]);
|
lineDataset.addSeries(timeSeries);
|
||||||
}
|
}
|
||||||
return lineDataset;
|
return lineDataset;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writeImageIntoPdf(byte[] buffer, Document document)
|
public static void writeImageIntoPdf(byte[] buffer, Document document)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Image image = Image.getInstance(buffer);
|
Image image = Image.getInstance(buffer);
|
||||||
image.setAlignment(Element.ALIGN_CENTER);
|
image.setAlignment(Element.ALIGN_CENTER);
|
||||||
|
|
|
@ -1,34 +1,32 @@
|
||||||
package org.bench4q.master.report;
|
package org.bench4q.master.report;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.bench4q.master.entity.db.TestPlanScript;
|
import org.bench4q.master.entity.db.TestPlanScript;
|
||||||
import org.bench4q.master.entity.db.TestPlanScriptResult;
|
import org.bench4q.master.entity.db.TestPlanScriptResult;
|
||||||
import org.bench4q.master.service.MonitorResultService;
|
import org.bench4q.master.service.MonitorResultService;
|
||||||
import org.bench4q.master.service.TestPlanScriptService;
|
import org.bench4q.master.service.TestPlanScriptService;
|
||||||
import org.bench4q.master.service.TestPlanService;
|
import org.bench4q.master.service.TestPlanService;
|
||||||
import org.jfree.chart.ChartFactory;
|
|
||||||
import org.jfree.chart.ChartUtilities;
|
|
||||||
import org.jfree.chart.JFreeChart;
|
|
||||||
import org.jfree.chart.title.TextTitle;
|
|
||||||
import org.jfree.data.time.Second;
|
import org.jfree.data.time.Second;
|
||||||
import org.jfree.data.time.TimeSeries;
|
import org.jfree.data.time.TimeSeries;
|
||||||
import org.jfree.data.time.TimeSeriesCollection;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.lowagie.text.Document;
|
import com.lowagie.text.Document;
|
||||||
import com.lowagie.text.Element;
|
|
||||||
import com.lowagie.text.Paragraph;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class ScriptReportService {
|
public class ScriptReportService {
|
||||||
public static String Average_Response_Time = "averageResponseTime";
|
public static String SCRIPT_TITLE = "Script result";
|
||||||
|
public static String Average_Response_Time = "averageResponseTime(unit: ms)";
|
||||||
|
public static String MAX_RESPONSE_TIME = "maxResponseTime(unit : time)";
|
||||||
private TestPlanScriptService testPlanScriptService;
|
private TestPlanScriptService testPlanScriptService;
|
||||||
private TestPlanService testPlanService;
|
private TestPlanService testPlanService;
|
||||||
private MonitorResultService monitorResultService;
|
private MonitorResultService monitorResultService;
|
||||||
|
private Logger logger = Logger.getLogger(ScriptReportService.class);
|
||||||
|
|
||||||
public TestPlanScriptService getTestPlanScriptService() {
|
public TestPlanScriptService getTestPlanScriptService() {
|
||||||
return testPlanScriptService;
|
return testPlanScriptService;
|
||||||
|
@ -84,41 +82,74 @@ public class ScriptReportService {
|
||||||
|
|
||||||
private void createAverageReponseTimeImage(
|
private void createAverageReponseTimeImage(
|
||||||
List<TestPlanScriptResult> results, Document document) {
|
List<TestPlanScriptResult> results, Document document) {
|
||||||
TimeSeries timeSeries = new TimeSeries(Average_Response_Time);
|
// TimeSeriesCollection lineSeriesCollection = new
|
||||||
TimeSeriesCollection lineSeriesCollection = new TimeSeriesCollection();
|
// TimeSeriesCollection();
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
List<TimeSeries> timeSeriesList = new ArrayList<TimeSeries>();
|
||||||
String scriptName = "null";
|
// ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
// String scriptName = "null";
|
||||||
if (results == null) {
|
if (results == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (TestPlanScriptResult result : results) {
|
addScriptSeries(results, timeSeriesList, "averageResponseTime");
|
||||||
timeSeries.addOrUpdate(new Second(result.getCreateDatetime()),
|
addScriptSeries(results, timeSeriesList, "maxResponseTime");
|
||||||
result.getAverageResponseTime());
|
|
||||||
}
|
|
||||||
lineSeriesCollection.addSeries(timeSeries);
|
|
||||||
JFreeChart chart = ChartFactory.createTimeSeriesChart(
|
|
||||||
Average_Response_Time, ReportService.Time,
|
|
||||||
Average_Response_Time, lineSeriesCollection, true, true, true);
|
|
||||||
chart.setBackgroundPaint(java.awt.Color.white);
|
|
||||||
|
|
||||||
if (results.size() > 0) {
|
|
||||||
scriptName = results.get(0).getTestPlanScript().getScript()
|
|
||||||
.getName();
|
|
||||||
chart.addSubtitle(new TextTitle(scriptName));
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ChartUtilities.writeChartAsPNG(outputStream, chart, 400, 300);
|
ReportService.writeImageIntoPdf(
|
||||||
Paragraph paragraph = new Paragraph(Average_Response_Time + " of "
|
ReportService.buildChartStream(document,
|
||||||
+ scriptName);
|
timeSeriesList.size(), timeSeriesList,
|
||||||
paragraph.setAlignment(Element.ALIGN_CENTER);
|
Average_Response_Time + "&" + MAX_RESPONSE_TIME)
|
||||||
document.add(paragraph);
|
.toByteArray(), document);
|
||||||
ReportService.writeImageIntoPdf(outputStream.toByteArray(),
|
|
||||||
document);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
// JFreeChart chart = ChartFactory.createTimeSeriesChart(SCRIPT_TITLE,
|
||||||
|
// ReportService.Time, Average_Response_Time + "&"
|
||||||
|
// + MAX_RESPONSE_TIME, lineSeriesCollection, true, true,
|
||||||
|
// true);
|
||||||
|
// chart.setBackgroundPaint(java.awt.Color.white);
|
||||||
|
//
|
||||||
|
// if (results.size() > 0) {
|
||||||
|
// scriptName = results.get(0).getTestPlanScript().getScript()
|
||||||
|
// .getName();
|
||||||
|
// chart.addSubtitle(new TextTitle(scriptName));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// ReportService.buildChartStream(document, lineSeriesCollection
|
||||||
|
// .getSeriesCount(), lineSeriesCollection.getSeries().toArray(a),
|
||||||
|
// Average_Response_Time + "&" + MAX_RESPONSE_TIME);
|
||||||
|
// ReportService.writeImageIntoPdf(ReportService.buildChartStream(),
|
||||||
|
// document);
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// ChartUtilities.writeChartAsPNG(outputStream, chart, 400, 300);
|
||||||
|
// Paragraph paragraph = new Paragraph(Average_Response_Time + " of "
|
||||||
|
// + scriptName);
|
||||||
|
// paragraph.setAlignment(Element.ALIGN_CENTER);
|
||||||
|
// document.add(paragraph);
|
||||||
|
// ReportService.writeImageIntoPdf(outputStream.toByteArray(),
|
||||||
|
// document);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: refactor this to a kind of command mode
|
||||||
|
private void addScriptSeries(List<TestPlanScriptResult> results,
|
||||||
|
List<TimeSeries> timeSeriesList, String fieldName) {
|
||||||
|
try {
|
||||||
|
TimeSeries timeSeries = new TimeSeries(fieldName);
|
||||||
|
for (TestPlanScriptResult result : results) {
|
||||||
|
Field field = result.getClass().getDeclaredField(fieldName);
|
||||||
|
field.setAccessible(true);
|
||||||
|
timeSeries.addOrUpdate(new Second(result.getCreateDatetime()),
|
||||||
|
field.getLong(result));
|
||||||
|
}
|
||||||
|
timeSeriesList.add(timeSeries);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.toString()
|
||||||
|
+ " in addScriptSeries where fieldName is : " + fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@ import javax.xml.bind.Marshaller;
|
||||||
import javax.xml.bind.Unmarshaller;
|
import javax.xml.bind.Unmarshaller;
|
||||||
|
|
||||||
import org.bench4q.master.communication.agent.RunScenarioModel;
|
import org.bench4q.master.communication.agent.RunScenarioModel;
|
||||||
import org.bench4q.master.communication.agent.UsePluginModel;
|
import org.bench4q.master.communication.agent.scriptrecord.UsePluginModel;
|
||||||
import org.bench4q.master.communication.agent.UserBehaviorModel;
|
import org.bench4q.master.communication.agent.scriptrecord.UserBehaviorModel;
|
||||||
|
|
||||||
public class Bench4qTestScriptAdapter implements IScriptAdapter {
|
public class Bench4qTestScriptAdapter implements IScriptAdapter {
|
||||||
private RunScenarioModel runScenarioModel;
|
private RunScenarioModel runScenarioModel;
|
||||||
|
|
|
@ -3,8 +3,8 @@ package org.bench4q.master.scriptrecord.httpcapture;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bench4q.master.communication.agent.RunScenarioModel;
|
import org.bench4q.master.communication.agent.RunScenarioModel;
|
||||||
import org.bench4q.master.communication.agent.UsePluginModel;
|
import org.bench4q.master.communication.agent.scriptrecord.UsePluginModel;
|
||||||
import org.bench4q.master.communication.agent.UserBehaviorModel;
|
import org.bench4q.master.communication.agent.scriptrecord.UserBehaviorModel;
|
||||||
|
|
||||||
public interface IScriptAdapter {
|
public interface IScriptAdapter {
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import javax.xml.bind.Marshaller;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.bench4q.master.communication.agent.RunScenarioModel;
|
import org.bench4q.master.communication.agent.RunScenarioModel;
|
||||||
import org.bench4q.master.communication.agent.UserBehaviorModel;
|
import org.bench4q.master.communication.agent.scriptrecord.UserBehaviorModel;
|
||||||
import org.bench4q.master.scriptrecord.httpcapture.Action;
|
import org.bench4q.master.scriptrecord.httpcapture.Action;
|
||||||
import org.bench4q.master.scriptrecord.httpcapture.Config;
|
import org.bench4q.master.scriptrecord.httpcapture.Config;
|
||||||
import org.bench4q.master.scriptrecord.httpcapture.HeaderValue;
|
import org.bench4q.master.scriptrecord.httpcapture.HeaderValue;
|
||||||
|
|
|
@ -5,8 +5,8 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.bench4q.master.communication.agent.ParameterModel;
|
import org.bench4q.master.communication.agent.ParameterModel;
|
||||||
import org.bench4q.master.communication.agent.UsePluginModel;
|
import org.bench4q.master.communication.agent.scriptrecord.UsePluginModel;
|
||||||
import org.bench4q.master.communication.agent.UserBehaviorModel;
|
import org.bench4q.master.communication.agent.scriptrecord.UserBehaviorModel;
|
||||||
import org.bench4q.master.scriptrecord.httpcapture.Config;
|
import org.bench4q.master.scriptrecord.httpcapture.Config;
|
||||||
import org.bench4q.master.scriptrecord.httpcapture.HeaderValue;
|
import org.bench4q.master.scriptrecord.httpcapture.HeaderValue;
|
||||||
import org.bench4q.master.scriptrecord.httpcapture.IScriptAdapter;
|
import org.bench4q.master.scriptrecord.httpcapture.IScriptAdapter;
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class MonitorResultService {
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.toString() + " when saveMonitorResult");
|
logger.error(e.toString() + " when saveMonitorResult");
|
||||||
|
e.printStackTrace();
|
||||||
transaction.rollback();
|
transaction.rollback();
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.bench4q.master.service;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
@ -162,8 +163,7 @@ public class MonitorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
saveResultRunable(NetworkInterfaceModel.class.getName(),
|
saveResultRunable(NetworkInterfaceModel.class.getName(),
|
||||||
changeCharsetToISO(httpResponse.getContent()),
|
httpResponse.getContent(), testPlanRunId, hostName);
|
||||||
testPlanRunId, hostName);
|
|
||||||
return extractNetworkInterfaceModel(httpResponse.getContent());
|
return extractNetworkInterfaceModel(httpResponse.getContent());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage() + "where testPlanRunId = "
|
logger.error(e.getMessage() + "where testPlanRunId = "
|
||||||
|
@ -181,8 +181,8 @@ public class MonitorService {
|
||||||
Unmarshaller unmarshaller = JAXBContext.newInstance(
|
Unmarshaller unmarshaller = JAXBContext.newInstance(
|
||||||
NetworkInterfaceModel.class).createUnmarshaller();
|
NetworkInterfaceModel.class).createUnmarshaller();
|
||||||
return (NetworkInterfaceModel) unmarshaller
|
return (NetworkInterfaceModel) unmarshaller
|
||||||
.unmarshal(new ByteArrayInputStream(changeCharsetToISO(content)
|
.unmarshal(new ByteArrayInputStream(content.getBytes(Charset
|
||||||
.getBytes()));
|
.forName("UTF-8"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String changeCharsetToISO(String content)
|
public static String changeCharsetToISO(String content)
|
||||||
|
|
|
@ -10,7 +10,7 @@ import javax.xml.bind.Unmarshaller;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.bench4q.master.communication.agent.RunScenarioModel;
|
import org.bench4q.master.communication.agent.RunScenarioModel;
|
||||||
import org.bench4q.master.communication.agent.UserBehaviorModel;
|
import org.bench4q.master.communication.agent.scriptrecord.UserBehaviorModel;
|
||||||
import org.bench4q.master.entity.db.Script;
|
import org.bench4q.master.entity.db.Script;
|
||||||
import org.bench4q.master.entity.db.User;
|
import org.bench4q.master.entity.db.User;
|
||||||
import org.bench4q.master.helper.SessionHelper;
|
import org.bench4q.master.helper.SessionHelper;
|
||||||
|
|
|
@ -163,16 +163,25 @@ public class TestPlanScriptService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestPlanScriptResult buildScriptResultWithModel(
|
private TestPlanScriptResult buildScriptResultWithModel(
|
||||||
ScriptBriefResultModel resultModel, TestPlanScript testPlanScript,
|
ScriptBriefResultModel model, TestPlanScript testPlanScript,
|
||||||
Date createDatetime) {
|
Date createDatetime) {
|
||||||
TestPlanScriptResult result = new TestPlanScriptResult();
|
TestPlanScriptResult result = new TestPlanScriptResult();
|
||||||
result.setTestPlanScript(testPlanScript);
|
result.setTestPlanScript(testPlanScript);
|
||||||
result.setTotalFailCount(resultModel.getTotalFailCountFromBegin());
|
result.setAverageElapsedTime(model.getAverageElapsedTime());
|
||||||
result.setTotalFinishedCount(resultModel
|
|
||||||
|
result.setAverageResponseTime(model.getAverageResponseTime());
|
||||||
|
result.setFailRateThisTime(model.getFailRateThisTime());
|
||||||
|
result.setFailThroughputThisTime(model.getFailThroughputThisTime());
|
||||||
|
result.setMaxResponseTime(model.getMaxResponseTime());
|
||||||
|
result.setMinResposneTime(model.getMinResponseTime());
|
||||||
|
result.setResponseTimeDeviationThisTime(model
|
||||||
|
.getResponseTimeDeviationThisTime());
|
||||||
|
result.setSuccessThroughputThisTime(model
|
||||||
|
.getSuccessThroughputThisTime());
|
||||||
|
result.setTotalFailCountFromBegin(model.getTotalFailCountFromBegin());
|
||||||
|
result.setTotalSuccessCountFromBegin(model
|
||||||
.getTotalSuccessCountFromBegin());
|
.getTotalSuccessCountFromBegin());
|
||||||
result.setTotalSuccessCount(resultModel.getTotalSuccessCountFromBegin());
|
|
||||||
result.setAverageElapsedTime(resultModel.getAverageElapsedTime());
|
|
||||||
result.setAverageResponseTime(resultModel.getAverageResponseTime());
|
|
||||||
result.setCreateDatetime(createDatetime);
|
result.setCreateDatetime(createDatetime);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import org.bench4q.master.api.model.RunningScriptModel;
|
||||||
import org.bench4q.master.api.model.TestPlanModel;
|
import org.bench4q.master.api.model.TestPlanModel;
|
||||||
import org.bench4q.master.api.model.TestScriptConfig;
|
import org.bench4q.master.api.model.TestScriptConfig;
|
||||||
import org.bench4q.master.entity.db.PlanedConfig;
|
import org.bench4q.master.entity.db.PlanedConfig;
|
||||||
|
import org.bench4q.master.entity.db.Script;
|
||||||
import org.bench4q.master.entity.db.TestPlan;
|
import org.bench4q.master.entity.db.TestPlan;
|
||||||
import org.bench4q.master.entity.db.TestPlanScript;
|
import org.bench4q.master.entity.db.TestPlanScript;
|
||||||
import org.bench4q.master.entity.db.User;
|
import org.bench4q.master.entity.db.User;
|
||||||
|
@ -99,6 +100,13 @@ public class TestPlanService {
|
||||||
|
|
||||||
testPlanScript = new TestPlanScript();
|
testPlanScript = new TestPlanScript();
|
||||||
testPlanScript.setTestPlan(testPlan);
|
testPlanScript.setTestPlan(testPlan);
|
||||||
|
Script script = this.scriptService.getScript(runningScriptModel
|
||||||
|
.getScriptId());
|
||||||
|
if (script == null) {
|
||||||
|
logger.error("There is no this script with id "
|
||||||
|
+ runningScriptModel.getScriptId());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
testPlanScript.setScript(this.scriptService
|
testPlanScript.setScript(this.scriptService
|
||||||
.getScript(runningScriptModel.getScriptId()));
|
.getScript(runningScriptModel.getScriptId()));
|
||||||
testPlanScript.setRequireLoad(runningScriptModel.getRequireLoad());
|
testPlanScript.setRequireLoad(runningScriptModel.getRequireLoad());
|
||||||
|
|
|
@ -24,5 +24,6 @@
|
||||||
<mapping class="org.bench4q.master.entity.db.TestPlanScript" />
|
<mapping class="org.bench4q.master.entity.db.TestPlanScript" />
|
||||||
<mapping class="org.bench4q.master.entity.db.TestPlanScriptResult" />
|
<mapping class="org.bench4q.master.entity.db.TestPlanScriptResult" />
|
||||||
<mapping class="org.bench4q.master.entity.db.MonitorResult" />
|
<mapping class="org.bench4q.master.entity.db.MonitorResult" />
|
||||||
|
<mapping class="org.bench4q.master.entity.db.ForTest" />
|
||||||
</session-factory>
|
</session-factory>
|
||||||
</hibernate-configuration>
|
</hibernate-configuration>
|
|
@ -0,0 +1,40 @@
|
||||||
|
package org.bench4q.master.test;
|
||||||
|
|
||||||
|
import org.bench4q.master.entity.db.ForTest;
|
||||||
|
import org.bench4q.master.helper.SessionHelper;
|
||||||
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.Transaction;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class MysqlTest {
|
||||||
|
|
||||||
|
private SessionHelper sessionHelper;
|
||||||
|
|
||||||
|
public SessionHelper getSessionHelper() {
|
||||||
|
return sessionHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSessionHelper(SessionHelper sessionHelper) {
|
||||||
|
this.sessionHelper = sessionHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MysqlTest() {
|
||||||
|
this.setSessionHelper(new SessionHelper());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testForChinese() {
|
||||||
|
Session session = this.getSessionHelper().openSession();
|
||||||
|
Transaction transaction = session.beginTransaction();
|
||||||
|
try {
|
||||||
|
ForTest test = new ForTest();
|
||||||
|
test.setContent("³ÂÌú°´Å¥");
|
||||||
|
session.merge(test);
|
||||||
|
transaction.commit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO: handle exception
|
||||||
|
e.printStackTrace();
|
||||||
|
transaction.rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,12 +27,12 @@ public class TestPlanTester extends TestBase {
|
||||||
private TestPlanModel testPlan = new TestPlanModel();
|
private TestPlanModel testPlan = new TestPlanModel();
|
||||||
private String _url = TestBase.BASE_URL + "/testPlan";
|
private String _url = TestBase.BASE_URL + "/testPlan";
|
||||||
private int scriptSumNum;
|
private int scriptSumNum;
|
||||||
private static int SCRIPTID1 = 18;
|
private static int SCRIPTID1 = 1;
|
||||||
private static int SCRIPTID2 = 2;
|
private static int SCRIPTID2 = 2;
|
||||||
// private static int EACH_SCRIPT_LOAD_LargeSCALE = 12000;
|
// private static int EACH_SCRIPT_LOAD_LargeSCALE = 12000;
|
||||||
private static int EACH_SCRIPT_LOAD_SMALLSCALE = 400;
|
private static int EACH_SCRIPT_LOAD_SMALLSCALE = 400;
|
||||||
// private static int EACH_SCRIPT_LOAD_MIDDLESCALE = 800;
|
// private static int EACH_SCRIPT_LOAD_MIDDLESCALE = 800;
|
||||||
private static String Monitor_Host_Name = "133.133.12.3";
|
private static String Monitor_Host_Name = "127.0.0.1";
|
||||||
private static String monitor_port = "5556";
|
private static String monitor_port = "5556";
|
||||||
|
|
||||||
public TestPlanModel getTestPlan() {
|
public TestPlanModel getTestPlan() {
|
||||||
|
@ -70,7 +70,7 @@ public class TestPlanTester extends TestBase {
|
||||||
while (this.getRunningInfo(testPlanID).getCurrentStatus() != TestPlanStatus.InRunning) {
|
while (this.getRunningInfo(testPlanID).getCurrentStatus() != TestPlanStatus.InRunning) {
|
||||||
Thread.sleep(6000);
|
Thread.sleep(6000);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 300; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000);
|
||||||
this.getScriptBrief(testPlanID, SCRIPTID1);
|
this.getScriptBrief(testPlanID, SCRIPTID1);
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ public class TestPlanTester extends TestBase {
|
||||||
|
|
||||||
public void getMonitorBrief(UUID testPlanID, String hostName, String port)
|
public void getMonitorBrief(UUID testPlanID, String hostName, String port)
|
||||||
throws IOException, InterruptedException {
|
throws IOException, InterruptedException {
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 1; i++) {
|
||||||
getMonitorMemoryResult(testPlanID, hostName, port);
|
getMonitorMemoryResult(testPlanID, hostName, port);
|
||||||
getProcessorResult(testPlanID, hostName, port);
|
getProcessorResult(testPlanID, hostName, port);
|
||||||
getLogicalDiskResult(testPlanID, hostName, port);
|
getLogicalDiskResult(testPlanID, hostName, port);
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
package org.bench4q.master.test.report;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bench4q.master.report.ReportService;
|
||||||
|
import org.jfree.data.time.Second;
|
||||||
|
import org.jfree.data.time.TimeSeries;
|
||||||
|
import org.jfree.data.time.TimeSeriesCollection;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.lowagie.text.Document;
|
||||||
|
import com.lowagie.text.DocumentException;
|
||||||
|
import com.lowagie.text.pdf.PdfWriter;
|
||||||
|
|
||||||
|
public class ReportFontTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createReportTest() throws FileNotFoundException,
|
||||||
|
DocumentException {
|
||||||
|
|
||||||
|
Document document = new Document();
|
||||||
|
PdfWriter.getInstance(
|
||||||
|
document,
|
||||||
|
new FileOutputStream(ReportService.buildFilePath(UUID
|
||||||
|
.randomUUID())));
|
||||||
|
document.open();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createTestImage(UUID id, Document document) throws IOException, Exception {
|
||||||
|
List<TimeSeries> timeSeriesList = new ArrayList<TimeSeries>();
|
||||||
|
TimeSeries timeSeries = new TimeSeries("test");
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
timeSeries.add(new Second(new Date(now)), 3000);
|
||||||
|
timeSeries.add(new Second(new Date(now + 100)), 4000);
|
||||||
|
timeSeriesList.add(timeSeries);
|
||||||
|
ReportService.buildSeries(1, "test");
|
||||||
|
ReportService.writeImageIntoPdf(
|
||||||
|
ReportService.buildChartStream(document, 1, timeSeriesList,
|
||||||
|
"test").toByteArray(), document);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue