use of com.thoughtworks.go.util.MaterialFingerprintTag in project gocd by gocd.
the class GitRepoContainingSubmodule method modifyOneFileInSubmoduleAndUpdateMainRepo.
public List<Modification> modifyOneFileInSubmoduleAndUpdateMainRepo(File remoteSubmoduleRepoLocation, String submoduleNameInRepo, String fileName, String newContentOfFile) throws Exception {
String comment = "Changed file: " + fileName + " in submodule: " + remoteSubmoduleRepoLocation;
changeFile(remoteSubmoduleRepoLocation, fileName, newContentOfFile);
checkInOneFile(remoteSubmoduleRepoLocation, new File(fileName), comment);
CommandLine.createCommandLine("git").withEncoding("UTF-8").withArg("pull").withWorkingDir(new File(remoteRepoDir, submoduleNameInRepo)).runOrBomb(new MaterialFingerprintTag(null));
checkInOneFile(remoteRepoDir, new File(submoduleNameInRepo), comment);
return latestModification();
}
use of com.thoughtworks.go.util.MaterialFingerprintTag in project gocd by gocd.
the class MaterialUpdateServiceTest method shouldUpdateServerHealthMessageWhenHung.
@Test
void shouldUpdateServerHealthMessageWhenHung() {
// given
service = spy(service);
systemEnvironment.set(SystemEnvironment.MATERIAL_UPDATE_INACTIVE_TIMEOUT, 1);
ProcessManager processManager = mock(ProcessManager.class);
Material material = mock(Material.class);
service.updateMaterial(material);
when(service.getProcessManager()).thenReturn(processManager);
when(material.getFingerprint()).thenReturn("fingerprint");
when(material.getUriForDisplay()).thenReturn("uri");
when(material.getLongDescription()).thenReturn("details to uniquely identify a material");
when(material.isAutoUpdate()).thenReturn(true);
when(processManager.getIdleTimeFor(new MaterialFingerprintTag("fingerprint"))).thenReturn(60010L);
// when
service.updateMaterial(material);
// then
verify(serverHealthService).removeByScope(HealthStateScope.forMaterialUpdate(material));
ArgumentCaptor<ServerHealthState> argumentCaptor = ArgumentCaptor.forClass(ServerHealthState.class);
verify(serverHealthService).update(argumentCaptor.capture());
assertThat(argumentCaptor.getValue().getMessage()).isEqualTo("Material update for uri hung:");
assertThat(argumentCaptor.getValue().getDescription()).isEqualTo("Material update is currently running but has not shown any activity in the last 1 minute(s). This may be hung. Details - details to uniquely identify a material");
assertThat(argumentCaptor.getValue().getType()).isEqualTo(HealthStateType.general(HealthStateScope.forMaterialUpdate(material)));
}
use of com.thoughtworks.go.util.MaterialFingerprintTag in project gocd by gocd.
the class P4CommandTestBase method shouldBombForNonZeroReturnCode.
@Test
void shouldBombForNonZeroReturnCode() {
ProcessOutputStreamConsumer outputStreamConsumer = Mockito.mock(ProcessOutputStreamConsumer.class);
CommandLine line = Mockito.mock(CommandLine.class);
when(line.run(outputStreamConsumer, new MaterialFingerprintTag(null), "foo")).thenReturn(1);
try {
p4.execute(line, "foo", outputStreamConsumer, true);
fail("did't bomb for non zero return code");
} catch (Exception ignored) {
}
verify(line).run(outputStreamConsumer, new MaterialFingerprintTag(null), "foo");
}
use of com.thoughtworks.go.util.MaterialFingerprintTag in project gocd by gocd.
the class MaterialUpdateService method updateMaterial.
public boolean updateMaterial(Material material) {
Date inProgressSince = inProgress.putIfAbsent(material, new Date());
if (inProgressSince == null || !material.isAutoUpdate()) {
LOGGER.debug("[Material Update] Starting update of material {}", material);
try {
long trackingId = mduPerformanceLogger.materialSentToUpdateQueue(material);
queueFor(material).post(new MaterialUpdateMessage(material, trackingId));
return true;
} catch (RuntimeException e) {
inProgress.remove(material);
throw e;
}
} else {
LOGGER.warn("[Material Update] Skipping update of material {} which has been in-progress since {}", material, inProgressSince);
long idleTime = getProcessManager().getIdleTimeFor(new MaterialFingerprintTag(material.getFingerprint()));
if (idleTime > getMaterialUpdateInActiveTimeoutInMillis()) {
HealthStateScope scope = HealthStateScope.forMaterialUpdate(material);
serverHealthService.removeByScope(scope);
serverHealthService.update(warning("Material update for " + material.getUriForDisplay() + " hung:", "Material update is currently running but has not shown any activity in the last " + idleTime / 60000 + " minute(s). This may be hung. Details - " + material.getLongDescription(), general(scope)));
}
return false;
}
}
Aggregations