add vUserCount for ScriptBriefResultModel
This commit is contained in:
parent
18d02acba6
commit
09fc24e0a9
|
@ -1,37 +1,37 @@
|
||||||
package org.bench4q.master.helper;
|
package org.bench4q.master.helper;
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public final class SessionHelper {
|
public final class SessionHelper {
|
||||||
private SessionFactory sessionFactory;
|
private SessionFactory sessionFactory;
|
||||||
|
|
||||||
public SessionFactory getSessionFactory() {
|
public SessionFactory getSessionFactory() {
|
||||||
return sessionFactory;
|
return sessionFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSessionFactory(SessionFactory sessionFactory) {
|
public void setSessionFactory(SessionFactory sessionFactory) {
|
||||||
this.sessionFactory = sessionFactory;
|
this.sessionFactory = sessionFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SessionHelper() {
|
public SessionHelper() {
|
||||||
try {
|
try {
|
||||||
Configuration cfg = new Configuration()
|
Configuration cfg = new Configuration()
|
||||||
.configure("org/bench4q/master/config/hibernate.cfg.xml");
|
.configure("org/bench4q/master/config/hibernate.cfg.xml");
|
||||||
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
|
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
|
||||||
.applySettings(cfg.getProperties()).build();
|
.applySettings(cfg.getProperties()).build();
|
||||||
this.setSessionFactory(cfg.buildSessionFactory(serviceRegistry));
|
this.setSessionFactory(cfg.buildSessionFactory(serviceRegistry));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Session openSession() {
|
public Session openSession() {
|
||||||
return this.getSessionFactory().openSession();
|
return this.getSessionFactory().openSession();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,206 +1,214 @@
|
||||||
package org.bench4q.master.testplan.datastatistics;
|
package org.bench4q.master.testplan.datastatistics;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import org.bench4q.share.models.agent.statistics.AgentBriefStatusModel;
|
import org.bench4q.share.models.agent.statistics.AgentBriefStatusModel;
|
||||||
import org.bench4q.share.models.agent.statistics.DataStatisticsModel;
|
import org.bench4q.share.models.agent.statistics.DataStatisticsModel;
|
||||||
import org.bench4q.share.models.master.statistics.ScriptBriefResultModel;
|
import org.bench4q.share.models.master.statistics.ScriptBriefResultModel;
|
||||||
|
|
||||||
public class ScriptBriefStatistics extends ScriptStatistics {
|
public class ScriptBriefStatistics extends ScriptStatistics {
|
||||||
private long totalFailCountThisTime;
|
private long totalFailCountThisTime;
|
||||||
private long totalSuccessCountThisTime;
|
private long totalSuccessCountThisTime;
|
||||||
private long totalSquareResponseTime;
|
private long totalSquareResponseTime;
|
||||||
private long totalFailThroughputThisTime;
|
private long totalFailThroughputThisTime;
|
||||||
private long totalSuccessThroughputThisTime;
|
private long totalSuccessThroughputThisTime;
|
||||||
private long minResponseTimeThisTime;
|
private long minResponseTimeThisTime;
|
||||||
private long maxResponseTimeThisTime;
|
private long maxResponseTimeThisTime;
|
||||||
private long totalResponseTimeThisTime;
|
private long totalResponseTimeThisTime;
|
||||||
private long totalFailCountFromBegin;
|
private long totalFailCountFromBegin;
|
||||||
private long totalSuccessCountFromBegin;
|
private long totalSuccessCountFromBegin;
|
||||||
|
|
||||||
private long totalElapsedTime;
|
private long totalElapsedTime;
|
||||||
private long effectiveCount;
|
private long activeVUserCountThisTime;
|
||||||
|
private long effectiveCount;
|
||||||
private ScriptBriefResultModel lastValidBriefResultModel;
|
|
||||||
|
private ScriptBriefResultModel lastValidBriefResultModel;
|
||||||
private void setTotalFailCountThisTime(long totalFailCountThisTime) {
|
|
||||||
this.totalFailCountThisTime = totalFailCountThisTime;
|
private void setTotalFailCountThisTime(long totalFailCountThisTime) {
|
||||||
}
|
this.totalFailCountThisTime = totalFailCountThisTime;
|
||||||
|
}
|
||||||
private void setTotalSuccessCountThisTime(long totalSuccessCountThisTime) {
|
|
||||||
this.totalSuccessCountThisTime = totalSuccessCountThisTime;
|
private void setTotalSuccessCountThisTime(long totalSuccessCountThisTime) {
|
||||||
}
|
this.totalSuccessCountThisTime = totalSuccessCountThisTime;
|
||||||
|
}
|
||||||
private void setTotalSquareResponseTime(long totalSquareResponseTime) {
|
|
||||||
this.totalSquareResponseTime = totalSquareResponseTime;
|
private void setTotalSquareResponseTime(long totalSquareResponseTime) {
|
||||||
}
|
this.totalSquareResponseTime = totalSquareResponseTime;
|
||||||
|
}
|
||||||
private void setTotalFailThroughputThisTime(long totalFailThroughputThisTime) {
|
|
||||||
this.totalFailThroughputThisTime = totalFailThroughputThisTime;
|
private void setTotalFailThroughputThisTime(long totalFailThroughputThisTime) {
|
||||||
}
|
this.totalFailThroughputThisTime = totalFailThroughputThisTime;
|
||||||
|
}
|
||||||
private void setTotalSuccessThroughputThisTime(
|
|
||||||
long totalSuccessThroughputThisTime) {
|
private void setTotalSuccessThroughputThisTime(
|
||||||
this.totalSuccessThroughputThisTime = totalSuccessThroughputThisTime;
|
long totalSuccessThroughputThisTime) {
|
||||||
}
|
this.totalSuccessThroughputThisTime = totalSuccessThroughputThisTime;
|
||||||
|
}
|
||||||
private void setMinResponseTimeThisTime(long minResponseTimeThisTime) {
|
|
||||||
this.minResponseTimeThisTime = minResponseTimeThisTime;
|
private void setMinResponseTimeThisTime(long minResponseTimeThisTime) {
|
||||||
}
|
this.minResponseTimeThisTime = minResponseTimeThisTime;
|
||||||
|
}
|
||||||
private void setMaxResponseTimeThisTime(long maxResponseTimeThisTime) {
|
|
||||||
this.maxResponseTimeThisTime = maxResponseTimeThisTime;
|
private void setMaxResponseTimeThisTime(long maxResponseTimeThisTime) {
|
||||||
}
|
this.maxResponseTimeThisTime = maxResponseTimeThisTime;
|
||||||
|
}
|
||||||
private void setTotalResponseTimeThisTime(long totalResponseTimeThisTime) {
|
|
||||||
this.totalResponseTimeThisTime = totalResponseTimeThisTime;
|
private void setTotalResponseTimeThisTime(long totalResponseTimeThisTime) {
|
||||||
}
|
this.totalResponseTimeThisTime = totalResponseTimeThisTime;
|
||||||
|
}
|
||||||
private void setTotalFailCountFromBegin(long totalFailCountFromBegin) {
|
|
||||||
this.totalFailCountFromBegin = totalFailCountFromBegin;
|
private void setTotalFailCountFromBegin(long totalFailCountFromBegin) {
|
||||||
}
|
this.totalFailCountFromBegin = totalFailCountFromBegin;
|
||||||
|
}
|
||||||
private void setTotalSuccessCoutFromBegin(long totalSuccessCoutFromBegin) {
|
|
||||||
this.totalSuccessCountFromBegin = totalSuccessCoutFromBegin;
|
private void setTotalSuccessCoutFromBegin(long totalSuccessCoutFromBegin) {
|
||||||
}
|
this.totalSuccessCountFromBegin = totalSuccessCoutFromBegin;
|
||||||
|
}
|
||||||
private void setTotalElapsedTime(long totalElapsedTime) {
|
|
||||||
this.totalElapsedTime = totalElapsedTime;
|
private void setTotalElapsedTime(long totalElapsedTime) {
|
||||||
}
|
this.totalElapsedTime = totalElapsedTime;
|
||||||
|
}
|
||||||
private void setEffectiveCounte(long effetiveCount) {
|
|
||||||
this.effectiveCount = effetiveCount;
|
private void setActiveVUserCountThisTime(long activeVUserCountThisTime) {
|
||||||
}
|
this.activeVUserCountThisTime = activeVUserCountThisTime;
|
||||||
|
}
|
||||||
private ScriptBriefResultModel getLastValidBriefResultModel() {
|
|
||||||
return lastValidBriefResultModel;
|
private void setEffectiveCounte(long effetiveCount) {
|
||||||
}
|
this.effectiveCount = effetiveCount;
|
||||||
|
}
|
||||||
private void setLastValidBriefResultModel(
|
|
||||||
ScriptBriefResultModel lastValidBriefResultModel) {
|
private ScriptBriefResultModel getLastValidBriefResultModel() {
|
||||||
this.lastValidBriefResultModel = lastValidBriefResultModel;
|
return lastValidBriefResultModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScriptBriefStatistics() {
|
private void setLastValidBriefResultModel(
|
||||||
reset();
|
ScriptBriefResultModel lastValidBriefResultModel) {
|
||||||
initLastValidBriefResultModel();
|
this.lastValidBriefResultModel = lastValidBriefResultModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reset() {
|
public ScriptBriefStatistics() {
|
||||||
this.setTotalFailCountFromBegin(0);
|
reset();
|
||||||
this.setTotalFailCountThisTime(0);
|
initLastValidBriefResultModel();
|
||||||
this.setTotalFailThroughputThisTime(0);
|
}
|
||||||
this.setTotalResponseTimeThisTime(0);
|
|
||||||
this.setTotalSquareResponseTime(0);
|
private void reset() {
|
||||||
this.setTotalSuccessCountThisTime(0);
|
this.setTotalFailCountFromBegin(0);
|
||||||
this.setTotalSuccessCoutFromBegin(0);
|
this.setTotalFailCountThisTime(0);
|
||||||
this.setTotalSuccessThroughputThisTime(0);
|
this.setTotalFailThroughputThisTime(0);
|
||||||
this.setTotalElapsedTime(0);
|
this.setTotalResponseTimeThisTime(0);
|
||||||
this.setEffectiveCounte(0);
|
this.setTotalSquareResponseTime(0);
|
||||||
this.setMaxResponseTimeThisTime(Long.MIN_VALUE);
|
this.setTotalSuccessCountThisTime(0);
|
||||||
this.setMinResponseTimeThisTime(Long.MAX_VALUE);
|
this.setTotalSuccessCoutFromBegin(0);
|
||||||
}
|
this.setTotalSuccessThroughputThisTime(0);
|
||||||
|
this.setTotalElapsedTime(0);
|
||||||
private void initLastValidBriefResultModel() {
|
this.setEffectiveCounte(0);
|
||||||
ScriptBriefResultModel initBriefModel = new ScriptBriefResultModel();
|
this.setMaxResponseTimeThisTime(Long.MIN_VALUE);
|
||||||
initBriefModel.setAverageElapsedTime(0);
|
this.setMinResponseTimeThisTime(Long.MAX_VALUE);
|
||||||
initBriefModel.setAverageResponseTime(0);
|
this.setActiveVUserCountThisTime(0);
|
||||||
initBriefModel.setFailRateThisTime(0);
|
}
|
||||||
initBriefModel.setFailThroughputThisTime(0);
|
|
||||||
initBriefModel.setFinished(false);
|
private void initLastValidBriefResultModel() {
|
||||||
initBriefModel.setMaxResponseTime(0);
|
ScriptBriefResultModel initBriefModel = new ScriptBriefResultModel();
|
||||||
initBriefModel.setMinResponseTime(0);
|
initBriefModel.setAverageElapsedTime(0);
|
||||||
initBriefModel.setPlanedRunningTime(0);
|
initBriefModel.setAverageResponseTime(0);
|
||||||
initBriefModel.setResponseTimeDeviationThisTime(0);
|
initBriefModel.setFailRateThisTime(0);
|
||||||
initBriefModel.setSuccessThroughputThisTime(0);
|
initBriefModel.setFailThroughputThisTime(0);
|
||||||
initBriefModel.setTotalFailCountFromBegin(0);
|
initBriefModel.setFinished(false);
|
||||||
initBriefModel.setTotalSuccessCountFromBegin(0);
|
initBriefModel.setMaxResponseTime(0);
|
||||||
this.setLastValidBriefResultModel(initBriefModel);
|
initBriefModel.setMinResponseTime(0);
|
||||||
}
|
initBriefModel.setPlanedRunningTime(0);
|
||||||
|
initBriefModel.setResponseTimeDeviationThisTime(0);
|
||||||
public void add(DataStatisticsModel dataUnit) {
|
initBriefModel.setSuccessThroughputThisTime(0);
|
||||||
if (!(dataUnit instanceof AgentBriefStatusModel)) {
|
initBriefModel.setTotalFailCountFromBegin(0);
|
||||||
return;
|
initBriefModel.setTotalSuccessCountFromBegin(0);
|
||||||
}
|
this.setLastValidBriefResultModel(initBriefModel);
|
||||||
add((AgentBriefStatusModel) dataUnit);
|
}
|
||||||
}
|
|
||||||
|
public void add(DataStatisticsModel dataUnit) {
|
||||||
private void add(AgentBriefStatusModel briefModel) {
|
if (!(dataUnit instanceof AgentBriefStatusModel)) {
|
||||||
if (briefModel == null) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
add((AgentBriefStatusModel) dataUnit);
|
||||||
this.effectiveCount++;
|
}
|
||||||
if (briefModel.getMaxResponseTime() > this.maxResponseTimeThisTime) {
|
|
||||||
this.setMaxResponseTimeThisTime(briefModel.getMaxResponseTime());
|
private void add(AgentBriefStatusModel briefModel) {
|
||||||
}
|
if (briefModel == null) {
|
||||||
if (briefModel.getMinResponseTime() < this.minResponseTimeThisTime) {
|
return;
|
||||||
this.setMinResponseTimeThisTime(briefModel.getMinResponseTime());
|
}
|
||||||
}
|
this.effectiveCount++;
|
||||||
this.totalFailCountFromBegin += briefModel.getFailCountFromBegin();
|
if (briefModel.getMaxResponseTime() > this.maxResponseTimeThisTime) {
|
||||||
this.totalFailCountThisTime += briefModel.getFailCountThisTime();
|
this.setMaxResponseTimeThisTime(briefModel.getMaxResponseTime());
|
||||||
this.totalFailThroughputThisTime += briefModel
|
}
|
||||||
.getFailThroughputThisTime();
|
if (briefModel.getMinResponseTime() < this.minResponseTimeThisTime) {
|
||||||
this.totalResponseTimeThisTime += briefModel
|
this.setMinResponseTimeThisTime(briefModel.getMinResponseTime());
|
||||||
.getTotalResponseTimeThisTime();
|
}
|
||||||
this.totalSquareResponseTime += briefModel
|
this.totalFailCountFromBegin += briefModel.getFailCountFromBegin();
|
||||||
.getTotalSqureResponseTimeThisTime();
|
this.totalFailCountThisTime += briefModel.getFailCountThisTime();
|
||||||
this.totalSuccessCountThisTime += briefModel.getSuccessCountThisTime();
|
this.totalFailThroughputThisTime += briefModel
|
||||||
this.totalSuccessCountFromBegin += briefModel
|
.getFailThroughputThisTime();
|
||||||
.getSuccessCountFromBegin();
|
this.totalResponseTimeThisTime += briefModel
|
||||||
this.totalSuccessThroughputThisTime += briefModel
|
.getTotalResponseTimeThisTime();
|
||||||
.getSuccessThroughputThisTime();
|
this.totalSquareResponseTime += briefModel
|
||||||
}
|
.getTotalSqureResponseTimeThisTime();
|
||||||
|
this.totalSuccessCountThisTime += briefModel.getSuccessCountThisTime();
|
||||||
public ScriptBriefResultModel getStatistics() {
|
this.totalSuccessCountFromBegin += briefModel
|
||||||
ScriptBriefResultModel result = new ScriptBriefResultModel();
|
.getSuccessCountFromBegin();
|
||||||
long averageResponseTime = 0;
|
this.totalSuccessThroughputThisTime += briefModel
|
||||||
if (this.totalSuccessCountThisTime == 0) {
|
.getSuccessThroughputThisTime();
|
||||||
result.setAverageResponseTime(0);
|
this.activeVUserCountThisTime += briefModel.getvUserCount();
|
||||||
result.setMaxResponseTime(0);
|
}
|
||||||
result.setMinResponseTime(0);
|
|
||||||
result.setResponseTimeDeviationThisTime(0);
|
public ScriptBriefResultModel getStatistics() {
|
||||||
if (this.totalFailCountThisTime == 0) {
|
ScriptBriefResultModel result = new ScriptBriefResultModel();
|
||||||
result.setFailRateThisTime(0);
|
long averageResponseTime = 0;
|
||||||
} else {
|
if (this.totalSuccessCountThisTime == 0) {
|
||||||
result.setFailRateThisTime(100);
|
result.setAverageResponseTime(0);
|
||||||
}
|
result.setMaxResponseTime(0);
|
||||||
} else {
|
result.setMinResponseTime(0);
|
||||||
averageResponseTime = this.totalResponseTimeThisTime
|
result.setResponseTimeDeviationThisTime(0);
|
||||||
/ this.totalSuccessCountThisTime;
|
if (this.totalFailCountThisTime == 0) {
|
||||||
result.setAverageResponseTime(averageResponseTime);
|
result.setFailRateThisTime(0);
|
||||||
result.setMaxResponseTime(this.maxResponseTimeThisTime);
|
} else {
|
||||||
result.setMinResponseTime(this.minResponseTimeThisTime);
|
result.setFailRateThisTime(100);
|
||||||
result.setResponseTimeDeviationThisTime(Math.round(Math
|
}
|
||||||
.sqrt(this.totalSquareResponseTime
|
} else {
|
||||||
/ this.totalSuccessCountThisTime
|
averageResponseTime = this.totalResponseTimeThisTime
|
||||||
- averageResponseTime * averageResponseTime)));
|
/ this.totalSuccessCountThisTime;
|
||||||
result.setFailRateThisTime(this.totalFailCountThisTime
|
result.setAverageResponseTime(averageResponseTime);
|
||||||
* 100
|
result.setMaxResponseTime(this.maxResponseTimeThisTime);
|
||||||
/ (this.totalFailCountThisTime + this.totalSuccessCountThisTime));
|
result.setMinResponseTime(this.minResponseTimeThisTime);
|
||||||
}
|
result.setResponseTimeDeviationThisTime(Math.round(Math
|
||||||
result.setFailThroughputThisTime(this.totalFailThroughputThisTime);
|
.sqrt(this.totalSquareResponseTime
|
||||||
result.setSuccessThroughputThisTime(this.totalSuccessThroughputThisTime);
|
/ this.totalSuccessCountThisTime
|
||||||
result.setTotalFailCountFromBegin(this.totalFailCountFromBegin);
|
- averageResponseTime * averageResponseTime)));
|
||||||
result.setTotalSuccessCountFromBegin(this.totalSuccessCountFromBegin);
|
result.setFailRateThisTime(this.totalFailCountThisTime
|
||||||
if (this.effectiveCount == 0) {
|
* 100
|
||||||
result.setAverageElapsedTime(0);
|
/ (this.totalFailCountThisTime + this.totalSuccessCountThisTime));
|
||||||
} else {
|
}
|
||||||
result.setAverageElapsedTime(this.totalElapsedTime
|
result.setFailThroughputThisTime(this.totalFailThroughputThisTime);
|
||||||
/ this.effectiveCount);
|
result.setSuccessThroughputThisTime(this.totalSuccessThroughputThisTime);
|
||||||
}
|
result.setTotalFailCountFromBegin(this.totalFailCountFromBegin);
|
||||||
result = dealWithInvalidSamplePoint(result);
|
result.setTotalSuccessCountFromBegin(this.totalSuccessCountFromBegin);
|
||||||
result.setSamplingTime(new Date());
|
if (this.effectiveCount == 0) {
|
||||||
reset();
|
result.setAverageElapsedTime(0);
|
||||||
return result;
|
} else {
|
||||||
}
|
result.setAverageElapsedTime(this.totalElapsedTime
|
||||||
|
/ this.effectiveCount);
|
||||||
private ScriptBriefResultModel dealWithInvalidSamplePoint(
|
}
|
||||||
ScriptBriefResultModel inputModel) {
|
result = dealWithInvalidSamplePoint(result);
|
||||||
if (this.totalFailCountThisTime == 0
|
result.setSamplingTime(new Date());
|
||||||
&& this.totalSuccessCountThisTime == 0) {
|
result.setvUserCount(this.activeVUserCountThisTime);
|
||||||
return this.getLastValidBriefResultModel();
|
reset();
|
||||||
}
|
return result;
|
||||||
this.setLastValidBriefResultModel(inputModel);
|
}
|
||||||
return inputModel;
|
|
||||||
}
|
private ScriptBriefResultModel dealWithInvalidSamplePoint(
|
||||||
}
|
ScriptBriefResultModel inputModel) {
|
||||||
|
if (this.totalFailCountThisTime == 0
|
||||||
|
&& this.totalSuccessCountThisTime == 0) {
|
||||||
|
return this.getLastValidBriefResultModel();
|
||||||
|
}
|
||||||
|
this.setLastValidBriefResultModel(inputModel);
|
||||||
|
return inputModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,131 +1,145 @@
|
||||||
package org.bench4q.master.test.datastatistics;
|
package org.bench4q.master.test.datastatistics;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import org.bench4q.master.testplan.datastatistics.ScriptBriefStatistics;
|
import org.bench4q.master.testplan.datastatistics.ScriptBriefStatistics;
|
||||||
import org.bench4q.share.models.agent.statistics.AgentBriefStatusModel;
|
import org.bench4q.share.models.agent.statistics.AgentBriefStatusModel;
|
||||||
import org.bench4q.share.models.master.statistics.ScriptBriefResultModel;
|
import org.bench4q.share.models.master.statistics.ScriptBriefResultModel;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class ScriptBriefStatisticsTest {
|
public class ScriptBriefStatisticsTest {
|
||||||
private ScriptBriefStatistics briefStatistics;
|
private ScriptBriefStatistics briefStatistics;
|
||||||
private static int TIME_UNIT_MS = 1000;
|
private static int TIME_UNIT_MS = 1000;
|
||||||
private static int FAIL_COUNT = 1;
|
private static int FAIL_COUNT = 1;
|
||||||
|
|
||||||
public ScriptBriefStatistics getBriefStatistics() {
|
public ScriptBriefStatistics getBriefStatistics() {
|
||||||
return briefStatistics;
|
return briefStatistics;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBriefStatistics(ScriptBriefStatistics briefStatistics) {
|
public void setBriefStatistics(ScriptBriefStatistics briefStatistics) {
|
||||||
this.briefStatistics = briefStatistics;
|
this.briefStatistics = briefStatistics;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScriptBriefStatisticsTest() {
|
public ScriptBriefStatisticsTest() {
|
||||||
this.setBriefStatistics(new ScriptBriefStatistics());
|
this.setBriefStatistics(new ScriptBriefStatistics());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addNullTest() {
|
public void addNullTest() {
|
||||||
this.getBriefStatistics().add(null);
|
this.getBriefStatistics().add(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addZeroTest() {
|
public void addZeroTest() {
|
||||||
briefStatistics.add(new AgentBriefStatusModel());
|
briefStatistics.add(new AgentBriefStatusModel());
|
||||||
ScriptBriefResultModel actualResult = briefStatistics.getStatistics();
|
ScriptBriefResultModel actualResult = briefStatistics.getStatistics();
|
||||||
ScriptBriefResultModel expectedResult = makeExpectedModelForZeroAgent();
|
ScriptBriefResultModel expectedResult = makeExpectedModelForZeroAgent();
|
||||||
assertTrue(actualResult.equals(expectedResult));
|
assertTrue(actualResult.equals(expectedResult));
|
||||||
}
|
assertEquals(0, actualResult.getvUserCount());
|
||||||
|
}
|
||||||
private ScriptBriefResultModel makeExpectedModelForZeroAgent() {
|
|
||||||
ScriptBriefResultModel result = new ScriptBriefResultModel();
|
private ScriptBriefResultModel makeExpectedModelForZeroAgent() {
|
||||||
result.setAverageElapsedTime(0);
|
ScriptBriefResultModel result = new ScriptBriefResultModel();
|
||||||
result.setAverageResponseTime(0);
|
result.setAverageElapsedTime(0);
|
||||||
result.setFailRateThisTime(0);
|
result.setAverageResponseTime(0);
|
||||||
result.setFailThroughputThisTime(0);
|
result.setFailRateThisTime(0);
|
||||||
result.setMaxResponseTime(0);
|
result.setFailThroughputThisTime(0);
|
||||||
result.setMinResponseTime(0);
|
result.setMaxResponseTime(0);
|
||||||
result.setResponseTimeDeviationThisTime(0);
|
result.setMinResponseTime(0);
|
||||||
result.setSuccessThroughputThisTime(0);
|
result.setResponseTimeDeviationThisTime(0);
|
||||||
result.setTotalFailCountFromBegin(0);
|
result.setSuccessThroughputThisTime(0);
|
||||||
result.setTotalSuccessCountFromBegin(0);
|
result.setTotalFailCountFromBegin(0);
|
||||||
return result;
|
result.setTotalSuccessCountFromBegin(0);
|
||||||
}
|
result.setvUserCount(0);
|
||||||
|
return result;
|
||||||
@Test
|
}
|
||||||
public void addOneTest() {
|
|
||||||
long timeFrame = 200;
|
@Test
|
||||||
this.getBriefStatistics().add(
|
public void addOneTest() {
|
||||||
buildOneInputModel(timeFrame, 200, 200, 200, 40000, 1));
|
long timeFrame = 200;
|
||||||
ScriptBriefResultModel actualModel = this.getBriefStatistics()
|
this.getBriefStatistics().add(
|
||||||
.getStatistics();
|
buildOneInputModel(timeFrame, 200, 200, 200, 40000, 1, 10));
|
||||||
ScriptBriefResultModel expectedModel = this
|
ScriptBriefResultModel actualModel = this.getBriefStatistics()
|
||||||
.makeExepectedModelForOneAgent();
|
.getStatistics();
|
||||||
assertTrue(actualModel.equals(expectedModel));
|
ScriptBriefResultModel expectedModel = this
|
||||||
}
|
.makeExepectedModelForOneAgent();
|
||||||
|
assertTrue(actualModel.equals(expectedModel));
|
||||||
public static AgentBriefStatusModel buildOneInputModel(long timeFrame,
|
}
|
||||||
long minRT, long maxRT, long totalRT, long totalSqureRT,
|
|
||||||
long successCount) {
|
@Test
|
||||||
AgentBriefStatusModel model = new AgentBriefStatusModel();
|
public void addOneTestWithNegativeVUser() {
|
||||||
model.setTimeFrame(timeFrame);
|
long timeFrame = 200;
|
||||||
model.setSuccessCountFromBegin(successCount);
|
this.getBriefStatistics().add(
|
||||||
model.setFailCountFromBegin(FAIL_COUNT);
|
buildOneInputModel(timeFrame, 200, 200, 200, 40000, 1, -2));
|
||||||
model.setSuccessThroughputThisTime(successCount * TIME_UNIT_MS
|
ScriptBriefResultModel actualModel = this.getBriefStatistics()
|
||||||
/ timeFrame);
|
.getStatistics();
|
||||||
model.setFailThroughputThisTime(FAIL_COUNT * TIME_UNIT_MS / timeFrame);
|
ScriptBriefResultModel expectedBriefResultModel = this
|
||||||
model.setMaxResponseTime(maxRT);
|
.makeExepectedModelForOneAgent();
|
||||||
model.setMinResponseTime(minRT);
|
expectedBriefResultModel.setvUserCount(-2);
|
||||||
model.setSuccessCountThisTime(successCount);
|
assertTrue(actualModel.equals(expectedBriefResultModel));
|
||||||
model.setFailCountThisTime(FAIL_COUNT);
|
}
|
||||||
model.setTotalResponseTimeThisTime(totalRT);
|
|
||||||
model.setTotalSqureResponseTimeThisTime(totalSqureRT);
|
public static AgentBriefStatusModel buildOneInputModel(long timeFrame,
|
||||||
return model;
|
long minRT, long maxRT, long totalRT, long totalSqureRT,
|
||||||
}
|
long successCount, long vUserCount) {
|
||||||
|
AgentBriefStatusModel model = new AgentBriefStatusModel();
|
||||||
private ScriptBriefResultModel makeExepectedModelForOneAgent() {
|
model.setTimeFrame(timeFrame);
|
||||||
ScriptBriefResultModel result = new ScriptBriefResultModel();
|
model.setSuccessCountFromBegin(successCount);
|
||||||
result.setAverageResponseTime(200);
|
model.setFailCountFromBegin(FAIL_COUNT);
|
||||||
result.setFailRateThisTime(50);
|
model.setSuccessThroughputThisTime(successCount * TIME_UNIT_MS
|
||||||
result.setFailThroughputThisTime(1 * TIME_UNIT_MS / 200);
|
/ timeFrame);
|
||||||
result.setMaxResponseTime(200);
|
model.setFailThroughputThisTime(FAIL_COUNT * TIME_UNIT_MS / timeFrame);
|
||||||
result.setMinResponseTime(200);
|
model.setMaxResponseTime(maxRT);
|
||||||
result.setResponseTimeDeviationThisTime(0);
|
model.setMinResponseTime(minRT);
|
||||||
result.setSuccessThroughputThisTime(1 * TIME_UNIT_MS / 200);
|
model.setSuccessCountThisTime(successCount);
|
||||||
result.setTotalFailCountFromBegin(1);
|
model.setFailCountThisTime(FAIL_COUNT);
|
||||||
result.setTotalSuccessCountFromBegin(1);
|
model.setTotalResponseTimeThisTime(totalRT);
|
||||||
return result;
|
model.setTotalSqureResponseTimeThisTime(totalSqureRT);
|
||||||
}
|
model.setvUserCount(vUserCount);
|
||||||
|
return model;
|
||||||
@Test
|
}
|
||||||
public void addTwoTest() {
|
|
||||||
long timeFrame1 = 200, timeFrame2 = 500;
|
private ScriptBriefResultModel makeExepectedModelForOneAgent() {
|
||||||
this.briefStatistics.add(buildOneInputModel(timeFrame1, 200, 200, 200,
|
ScriptBriefResultModel result = new ScriptBriefResultModel();
|
||||||
40000, 1));
|
result.setAverageResponseTime(200);
|
||||||
this.briefStatistics.add(buildOneInputModel(timeFrame2, 190, 210, 400,
|
result.setFailRateThisTime(50);
|
||||||
80200, 2));
|
result.setFailThroughputThisTime(1 * TIME_UNIT_MS / 200);
|
||||||
ScriptBriefResultModel actualModel = this.briefStatistics
|
result.setMaxResponseTime(200);
|
||||||
.getStatistics();
|
result.setMinResponseTime(200);
|
||||||
ScriptBriefResultModel expectedModel = makeExpectedModelForTwoAgent();
|
result.setResponseTimeDeviationThisTime(0);
|
||||||
assertTrue(actualModel.equals(expectedModel));
|
result.setSuccessThroughputThisTime(1 * TIME_UNIT_MS / 200);
|
||||||
}
|
result.setTotalFailCountFromBegin(1);
|
||||||
|
result.setTotalSuccessCountFromBegin(1);
|
||||||
private ScriptBriefResultModel makeExpectedModelForTwoAgent() {
|
result.setvUserCount(10);
|
||||||
ScriptBriefResultModel result = new ScriptBriefResultModel();
|
return result;
|
||||||
result.setAverageResponseTime(200);
|
}
|
||||||
result.setFailRateThisTime(40);
|
|
||||||
result.setFailThroughputThisTime(7);
|
@Test
|
||||||
result.setMaxResponseTime(210);
|
public void addTwoTest() {
|
||||||
result.setMinResponseTime(190);
|
long timeFrame1 = 200, timeFrame2 = 500;
|
||||||
result.setResponseTimeDeviationThisTime(8);
|
this.briefStatistics.add(buildOneInputModel(timeFrame1, 200, 200, 200,
|
||||||
result.setSuccessThroughputThisTime(9);
|
40000, 1, 10));
|
||||||
result.setTotalFailCountFromBegin(2);
|
this.briefStatistics.add(buildOneInputModel(timeFrame2, 190, 210, 400,
|
||||||
result.setTotalSuccessCountFromBegin(3);
|
80200, 2, 20));
|
||||||
return result;
|
ScriptBriefResultModel actualModel = this.briefStatistics
|
||||||
}
|
.getStatistics();
|
||||||
|
ScriptBriefResultModel expectedModel = makeExpectedModelForTwoAgent();
|
||||||
@Test
|
assertTrue(actualModel.equals(expectedModel));
|
||||||
public void testAddOneRealModel() {
|
}
|
||||||
|
|
||||||
}
|
private ScriptBriefResultModel makeExpectedModelForTwoAgent() {
|
||||||
}
|
ScriptBriefResultModel result = new ScriptBriefResultModel();
|
||||||
|
result.setAverageResponseTime(200);
|
||||||
|
result.setFailRateThisTime(40);
|
||||||
|
result.setFailThroughputThisTime(7);
|
||||||
|
result.setMaxResponseTime(210);
|
||||||
|
result.setMinResponseTime(190);
|
||||||
|
result.setResponseTimeDeviationThisTime(8);
|
||||||
|
result.setSuccessThroughputThisTime(9);
|
||||||
|
result.setTotalFailCountFromBegin(2);
|
||||||
|
result.setTotalSuccessCountFromBegin(3);
|
||||||
|
result.setvUserCount(30);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue