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