Search in sources :

Example 1 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class AgentInstanceTest method shouldReturnTrueWhenFreeDiskOnAgentIsLow.

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

        @Override
        public long getAgentSizeLimit() {
            return 100 * 1024 * 1024;
        }
    });
    AgentRuntimeInfo newRuntimeInfo = new AgentRuntimeInfo(agentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
    long is90M = 90 * 1024 * 1024;
    newRuntimeInfo.setUsableSpace(is90M);
    original.update(newRuntimeInfo);
    assertThat(original.isLowDiskSpace(), is(true));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) Test(org.junit.Test)

Example 2 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class AgentInstanceTest method shouldBeLostContactWhenLastHeardTimeExeedTimeOut.

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

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

Example 3 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class AgentInstanceTest method shouldReturnFalseWhenAgentHasEnoughSpace.

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

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

Example 4 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class AgentInstanceTest method tearDown.

@After
public void tearDown() throws Exception {
    FileUtils.deleteQuietly(new File("config/agentkeystore"));
    new SystemEnvironment().setProperty("agent.connection.timeout", "300");
    new SystemEnvironment().clearProperty(SystemEnvironment.AGENT_SIZE_LIMIT);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) File(java.io.File) After(org.junit.After)

Example 5 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class SslInfrastructureServiceTest method requesterStub.

private SslInfrastructureService.RemoteRegistrationRequester requesterStub(final Registration registration) {
    final SslInfrastructureServiceTest me = this;
    final SystemEnvironment systemEnvironment = new SystemEnvironment();
    return new SslInfrastructureService.RemoteRegistrationRequester(null, agentRegistryStub(), new GoAgentServerHttpClient(new GoAgentServerHttpClientBuilder(systemEnvironment))) {

        protected Registration requestRegistration(String agentHostName, AgentAutoRegistrationProperties agentAutoRegisterProperties) throws IOException, ClassNotFoundException {
            LOGGER.debug("Requesting remote registration");
            me.remoteCalled = true;
            return registration;
        }
    };
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) GoAgentServerHttpClientBuilder(com.thoughtworks.go.agent.common.ssl.GoAgentServerHttpClientBuilder) GoAgentServerHttpClient(com.thoughtworks.go.agent.common.ssl.GoAgentServerHttpClient) AgentAutoRegistrationProperties(com.thoughtworks.go.config.AgentAutoRegistrationProperties)

Aggregations

SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)158 Test (org.junit.Test)82 Before (org.junit.Before)38 File (java.io.File)35 AgentInstance (com.thoughtworks.go.domain.AgentInstance)26 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)15 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)14 ArrayList (java.util.ArrayList)12 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)10 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)9 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)8 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)8 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)8 ZipUtil (com.thoughtworks.go.util.ZipUtil)8 Date (java.util.Date)8 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)7 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)7 AgentConfig (com.thoughtworks.go.config.AgentConfig)6 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)6 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)5