Search in sources :

Example 36 with AgentIdentifier

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();
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Before(org.junit.Before)

Example 37 with AgentIdentifier

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"));
}
Also used : AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 38 with AgentIdentifier

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());
}
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)

Example 39 with AgentIdentifier

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);
}
Also used : Expectations(org.jmock.Expectations) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) ClassMockery(com.thoughtworks.go.util.ClassMockery) Before(org.junit.Before)

Example 40 with AgentIdentifier

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()));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) ByteArrayInputStream(java.io.ByteArrayInputStream) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Aggregations

AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)81 Test (org.junit.Test)57 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)34 FakeBuildRepositoryRemote (com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote)12 Before (org.junit.Before)11 UploadEntry (com.thoughtworks.go.matchers.UploadEntry)10 ArrayList (java.util.ArrayList)10 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)9 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)9 File (java.io.File)9 AgentConfig (com.thoughtworks.go.config.AgentConfig)5 AgentInstance (com.thoughtworks.go.domain.AgentInstance)5 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)5 AgentInstruction (com.thoughtworks.go.remote.AgentInstruction)4 NoWork (com.thoughtworks.go.remote.work.NoWork)4 Work (com.thoughtworks.go.remote.work.Work)4 Agent (com.thoughtworks.go.server.domain.Agent)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)3 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)2