use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class BuildWorkTest method setUp.
@Before
public void setUp() throws Exception {
initMocks(this);
agentIdentifier = new AgentIdentifier("localhost", "127.0.0.1", "uuid");
environmentVariableContext = new EnvironmentVariableContext();
artifactManipulator = new GoArtifactsManipulatorStub();
new SystemEnvironment().setProperty("serviceUrl", SERVER_URL);
buildRepository = new com.thoughtworks.go.remote.work.BuildRepositoryRemoteStub();
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class BuildRepositoryMessageProducerTest method shouldAllocateNewCookieForEveryGetCookieRequest.
@Test
public void shouldAllocateNewCookieForEveryGetCookieRequest() throws Exception {
AgentIdentifier identifier = new AgentIdentifier("host", "192.168.1.1", "uuid");
when(oldImplementation.getCookie(identifier, "/foo/bar")).thenReturn("cookie");
assertThat(producer.getCookie(identifier, "/foo/bar"), is("cookie"));
// should not cache
when(oldImplementation.getCookie(identifier, "/foo/bar")).thenReturn("cookie1");
assertThat(producer.getCookie(identifier, "/foo/bar"), is("cookie1"));
}
use of com.thoughtworks.go.remote.AgentIdentifier 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());
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class WorkAssignmentsTest method setup.
@Before
public void setup() {
context = new ClassMockery();
idleAgentsTopic = context.mock(IdleAgentTopic.class, "idle_topic");
assignedWorkTopic = context.mock(WorkAssignedTopic.class, "assigned_work_topic");
context.checking(new Expectations() {
{
one(assignedWorkTopic).addListener(with(any(WorkAssignments.class)));
}
});
assignments = new WorkAssignments(idleAgentsTopic, assignedWorkTopic);
agentIdentifier = new AgentIdentifier("localhost", "127.0.0.1", "uuid");
agent = new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class MessageTest method encodeAndDecodePingMessage.
@Test
public void encodeAndDecodePingMessage() {
AgentRuntimeInfo info = new AgentRuntimeInfo(new AgentIdentifier("hostName", "ipAddress", "uuid"), null, null, null, false);
byte[] msg = MessageEncoding.encodeMessage(new Message(Action.ping, MessageEncoding.encodeData(info)));
Message decoded = MessageEncoding.decodeMessage(new ByteArrayInputStream(msg));
AgentRuntimeInfo decodedInfo = MessageEncoding.decodeData(decoded.getData(), AgentRuntimeInfo.class);
assertThat(decodedInfo.getIdentifier(), is(info.getIdentifier()));
}
Aggregations