add realStartTime to scenario

add realStartTime to scenario
This commit is contained in:
coderfengyun 2014-09-02 10:27:42 +08:00
parent fd82b54d4e
commit 9157b793fc
8 changed files with 24 additions and 8 deletions

View File

@ -26,4 +26,6 @@ public interface RunningScriptInterface {
public List<TestPlanScriptResult> doAfterRun(Date sampleTime);
public Date getStartTime();
}

View File

@ -185,7 +185,7 @@ public class RunningAgentDB implements RunningAgentInterface {
RunScenarioResultModel runScenarioResultModel = this
.getAgentMessenger().submitScenrioWithParams(this.getAgent(),
this.getAgentRunId(), script2.loadParamFiles(),
runScenarioModel);
runScenarioModel, this.getRunningScript().getStartTime());
if (runScenarioResultModel == null) {
return false;
}

View File

@ -316,4 +316,8 @@ public class TestPlan implements IAggregate {
return true;
}
public Date getCurrentStartTime() {
return getLastRunningTime();
}
}

View File

@ -312,4 +312,9 @@ public class TestPlanScript implements RunningScriptInterface {
}
return true;
}
@Override
public Date getStartTime() {
return this.getTestPlan().getCurrentStartTime();
}
}

View File

@ -1,6 +1,7 @@
package org.bench4q.master.infrastructure.communication;
import java.io.File;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.Future;
@ -17,7 +18,7 @@ public interface AgentMessenger {
public RunScenarioResultModel submitScenrioWithParams(Agent agent,
UUID agentRunId, List<File> paramFiles,
final RunScenarioModel runScenarioModel);
final RunScenarioModel runScenarioModel, Date realStartDate);
public RunScenarioResultModel runWithParams(Agent agent, UUID agentRunId);

View File

@ -1,6 +1,7 @@
package org.bench4q.master.infrastructure.communication.impl;
import java.io.File;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
@ -73,14 +74,14 @@ public class AgentMessengerImpl implements AgentMessenger {
public RunScenarioResultModel submitScenrioWithParams(Agent agent,
UUID agentRunId, List<File> paramFiles,
final RunScenarioModel runScenarioModel) {
final RunScenarioModel runScenarioModel, Date realStartDate) {
HttpResponse httpResponse = null;
try {
final String modelContent = MarshalHelper
.tryMarshal(runScenarioModel);
httpResponse = this.httpRequester.postFiles(null,
buildBaseUrl(agent) + "/test/submitScenarioWithParams/"
+ agentRunId, "files[]", paramFiles,
+ agentRunId+ "/" + realStartDate.getTime(), "files[]", paramFiles,
"scenarioModel", new LinkedList<String>() {
private static final long serialVersionUID = 1L;
{
@ -97,13 +98,13 @@ public class AgentMessengerImpl implements AgentMessenger {
public Future<RunScenarioResultModel> submitScenarioWithParamsAsync(
final Agent agent, final UUID agentRunId,
final List<File> paramFiles, final RunScenarioModel runScenarioModel) {
final List<File> paramFiles, final RunScenarioModel runScenarioModel, final Date realStartDate) {
return this.executorService
.submit(new Callable<RunScenarioResultModel>() {
@Override
public RunScenarioResultModel call() throws Exception {
return submitScenrioWithParams(agent, agentRunId,
paramFiles, runScenarioModel);
paramFiles, runScenarioModel, realStartDate);
}
});
}

View File

@ -5,7 +5,9 @@ import static org.junit.Assert.*;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.xml.bind.JAXBException;
import org.apache.commons.io.FileUtils;
@ -72,7 +74,7 @@ public class Test_AgentMessenger extends TestBase_MakeUpTestPlan {
System.out.println(model.getRunId());
RunScenarioResultModel modelAfter = this.getAgentMessenger()
.submitScenrioWithParams(agent, model.getRunId(), paramFiles,
inputModel);
inputModel, new Date());
assertEquals(model.getRunId(), modelAfter.getRunId());
model = this.getAgentMessenger().runWithParams(agent, model.getRunId());
assertNotNull(model);

View File

@ -2,6 +2,7 @@ package stubs;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.Future;
@ -34,7 +35,7 @@ public class Mock_AgentMessenger implements AgentMessenger {
@Override
public RunScenarioResultModel submitScenrioWithParams(Agent agent,
UUID agentRunId, List<File> paramFiles,
RunScenarioModel runScenarioModel) {
RunScenarioModel runScenarioModel, Date realStartTime) {
return new RunScenarioResultModel(this.testId);
}