Search in sources :

Example 1 with ElasticAgentRuntimeInfo

use of com.thoughtworks.go.server.service.ElasticAgentRuntimeInfo in project gocd by gocd.

the class AgentStatusChangeNotifierTest method shouldNotifyIfAgentIsElastic.

@Test
public void shouldNotifyIfAgentIsElastic() throws Exception {
    ElasticAgentRuntimeInfo agentRuntimeInfo = new ElasticAgentRuntimeInfo(new AgentIdentifier("localhost", "127.0.0.1", "uuid"), AgentRuntimeStatus.Idle, "/foo/one", null, "42", "go.cd.elastic-agent-plugin.docker");
    AgentConfig agentConfig = new AgentConfig();
    agentConfig.setElasticAgentId("42");
    agentConfig.setElasticPluginId("go.cd.elastic-agent-plugin.docker");
    agentConfig.setIpAddress("127.0.0.1");
    AgentInstance agentInstance = AgentInstance.createFromConfig(agentConfig, new SystemEnvironment(), mock(AgentStatusChangeListener.class));
    agentInstance.update(agentRuntimeInfo);
    when(notificationPluginRegistry.isAnyPluginInterestedIn("agent-status")).thenReturn(true);
    agentStatusChangeNotifier.onAgentStatusChange(agentInstance);
    verify(pluginNotificationQueue).post(captor.capture());
    assertThat(captor.getValue().getData() instanceof AgentNotificationData, is(true));
    AgentNotificationData data = (AgentNotificationData) captor.getValue().getData();
    assertTrue(data.isElastic());
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentConfig(com.thoughtworks.go.config.AgentConfig) AgentNotificationData(com.thoughtworks.go.domain.notificationdata.AgentNotificationData) ElasticAgentRuntimeInfo(com.thoughtworks.go.server.service.ElasticAgentRuntimeInfo) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) Test(org.junit.Test)

Aggregations

AgentConfig (com.thoughtworks.go.config.AgentConfig)1 AgentInstance (com.thoughtworks.go.domain.AgentInstance)1 AgentNotificationData (com.thoughtworks.go.domain.notificationdata.AgentNotificationData)1 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)1 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)1 ElasticAgentRuntimeInfo (com.thoughtworks.go.server.service.ElasticAgentRuntimeInfo)1 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)1 Test (org.junit.Test)1