assertEquals(preConfMsg, "build.type=test", dist.getAttributeValue("entries"));
}
public void testPickAgent2Agents() throws Exception {
// register agent
final BuildAgent agentAvailable = new BuildAgent(
BuildAgentServiceImplTest.TEST_AGENT_PROPERTIES_FILE,
BuildAgentServiceImplTest.TEST_USER_DEFINED_PROPERTIES_FILE, true);
final BuildAgent agentAvailable2 = new BuildAgent(
BuildAgentServiceImplTest.TEST_AGENT_PROPERTIES_FILE,
BuildAgentServiceImplTest.TEST_USER_DEFINED_PROPERTIES_FILE, true);
try {
assertFalse(agentAvailable.getService().isBusy());
assertFalse(agentAvailable2.getService().isBusy());
DistributedMasterBuilder masterBuilder = createMasterBuilder();
// try to find agents
final BuildAgentService agentFoundFirst = masterBuilder.pickAgent();
assertNotNull("Couldn't find first agent", agentFoundFirst);
assertTrue(agentFoundFirst.isBusy());
final BuildAgentService agentFoundSecond = masterBuilder.pickAgent();
assertNotNull("Couldn't find second agent", agentFoundSecond);
assertTrue(agentFoundFirst.isBusy());
assertTrue(agentFoundSecond.isBusy());
final BuildAgentService agentFoundThird = masterBuilder.pickAgent();
assertNull("Shouldn't find third agent", agentFoundThird);
// set Agent to Not busy, then make sure it can be found again.
// callTestDoBuild() only needed to clearOuputFiles() will succeed
BuildAgentServiceImplTest.callTestDoBuild(false, agentAvailable.getService());
agentAvailable.getService().clearOutputFiles();
final BuildAgentService agentRefound = masterBuilder.pickAgent();
assertNotNull("Couldn't find released agent", agentRefound);
assertTrue("Claimed agent should show as busy. (Did we find a better way?)",
agentRefound.isBusy());
} finally {
// terminate JoinManager in BuildAgent
agentAvailable.terminate();
agentAvailable2.terminate();
}
}