AgentController implements Agent, AgentConstants { public void shutdown() { if (m_timer != null) { m_timer.cancel(); } if (m_fanOutStreamSender != null) { m_fanOutStreamSender.shutdown(); } m_agentControllerServerListener.shutdown(); LOGGER.info("Agent controller shuts down"); } AgentController(Condition eventSyncCondition, AgentConfig agentConfig); @SuppressWarnings("ConstantConditions") void run(); void shutdown(); SystemDataModel getSystemDataModel(); AgentConfig getAgentConfig();  }
@Test public void testAgentStatus() throws InterruptedException { agentControllerServerDaemon.shutdown(); agentControllerServerDaemon = new AgentControllerServerDaemon(agentControllerServerDaemon.getPort()); agentControllerServerDaemon.start(); sleep(3000); allAvailableAgents = agentControllerServerDaemon.getAllAvailableAgents(); assertThat(allAvailableAgents.size(), is(2)); }
@Test public void testStartAgent() { console1 = new SingleConsole(getFreePort()); console1.start(); console1.setReportPath(new File("./tmp/console-home")); assertThat(console1.getAllAttachedAgentsCount(), is(0)); GrinderProperties grinderProperties = new GrinderProperties(); grinderProperties.setInt(GrinderProperties.CONSOLE_PORT, console1.getConsolePort()); String localHostAddress = NetworkUtils.getLocalHostAddress(); grinderProperties.setProperty(GrinderProperties.CONSOLE_HOST, localHostAddress); AgentIdentity next = getAgentIdentity(allAvailableAgents, 0); agentControllerServerDaemon.startAgent(grinderProperties, next); waitAndAssertUntilAgentAttachedTo(console1, 1, 2); agentControllerServerDaemon.shutdown(); waitAndAssertUntilAgentAttachedTo(console1, 0, 5); }
@Test public void testAgentControllerServerDaemonRecovery() { sleep(2000); Set<AgentIdentity> allAvailableAgents = agentControllerServerDaemon.getAllAvailableAgents(); assertThat(allAvailableAgents.size(), is(2)); SingleConsole console1 = new SingleConsole(6372); console1.start(); console1.setReportPath(new File("./tmp/console-home")); GrinderProperties grinderProperties = new GrinderProperties(); grinderProperties.setInt(GrinderProperties.CONSOLE_PORT, console1.getConsolePort()); agentControllerServerDaemon.startAgent(grinderProperties, getAgentIdentity(allAvailableAgents, 0)); agentControllerServerDaemon.startAgent(grinderProperties, getAgentIdentity(allAvailableAgents, 1)); waitAndAssertUntilAgentAttachedTo(console1, 2, 10); agentControllerServerDaemon.shutdown(); waitAndAssertUntilAgentAttachedTo(console1, 0, 5); agentControllerServerDaemon = new AgentControllerServerDaemon(agentControllerServerDaemon.getPort()); agentControllerServerDaemon.start(); waitAndAssertUntilAgentAttachedTo(agentControllerServerDaemon, 2, 10); sleep(2000); allAvailableAgents = agentControllerServerDaemon.getAllAvailableAgents(); agentControllerServerDaemon.startAgent(grinderProperties, getAgentIdentity(allAvailableAgents, 0)); agentControllerServerDaemon.startAgent(grinderProperties, getAgentIdentity(allAvailableAgents, 1)); waitAndAssertUntilAgentAttachedTo(console1, 2, 10); }