use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldResolveTriangleDependencyViaAutoBuild.
@Test
public void shouldResolveTriangleDependencyViaAutoBuild() throws Exception {
SystemEnvironment env = mock(SystemEnvironment.class);
when(env.enforceRevisionCompatibilityWithUpstream()).thenReturn(false);
int i = 0;
GitMaterial git = new GitMaterial("git");
String[] git_revs = { "g1" };
u.checkinInOrder(git, git_revs);
ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(git));
ScheduleTestUtil.AddedPipeline p5 = u.saveConfigWith("p5", u.m(p4));
ScheduleTestUtil.AddedPipeline p6 = u.saveConfigWith("p6", u.m(p4), u.m(p5));
String p4_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i++), "g1");
String p4_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i++), "g1");
String p5_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p5, u.d(i++), p4_2);
String p4_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i++), "g1");
String p4_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i), "g1");
MaterialRevisions given = u.mrs(u.mr(p4, true, p4_4), u.mr(p5, true, p5_1));
MaterialRevisions expected = u.mrs(u.mr(p4, false, p4_2), u.mr(p5, false, p5_1));
AutoBuild autoBuild = new AutoBuild(goConfigService, pipelineService, p6.config.name().toString(), env, materialChecker);
pipelineTimeline.update();
BuildCause buildCause = autoBuild.onModifications(given, false, null);
assertThat(buildCause.getMaterialRevisions(), is(expected));
}
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;
}
}, mock(AgentStatusChangeListener.class));
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 shouldRefreshDisabledAgent.
@Test
public void shouldRefreshDisabledAgent() throws Exception {
agentConfig.disable();
AgentInstance instance = AgentInstance.createFromConfig(agentConfig, new SystemEnvironment() {
public int getAgentConnectionTimeout() {
return -1;
}
}, mock(AgentStatusChangeListener.class));
instance.update(new AgentRuntimeInfo(agentConfig.getAgentIdentifier(), AgentRuntimeStatus.Building, currentWorkingDirectory(), "cookie", false));
instance.refresh();
assertThat(instance.getRuntimeStatus(), is(AgentRuntimeStatus.LostContact));
assertThat(instance.getStatus(), is(AgentStatus.Disabled));
}
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;
}
}, mock(AgentStatusChangeListener.class));
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 shouldNotifyAgentChangeListenerOnRefreshAndMarkedLostContact.
@Test
public void shouldNotifyAgentChangeListenerOnRefreshAndMarkedLostContact() throws Exception {
AgentInstance instance = AgentInstance.createFromConfig(agentConfig, new SystemEnvironment() {
public int getAgentConnectionTimeout() {
return -1;
}
}, agentStatusChangeListener);
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));
verify(agentStatusChangeListener, times(2)).onAgentStatusChange(instance);
}
Aggregations