Search in sources :

Example 86 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;
        }
    }, mock(AgentStatusChangeListener.class));
    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));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) Test(org.junit.Test)

Example 87 with SystemEnvironment

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

the class AgentInstanceMother method agentWithConfigErrors.

public static AgentInstance agentWithConfigErrors() {
    ResourceConfig resourceConfig1 = new ResourceConfig("foo%");
    ResourceConfig resourceConfig2 = new ResourceConfig("bar$");
    AgentConfig agentConfig = new AgentConfig("uuid", "host", "IP", new ResourceConfigs(resourceConfig1, resourceConfig2));
    agentConfig.validateTree(ConfigSaveValidationContext.forChain(new BasicCruiseConfig()));
    AgentInstance agentInstance = AgentInstance.createFromConfig(agentConfig, new SystemEnvironment(), mock(AgentStatusChangeListener.class));
    return agentInstance;
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener)

Example 88 with SystemEnvironment

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

the class AgentInstanceTest method shouldNotRefreshDeniedAgent.

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

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

Example 89 with SystemEnvironment

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

the class DiskIsEmpty method onTearDown.

public void onTearDown() {
    new SystemEnvironment().clearProperty(SystemEnvironment.ARTIFACT_FULL_SIZE_LIMIT);
    new SystemEnvironment().clearProperty(SystemEnvironment.ARTIFACT_WARNING_SIZE_LIMIT);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment)

Example 90 with SystemEnvironment

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

the class SleepWork method doWork.

@Override
public void doWork(AgentIdentifier agentIdentifier, BuildRepositoryRemote remoteBuildRepository, GoArtifactsManipulator manipulator, EnvironmentVariableContext environmentVariableContext, AgentRuntimeInfo agentRuntimeInfo, PackageRepositoryExtension packageRepositoryExtension, SCMExtension scmExtension, TaskExtension taskExtension) {
    cancelLatch = new CountDownLatch(1);
    agentRuntimeInfo.busy(new AgentBuildingInfo("sleepwork", "sleepwork1"));
    boolean canceled = false;
    DefaultGoPublisher goPublisher = new DefaultGoPublisher(manipulator, new JobIdentifier(), remoteBuildRepository, agentRuntimeInfo);
    try {
        if (this.sleepInMilliSeconds > 0) {
            canceled = cancelLatch.await(this.sleepInMilliSeconds, TimeUnit.MILLISECONDS);
        }
        String result = canceled ? "done_canceled" : "done";
        manipulator.setProperty(null, new Property(name + "_result", result));
        SystemEnvironment systemEnvironment = new SystemEnvironment();
        if (systemEnvironment.isConsoleLogsThroughWebsocketEnabled() && systemEnvironment.isWebsocketsForAgentsEnabled()) {
            goPublisher.consumeLine(format("Sleeping for %s milliseconds", this.sleepInMilliSeconds));
        }
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentBuildingInfo(com.thoughtworks.go.server.service.AgentBuildingInfo) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) CountDownLatch(java.util.concurrent.CountDownLatch) Property(com.thoughtworks.go.domain.Property)

Aggregations

SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)174 Test (org.junit.Test)93 Before (org.junit.Before)38 File (java.io.File)37 AgentInstance (com.thoughtworks.go.domain.AgentInstance)27 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)15 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)14 ArrayList (java.util.ArrayList)14 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)11 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)10 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)10 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)10 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)9 AgentConfig (com.thoughtworks.go.config.AgentConfig)8 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)8 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)8 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)7 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)7 Date (java.util.Date)7 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)6