Search in sources :

Example 86 with JobIdentifier

use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.

the class TestSuiteTest method testContainsTestName.

@Test
public void testContainsTestName() {
    testSuite.addTest("testB", TestStatus.Error, new JobIdentifier("", -1, "", "", "", "job-1"));
    testSuite.addTest("testA", TestStatus.Error, new JobIdentifier("", -1, "", "", "", "job-1"));
    assertThat(testSuite.contains("testA"), is(true));
    assertThat(testSuite.contains("testB"), is(true));
    assertThat(testSuite.contains("testC"), is(false));
    assertThat(testSuite.contains(""), is(false));
    assertThat(testSuite.contains(null), is(false));
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Test(org.junit.Test)

Example 87 with JobIdentifier

use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.

the class ConsoleActivityMonitorTest method shouldOnlyMonitorConsoleActivityForBuildingJobs.

@Test
public void shouldOnlyMonitorConsoleActivityForBuildingJobs() {
    when(timeProvider.currentTimeMillis()).thenReturn(new DateTime(1971, 1, 1, 0, 55, 59, 0).getMillis());
    JobIdentifier unresponsiveJob = new JobIdentifier("pipelines", 10, "label-10", "stage", "3", "job", 25l);
    consoleActivityMonitor.consoleUpdatedFor(unresponsiveJob);
    when(timeProvider.currentTimeMillis()).thenReturn(new DateTime(1972, 1, 1, 1, 5, 0, 0).getMillis());
    consoleActivityMonitor.cancelUnresponsiveJobs(scheduleService);
    verifyNoMoreInteractions(jobInstanceService);
    verifyNoMoreInteractions(scheduleService);
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 88 with JobIdentifier

use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.

the class ConsoleActivityMonitorTest method shouldNotCancelJobIfJobTimeOutIsSetTo0.

@Test
public void shouldNotCancelJobIfJobTimeOutIsSetTo0() {
    JobIdentifier unresponsiveJob = new JobIdentifier("pipelines", 10, "label-10", "stage", "3", "job", 25l);
    listener.jobStatusChanged(buildingInstance(unresponsiveJob));
    when(timeProvider.currentTimeMillis()).thenReturn(new DateTime(1971, 1, 1, 0, 55, 59, 0).getMillis());
    consoleActivityMonitor.consoleUpdatedFor(unresponsiveJob);
    when(timeProvider.currentTimeMillis()).thenReturn(new DateTime(1972, 1, 1, 1, 1, 0, 0).getMillis());
    when(goConfigService.canCancelJobIfHung(unresponsiveJob)).thenReturn(false);
    consoleActivityMonitor.cancelUnresponsiveJobs(scheduleService);
    verify(scheduleService, never()).cancelJob(unresponsiveJob);
    verifyNoMoreInteractions(jobInstanceService);
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 89 with JobIdentifier

use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.

the class ConsoleActivityMonitorTest method shouldSetServerHealthMessageWhenJobSeemsUnresponsive.

@Test
public void shouldSetServerHealthMessageWhenJobSeemsUnresponsive() {
    DateTime now = new DateTime();
    when(timeProvider.currentTimeMillis()).thenReturn(now.getMillis());
    JobIdentifier job = new JobIdentifier("foo", 12, "foo-10", "stage", "2", "job", 20l);
    listener.jobStatusChanged(buildingInstance(job));
    // just over warning time limit i.e. 2 minutes
    when(timeProvider.currentTimeMillis()).thenReturn(now.plusMinutes(2).plusSeconds(1).getMillis());
    consoleActivityMonitor.cancelUnresponsiveJobs(scheduleService);
    verify(serverHealthService).update(ServerHealthState.warningWithHtml("Job 'foo/stage/job' is not responding", "Job <a href='/go/tab/build/detail/foo/12/stage/2/job'>foo/stage/job</a> is currently running but has not shown any console activity in the last 2 minute(s). This job may be hung.", HealthStateType.general(HealthStateScope.forJob("foo", "stage", "job"))));
    // after 4 minutes
    when(timeProvider.currentTimeMillis()).thenReturn(now.plusMinutes(4).plusSeconds(1).getMillis());
    consoleActivityMonitor.cancelUnresponsiveJobs(scheduleService);
    verify(serverHealthService).update(ServerHealthState.warningWithHtml("Job 'foo/stage/job' is not responding", "Job <a href='/go/tab/build/detail/foo/12/stage/2/job'>foo/stage/job</a> is currently running but has not shown any console activity in the last 4 minute(s). This job may be hung.", HealthStateType.general(HealthStateScope.forJob("foo", "stage", "job"))));
    // 6 hours
    when(goConfigService.getUnresponsiveJobTerminationThreshold(any(JobIdentifier.class))).thenReturn(360 * 60 * 1000L);
    // after 62 minutes
    when(timeProvider.currentTimeMillis()).thenReturn(now.plusHours(1).plusMinutes(2).plusSeconds(1).getMillis());
    consoleActivityMonitor.cancelUnresponsiveJobs(scheduleService);
    verify(serverHealthService).update(ServerHealthState.warningWithHtml("Job 'foo/stage/job' is not responding", "Job <a href='/go/tab/build/detail/foo/12/stage/2/job'>foo/stage/job</a> is currently running but has not shown any console activity in the last 62 minute(s). This job may be hung.", HealthStateType.general(HealthStateScope.forJob("foo", "stage", "job"))));
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 90 with JobIdentifier

use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.

the class ConsoleActivityMonitorTest method shouldCancelUnresponsiveJobAndLetOtherJobComplete.

@Test
public void shouldCancelUnresponsiveJobAndLetOtherJobComplete() {
    JobIdentifier unresponsiveJob = new JobIdentifier("pipelines", 10, "label-10", "stage", "3", "job", 25l);
    listener.jobStatusChanged(buildingInstance(unresponsiveJob));
    JobIdentifier responsiveJob = new JobIdentifier("foo", 12, "foo-10", "stage", "2", "job", 20l);
    listener.jobStatusChanged(buildingInstance(responsiveJob));
    when(timeProvider.currentTimeMillis()).thenReturn(new DateTime(1971, 1, 1, 0, 55, 59, 0).getMillis());
    consoleActivityMonitor.consoleUpdatedFor(unresponsiveJob);
    consoleActivityMonitor.consoleUpdatedFor(responsiveJob);
    when(timeProvider.currentTimeMillis()).thenReturn(new DateTime(1972, 1, 1, 1, 0, 0, 0).getMillis());
    consoleActivityMonitor.consoleUpdatedFor(responsiveJob);
    when(timeProvider.currentTimeMillis()).thenReturn(new DateTime(1972, 1, 1, 1, 1, 0, 0).getMillis());
    consoleActivityMonitor.cancelUnresponsiveJobs(scheduleService);
    verify(scheduleService).cancelJob(unresponsiveJob);
    consoleActivityMonitor.cancelUnresponsiveJobs(scheduleService);
    verifyNoMoreInteractions(jobInstanceService);
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)113 Test (org.junit.Test)85 File (java.io.File)16 JobInstance (com.thoughtworks.go.domain.JobInstance)15 Pipeline (com.thoughtworks.go.domain.Pipeline)13 DateTime (org.joda.time.DateTime)12 Before (org.junit.Before)10 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)7 Stage (com.thoughtworks.go.domain.Stage)6 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)5 IllegalArtifactLocationException (com.thoughtworks.go.domain.exception.IllegalArtifactLocationException)5 AgentMetadata (com.thoughtworks.go.plugin.access.elastic.models.AgentMetadata)5 IOException (java.io.IOException)5 ModelAndView (org.springframework.web.servlet.ModelAndView)5 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)3 Property (com.thoughtworks.go.domain.Property)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 RunIf (com.googlecode.junit.ext.RunIf)2 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)2 HeaderConstraint (com.thoughtworks.go.server.security.HeaderConstraint)2