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