Search in sources :

Example 41 with AgentRuntimeInfo

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

the class AgentInstanceTest method shouldReturnTrueWhenFreeDiskOnAgentIsLow.

@Test
void shouldReturnTrueWhenFreeDiskOnAgentIsLow() {
    AgentInstance original = AgentInstance.createFromAgent(agent, new SystemEnvironment() {

        @Override
        public long getAgentSizeLimit() {
            return 100 * 1024 * 1024;
        }
    }, mock(AgentStatusChangeListener.class));
    AgentRuntimeInfo newRuntimeInfo = new AgentRuntimeInfo(agent.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie");
    long is90M = 90 * 1024 * 1024;
    newRuntimeInfo.setUsableSpace(is90M);
    original.update(newRuntimeInfo);
    assertThat(original.isLowDiskSpace()).isTrue();
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) Test(org.junit.jupiter.api.Test)

Example 42 with AgentRuntimeInfo

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

the class AgentInstanceTest method shouldRefreshDisabledAgent.

@Test
void shouldRefreshDisabledAgent() {
    agent.disable();
    AgentInstance instance = AgentInstance.createFromAgent(agent, new SystemEnvironment() {

        @Override
        public int getAgentConnectionTimeout() {
            return -1;
        }
    }, mock(AgentStatusChangeListener.class));
    instance.update(new AgentRuntimeInfo(agent.getAgentIdentifier(), Building, currentWorkingDirectory(), "cookie"));
    instance.refresh();
    assertThat(instance.getRuntimeStatus()).isEqualTo(AgentRuntimeStatus.LostContact);
    assertThat(instance.getStatus()).isEqualTo(AgentStatus.Disabled);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) Test(org.junit.jupiter.api.Test)

Example 43 with AgentRuntimeInfo

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

the class AgentInstanceTest method shouldBeLostContactWhenLastHeardTimeExeedTimeOut.

@Test
void shouldBeLostContactWhenLastHeardTimeExeedTimeOut() {
    AgentInstance instance = AgentInstance.createFromAgent(agent, new SystemEnvironment() {

        @Override
        public int getAgentConnectionTimeout() {
            return -1;
        }
    }, mock(AgentStatusChangeListener.class));
    assertThat(instance.getStatus()).isEqualTo(AgentStatus.Missing);
    instance.update(new AgentRuntimeInfo(agent.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"));
    instance.refresh();
    assertThat(instance.getStatus()).isEqualTo(AgentStatus.LostContact);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) Test(org.junit.jupiter.api.Test)

Example 44 with AgentRuntimeInfo

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

the class AgentInstanceTest method shouldReturnFalseWhenAgentHasEnoughSpace.

@Test
void shouldReturnFalseWhenAgentHasEnoughSpace() {
    AgentInstance original = AgentInstance.createFromAgent(agent, new SystemEnvironment() {

        @Override
        public long getAgentSizeLimit() {
            return 100 * 1024 * 1024;
        }
    }, mock(AgentStatusChangeListener.class));
    AgentRuntimeInfo newRuntimeInfo = new AgentRuntimeInfo(agent.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie");
    long is110M = 110 * 1024 * 1024;
    newRuntimeInfo.setUsableSpace(is110M);
    original.update(newRuntimeInfo);
    assertThat(original.isLowDiskSpace()).isFalse();
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) Test(org.junit.jupiter.api.Test)

Example 45 with AgentRuntimeInfo

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

the class AgentInstanceTest method shouldGetAgentAndBootstrapperVersions.

@Test
void shouldGetAgentAndBootstrapperVersions() {
    AgentInstance agentInstance = AgentInstanceMother.idle();
    AgentRuntimeInfo newRuntimeInfo = new AgentRuntimeInfo(agentInstance.getAgentIdentifier(), agentInstance.getRuntimeStatus(), "some-location", "some-cookie");
    newRuntimeInfo.updateBootstrapperVersion("20.3.0-1234").updateAgentVersion("20.5.0-2345");
    agentInstance.update(newRuntimeInfo);
    assertThat(agentInstance.getAgentBootstrapperVersion()).isEqualTo("20.3.0-1234");
    assertThat(agentInstance.getAgentVersion()).isEqualTo("20.5.0-2345");
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) Test(org.junit.jupiter.api.Test)

Aggregations

AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)150 Test (org.junit.jupiter.api.Test)70 Test (org.junit.Test)52 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)35 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)29 File (java.io.File)17 RemoteInvocation (org.springframework.remoting.support.RemoteInvocation)16 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)14 Agent (com.thoughtworks.go.config.Agent)13 AgentInstruction (com.thoughtworks.go.remote.AgentInstruction)13 FakeBuildRepositoryRemote (com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote)12 AgentInstance.createFromLiveAgent (com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent)11 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)11 AgentBuildingInfo (com.thoughtworks.go.server.service.AgentBuildingInfo)11 UploadEntry (com.thoughtworks.go.matchers.UploadEntry)10 ArrayList (java.util.ArrayList)10 StringContains.containsString (org.hamcrest.core.StringContains.containsString)9 AgentInstance (com.thoughtworks.go.domain.AgentInstance)8 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)8 NullAgentInstance (com.thoughtworks.go.domain.NullAgentInstance)7