add test about the bug emerging in sampling
add test about the bug emerging in sampling
This commit is contained in:
parent
1f6f999b35
commit
ef495e95be
|
@ -227,6 +227,9 @@ public class RunningAgentDB implements RunningAgentInterface {
|
|||
|
||||
@Override
|
||||
public TestBriefStatusModel briefAll() {
|
||||
if (this.isStoped()) {
|
||||
return null;
|
||||
}
|
||||
return this.getAgentMessenger().scriptBriefAll(this.getAgent(),
|
||||
this.getAgentRunId());
|
||||
}
|
||||
|
|
|
@ -10,9 +10,10 @@ import javax.xml.bind.JAXBException;
|
|||
|
||||
import org.bench4q.master.domain.RunningAgentInterface;
|
||||
import org.bench4q.master.domain.entity.Agent;
|
||||
import org.bench4q.master.domain.entity.RunningAgentDB;
|
||||
import org.bench4q.master.domain.factory.RunningAgentFactory;
|
||||
import org.bench4q.master.domain.valueobject.datastatistics.RunningScriptSampler;
|
||||
import org.bench4q.share.enums.master.AgentStatus;
|
||||
import org.bench4q.share.models.master.statistics.ScriptResultModel;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -36,7 +37,22 @@ public class Test_ScriptSample {
|
|||
runningAgents.add(this.runningAgentFactory
|
||||
.buildRunningAgentWithOutIdAndRunningScript(
|
||||
this.testcase2.get(0), 10, UUID.randomUUID()));
|
||||
runningAgents.add(this.runningAgentFactory
|
||||
.buildRunningAgentWithOutIdAndRunningScript(
|
||||
this.testcase2.get(1), 20, UUID.randomUUID()));
|
||||
RunningScriptSampler sampler = new RunningScriptSampler(runningAgents);
|
||||
assertNotNull(sampler.getResultModelFromAgent());
|
||||
long totalSuccessCountBeforeKill = sampler.getResultModelFromAgent()
|
||||
.getScriptBriefResultModel().getTotalSuccessCountFromBegin();
|
||||
|
||||
kill(this.testcase2.get(0));
|
||||
|
||||
long totalSuccessCountAfterKill = sampler.getResultModelFromAgent()
|
||||
.getScriptBriefResultModel().getTotalSuccessCountFromBegin();
|
||||
assertTrue(totalSuccessCountAfterKill >= totalSuccessCountBeforeKill);
|
||||
|
||||
}
|
||||
|
||||
private void kill(Agent agent) {
|
||||
agent.setCurrentEnumStatus(AgentStatus.BreakDown);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package stubs;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bench4q.master.domain.entity.Agent;
|
||||
import org.bench4q.master.infrastructure.communication.AgentMessenger;
|
||||
import org.bench4q.share.enums.master.AgentStatus;
|
||||
import org.bench4q.share.models.agent.BehaviorBriefModel;
|
||||
import org.bench4q.share.models.agent.RunScenarioModel;
|
||||
import org.bench4q.share.models.agent.RunScenarioResultModel;
|
||||
import org.bench4q.share.models.agent.ServerStatusModel;
|
||||
|
@ -41,13 +43,25 @@ public class Mock_AgentMessenger implements AgentMessenger {
|
|||
|
||||
@Override
|
||||
public TestBriefStatusModel scriptBriefAll(Agent agent, UUID runId) {
|
||||
if (isDead(agent)) {
|
||||
return null;
|
||||
}
|
||||
TestBriefStatusModel result = new TestBriefStatusModel();
|
||||
result.setScenarioBriefModel(new AgentBriefStatusModel());
|
||||
AgentBriefStatusModel scenarioBriefModel = new AgentBriefStatusModel();
|
||||
scenarioBriefModel.setSuccessCountFromBegin(1000);
|
||||
result.setScenarioBriefModel(scenarioBriefModel);
|
||||
result.setPagesBriefModel(new AgentPagesBriefModel());
|
||||
result.setBehaviorsBriefModel(new AgentBehaviorsBriefModel());
|
||||
AgentBehaviorsBriefModel behaviorsBriefModel = new AgentBehaviorsBriefModel();
|
||||
behaviorsBriefModel
|
||||
.setBehaviorBriefModels(new ArrayList<BehaviorBriefModel>());
|
||||
result.setBehaviorsBriefModel(behaviorsBriefModel);
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isDead(Agent agent) {
|
||||
return agent.getCurrentEnumStatus() == AgentStatus.BreakDown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StopTestModel stop(Agent agent, UUID runId) {
|
||||
// if (runId == this.testId) {
|
||||
|
|
Loading…
Reference in New Issue