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