use of com.thoughtworks.go.util.LogFixture in project gocd by gocd.
the class CcTrayActivityListenerTest method shouldLogAndIgnoreAnyChangesWhichCannotBeHandled.
@Test
public void shouldLogAndIgnoreAnyChangesWhichCannotBeHandled() throws Exception {
CcTrayStageStatusChangeHandler normalStageStatusChangeHandler = mock(CcTrayStageStatusChangeHandler.class);
CcTrayJobStatusChangeHandler failingJobStatusChangeHandler = mock(CcTrayJobStatusChangeHandler.class);
doThrow(new RuntimeException("Ouch. Failed.")).when(failingJobStatusChangeHandler).call(any(JobInstance.class));
try (LogFixture logFixture = logFixtureFor(CcTrayActivityListener.class, Level.DEBUG)) {
CcTrayActivityListener listener = new CcTrayActivityListener(goConfigService, failingJobStatusChangeHandler, normalStageStatusChangeHandler, configChangeHandler);
listener.initialize();
listener.jobStatusChanged(JobInstanceMother.passed("some-job-this-should-fail"));
listener.stageStatusChanged(StageMother.unrunStage("some-stage"));
waitForProcessingToHappen();
assertThat(logFixture.contains(Level.WARN, "Failed to handle action in CCTray queue"), is(true));
}
verify(normalStageStatusChangeHandler).call(StageMother.unrunStage("some-stage"));
}
use of com.thoughtworks.go.util.LogFixture in project gocd by gocd.
the class P4OutputParserTest method shouldIgnoreBadLinesAndLogThem.
@Test
public void shouldIgnoreBadLinesAndLogThem() throws ParseException {
try (LogFixture logging = logFixtureFor(P4OutputParser.class, Level.DEBUG)) {
final String output = "Change 539921 on 2008/09/24 " + "by abc@SomeRefinery_abc_sa1-sgr-xyz-001 'more work in progress on MDC un'\n";
final String description = "Change that I cannot parse :-(\n";
context.checking(new Expectations() {
{
allowing(p4Client).describe(with(any(Long.class)));
will(returnValue(description));
}
});
List<Modification> modifications = parser.modifications(new ConsoleResult(0, Arrays.asList(output.split("\n")), new ArrayList<>(), new ArrayList<>(), new ArrayList<>()));
assertThat(modifications.size(), is(0));
assertThat(logging.getLog(), containsString(description));
}
}
use of com.thoughtworks.go.util.LogFixture in project gocd by gocd.
the class GoConfigDaoTestBase method shouldLogAnyErrorMessageIncludingTheValidationError.
@Test
public void shouldLogAnyErrorMessageIncludingTheValidationError() throws Exception {
try (LogFixture logger = logFixtureFor(GoFileConfigDataSource.class, Level.DEBUG)) {
try {
cachedGoConfig.save(INVALID_CONFIG_WITH_TYPE_FOR_ARTIFACT, false);
fail();
} catch (Exception e) {
assertThat(logger.getLog(), containsString("'type' is not allowed to appear in element 'test'."));
}
}
}
use of com.thoughtworks.go.util.LogFixture in project gocd by gocd.
the class BuildCauseProducerServiceIntegrationTimerTest method pipelineWithTimerShouldRerunWhenItHasAlreadyRunWithLatestMaterials_GivenTimerIsNOTSetToTriggerOnlyForNewMaterials.
@Test
public void pipelineWithTimerShouldRerunWhenItHasAlreadyRunWithLatestMaterials_GivenTimerIsNOTSetToTriggerOnlyForNewMaterials() throws Exception {
int i = 1;
String pipelineName = "p1";
GitMaterial git1 = u.wf(new GitMaterial("git1"), "folder");
ScheduleTestUtil.AddedPipeline up1 = u.saveConfigWith("up1", u.m(git1));
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWithTimer(pipelineName, u.timer("* * * * * ? 2000", false), u.m(git1), u.m(up1));
u.checkinFile(git1, "g11", TestFileUtil.createTempFile("blah_g11"), ModifiedAction.added);
String up1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up1, u.d(i++), "g11");
pipelineTimeline.update();
// Run once with latest, when pipeline schedules due to timer.
buildCauseProducerService.timerSchedulePipeline(p1.config, new ServerHealthStateOperationResult());
assertThat(piplineScheduleQueue.toBeScheduled().size(), is(1));
assertThat(piplineScheduleQueue.toBeScheduled().get(pipelineName).getMaterialRevisions(), isSameMaterialRevisionsAs(u.mrs(u.mr(git1, true, "g11"), u.mr(up1, true, up1_1))));
BuildCause buildCause = piplineScheduleQueue.toBeScheduled().get(pipelineName);
String up1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up1, u.d(i++), "g11");
piplineScheduleQueue.finishSchedule(pipelineName, buildCause, buildCause);
try (LogFixture logFixture = logFixtureFor(TimedBuild.class, Level.INFO)) {
// Timer time comes around again. Will rerun since the new flag (runOnlyOnNewMaterials) is not ON.
buildCauseProducerService.timerSchedulePipeline(p1.config, new ServerHealthStateOperationResult());
assertThat(piplineScheduleQueue.toBeScheduled().size(), is(1));
assertThat(piplineScheduleQueue.toBeScheduled().get(pipelineName).getMaterialRevisions(), is(u.mrs(u.mr(git1, false, "g11"), u.mr(up1, false, up1_2))));
assertThat(logFixture.contains(Level.INFO, "Skipping scheduling of timer-triggered pipeline 'p1' as it has previously run with the latest material(s)."), is(false));
}
}
use of com.thoughtworks.go.util.LogFixture in project gocd by gocd.
the class UpdateAgentStatusTest method shouldLogWarningWhenIPAddressChanges.
@Test
public void shouldLogWarningWhenIPAddressChanges() throws Exception {
AgentIdentifier agentIdentifier1 = new AgentIdentifier("localhost", "10.18.3.95", "uuid");
AgentRuntimeInfo agentRuntimeInfo1 = new AgentRuntimeInfo(agentIdentifier1, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
agentRuntimeInfo1.busy(new AgentBuildingInfo("building", "buildLocator"));
agentRuntimeInfo1.setLocation("/myDirectory");
try (LogFixture logging = logFixtureFor(AgentService.class, Level.DEBUG)) {
agentService.updateRuntimeInfo(agentRuntimeInfo1);
assertThat(logging.getLog(), containsString("Agent with UUID [uuid] changed IP Address from [10.81.2.1] to [10.18.3.95]"));
}
}
Aggregations