Search in sources :

Example 46 with AgentRuntimeInfo

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

the class AgentInstanceTest method shouldNotifyAgentChangeListenerOnRefreshAndMarkedLostContact.

@Test
public void shouldNotifyAgentChangeListenerOnRefreshAndMarkedLostContact() throws Exception {
    AgentInstance instance = AgentInstance.createFromConfig(agentConfig, new SystemEnvironment() {

        public int getAgentConnectionTimeout() {
            return -1;
        }
    }, agentStatusChangeListener);
    assertThat(instance.getStatus(), is(AgentStatus.Missing));
    instance.update(new AgentRuntimeInfo(agentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false));
    instance.refresh();
    assertThat(instance.getStatus(), is(AgentStatus.LostContact));
    verify(agentStatusChangeListener, times(2)).onAgentStatusChange(instance);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) Test(org.junit.Test)

Example 47 with AgentRuntimeInfo

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

the class AgentInstanceTest method shouldNotChangePendingAgentIpAddress.

@Test
public void shouldNotChangePendingAgentIpAddress() throws Exception {
    AgentInstance pending = AgentInstance.createFromLiveAgent(new AgentRuntimeInfo(agentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), systemEnvironment, mock(AgentStatusChangeListener.class));
    AgentRuntimeInfo info = new AgentRuntimeInfo(new AgentIdentifier("ccedev01", "10.18.7.52", "uuid"), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
    assertThat(pending.isIpChangeRequired(info.getIpAdress()), is(false));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) Test(org.junit.Test)

Example 48 with AgentRuntimeInfo

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

the class AgentInstanceTest method shouldBeAbleToDenyAgentWhenItIsBuilding.

@Test
public void shouldBeAbleToDenyAgentWhenItIsBuilding() throws Exception {
    AgentInstance original = AgentInstance.createFromConfig(agentConfig, systemEnvironment, mock(AgentStatusChangeListener.class));
    AgentRuntimeInfo runtimeInfo = buildingRuntimeInfo();
    original.update(runtimeInfo);
    assertThat(original.canDisable(), is(true));
    original.deny();
    assertThat(agentConfig.isDisabled(), is(true));
    assertThat(original.getStatus(), is(AgentStatus.Disabled));
    assertThat(original.getBuildingInfo(), is(runtimeInfo.getBuildingInfo()));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) Test(org.junit.Test)

Example 49 with AgentRuntimeInfo

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

the class AgentInstanceTest method shouldUpdateAgentBackToIdleAfterCancelledTaskFinishes.

@Test
public void shouldUpdateAgentBackToIdleAfterCancelledTaskFinishes() throws Exception {
    AgentInstance cancelled = AgentInstanceMother.cancelled();
    AgentRuntimeInfo fromAgent = new AgentRuntimeInfo(cancelled.agentConfig().getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
    fromAgent.idle();
    cancelled.update(fromAgent);
    assertThat(cancelled.getStatus(), is(AgentStatus.Idle));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) Test(org.junit.Test)

Example 50 with AgentRuntimeInfo

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

the class AgentInstanceTest method shouldBecomeIdleAfterApprove.

@Test
public void shouldBecomeIdleAfterApprove() throws Exception {
    AgentInstance instance = AgentInstance.createFromLiveAgent(new AgentRuntimeInfo(agentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), systemEnvironment, mock(AgentStatusChangeListener.class));
    instance.enable();
    instance.update(new AgentRuntimeInfo(agentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false));
    assertThat(instance.getStatus(), is(AgentStatus.Idle));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) Test(org.junit.Test)

Aggregations

AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)123 Test (org.junit.Test)101 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)34 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)26 File (java.io.File)16 AgentInstruction (com.thoughtworks.go.remote.AgentInstruction)13 StringContains.containsString (org.hamcrest.core.StringContains.containsString)13 FakeBuildRepositoryRemote (com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote)12 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)11 UploadEntry (com.thoughtworks.go.matchers.UploadEntry)10 AgentBuildingInfo (com.thoughtworks.go.server.service.AgentBuildingInfo)10 ArrayList (java.util.ArrayList)10 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)9 AgentInstance (com.thoughtworks.go.domain.AgentInstance)7 Before (org.junit.Before)7 Expectations (org.jmock.Expectations)4 RunIf (com.googlecode.junit.ext.RunIf)3 AgentConfig (com.thoughtworks.go.config.AgentConfig)3 Date (java.util.Date)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3