parent
70ded922fe
commit
504456cce2
|
@ -1,34 +0,0 @@
|
|||
package org.bench4q.master.integrated;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.bench4q.master.domain.entity.Monitor;
|
||||
import org.bench4q.master.domain.entity.TestPlan;
|
||||
import org.bench4q.master.unitTest.TestBase_MakeUpTestPlan;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "classpath:service-test-context.xml" })
|
||||
public class Test_Monitor extends TestBase_MakeUpTestPlan {
|
||||
|
||||
@Before
|
||||
public void prepare() {
|
||||
prepareForTestPlanRunning();
|
||||
submitATestPlanWithOneScript();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoAfterRun() {
|
||||
TestPlan testPlan = this.getTestPlanRepository().getTestPlanInDomainBy(
|
||||
getTestPlanRunIdUuid());
|
||||
assertEquals(1, testPlan.getMonitors().size());
|
||||
for (Monitor monitor : testPlan.getMonitors()) {
|
||||
monitor.doAfterRun();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -4,7 +4,6 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
import org.bench4q.master.domain.entity.Monitor;
|
||||
import org.bench4q.master.domain.valueobject.datastatistics.TestMonitorSampler;
|
||||
import org.bench4q.master.unitTest.TestBase_MakeUpTestPlan;
|
||||
import org.bench4q.share.models.monitor.MonitorMain;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
|
@ -17,7 +16,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "classpath:service-test-context.xml" })
|
||||
public class Test_TestMonitorSampler extends TestBase_MakeUpTestPlan {
|
||||
public class Test_TestMonitorSampler {
|
||||
|
||||
private TestMonitorSampler testMonitorSampler;
|
||||
private Monitor monitor;
|
||||
|
|
|
@ -53,6 +53,7 @@ public class Test_TestPlan extends TestBase_MakeUpTestPlan {
|
|||
TestPlan testPlanInDomain = this.getTestPlanFactory().convertToDomain(
|
||||
testPlanFromRepo);
|
||||
testPlanInDomain.run();
|
||||
this.getTestPlanRepository().attachRunningTestPlan(testPlanInDomain);
|
||||
assertEquals(TestPlanStatus.InRunning.name(),
|
||||
testPlanInDomain.getCurrentStatus());
|
||||
|
||||
|
@ -72,8 +73,7 @@ public class Test_TestPlan extends TestBase_MakeUpTestPlan {
|
|||
testPlanScript.getRequireLoad());
|
||||
assertNotNull(testPlanScript.getRunningAgentsDB());
|
||||
assertEquals(1, testPlanScript.getRunningAgentsDB().size());
|
||||
RunningAgentDB runningAgentDB = extractRunningAgent(testPlanScript,
|
||||
Test_AGENT_HOSTNAME);
|
||||
RunningAgentDB runningAgentDB = extractTheFirstRunningAgent(testPlanScript);
|
||||
assertNotNull(runningAgentDB);
|
||||
assertEquals(EACH_SCRIPT_LOAD_SMALLSCALE, runningAgentDB.getLoadInUse());
|
||||
Thread.sleep(10000);
|
||||
|
|
|
@ -218,9 +218,8 @@ public class TestBase_MakeUpTestPlan extends TestBase {
|
|||
return;
|
||||
}
|
||||
testPlan.setCurrentStatus(TestPlanStatus.Complete.name());
|
||||
RunningAgentDB runningAgent = extractRunningAgent(
|
||||
testPlan.extracSpecifiedScript(getScriptId()),
|
||||
Test_AGENT_HOSTNAME);
|
||||
RunningAgentDB runningAgent = extractTheFirstRunningAgent(testPlan
|
||||
.extracSpecifiedScript(getScriptId()));
|
||||
RunningScriptInterface runningScript = testPlan
|
||||
.extracSpecifiedScript(getScriptId());
|
||||
runningScript.doForComplete();
|
||||
|
@ -234,13 +233,11 @@ public class TestBase_MakeUpTestPlan extends TestBase {
|
|||
this.getTestPlanRepository().detach(testPlan.getId());
|
||||
}
|
||||
|
||||
protected RunningAgentDB extractRunningAgent(TestPlanScript testPlanScript,
|
||||
String hostName) {
|
||||
protected RunningAgentDB extractTheFirstRunningAgent(
|
||||
TestPlanScript testPlanScript) {
|
||||
for (RunningAgentDB runningAgentDB : testPlanScript
|
||||
.getRunningAgentsDB()) {
|
||||
if (runningAgentDB.getAgent().getHostName().equals(hostName)) {
|
||||
return runningAgentDB;
|
||||
}
|
||||
return runningAgentDB;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
package org.bench4q.master.unitTest.entity;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.bench4q.master.domain.entity.Monitor;
|
||||
import org.bench4q.master.domain.entity.TestPlan;
|
||||
import org.bench4q.master.unitTest.TestBase_MakeUpTestPlan;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "classpath:service-test-context.xml" })
|
||||
public class Test_Monitor extends TestBase_MakeUpTestPlan {
|
||||
|
||||
@Before
|
||||
public void prepare() {
|
||||
prepareForTestPlanRunning();
|
||||
submitATestPlanWithOneScript();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoAfterRun() {
|
||||
TestPlan testPlan = this.getTestPlanRepository().getTestPlanInDomainBy(
|
||||
getTestPlanRunIdUuid());
|
||||
assertEquals(1, testPlan.getMonitors().size());
|
||||
for (Monitor monitor : testPlan.getMonitors()) {
|
||||
monitor.doAfterRun();
|
||||
}
|
||||
for (Monitor monitor : getTestPlanRepository().getTestPlanInDomainBy(
|
||||
getTestPlanRunIdUuid()).getMonitors()) {
|
||||
assertEquals(5, monitor.getResults().size());
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void clear() {
|
||||
cleanUpForTestPlanRunning();
|
||||
}
|
||||
|
||||
}
|
|
@ -90,8 +90,8 @@ public class Test_TestPlan extends TestBase_MakeUpTestPlan {
|
|||
}
|
||||
|
||||
private TestPlan getTestPlan() {
|
||||
TestPlan testPlanFromRepo = this.getTestPlanRepository().getTestPlanInDomainBy(
|
||||
getTestPlanRunIdUuid());
|
||||
TestPlan testPlanFromRepo = this.getTestPlanRepository()
|
||||
.getTestPlanInDomainBy(getTestPlanRunIdUuid());
|
||||
TestPlan testPlanInDomain = this.getTestPlanFactory().convertToDomain(
|
||||
testPlanFromRepo);
|
||||
return testPlanInDomain;
|
||||
|
@ -115,4 +115,5 @@ public class Test_TestPlan extends TestBase_MakeUpTestPlan {
|
|||
this.getHaPool().checkAllHeartBeat();
|
||||
assertEquals(500, this.getHaPool().getCurrentAvailableLoad());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import stubs.Mock_AgentMessenger;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { HighAvailablePoolImpl.class,
|
||||
AgentRepository.class, Mock_AgentMessenger.class, HttpRequester.class,
|
||||
|
|
|
@ -4,6 +4,7 @@ import static org.junit.Assert.*;
|
|||
|
||||
import org.bench4q.master.domain.entity.Agent;
|
||||
import org.bench4q.master.domain.repository.AgentRepository;
|
||||
import org.bench4q.master.helper.SessionHelper;
|
||||
import org.bench4q.share.enums.master.AgentStatus;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -12,7 +13,7 @@ import org.springframework.test.context.ContextConfiguration;
|
|||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "classpath:service-test-context.xml" })
|
||||
@ContextConfiguration(classes = { AgentRepository.class, SessionHelper.class })
|
||||
public class Test_AgentRepository {
|
||||
private AgentRepository agentRepoitory;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.bench4q.master.unitTest.infrastructure.ha;
|
||||
package stubs;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
Loading…
Reference in New Issue