use of com.thoughtworks.go.server.perf.SchedulingPerformanceLogger in project gocd by gocd.
the class ScheduleServiceStageTriggerTest method shouldNotNotifyListenersForWhenCancelStageTransactionRollsback.
@Test
public void shouldNotNotifyListenersForWhenCancelStageTransactionRollsback() throws Exception {
Pipeline oldest = preCondition.createPipelineWithFirstStagePassedAndSecondStageRunning();
preCondition.createPipelineWithFirstStagePassedAndSecondStageHasNotStarted();
preCondition.createPipelineWithFirstStagePassedAndSecondStageHasNotStarted();
final Stage stage = oldest.getStages().byName(preCondition.ftStage);
final StageIdentifier identifier = stage.getIdentifier();
StageStatusTopic stageStatusTopic = mock(StageStatusTopic.class);
JobResultTopic jobResultTopic = mock(JobResultTopic.class);
StageStatusListener stageStatusListener = mock(StageStatusListener.class);
JobInstanceService jobInstanceService = jobInstanceService(jobResultTopic);
StageService stageService = new StageService(stageDao, jobInstanceService, stageStatusTopic, stageStatusCache, securityService, pipelineDao, changesetService, goConfigService, transactionTemplate, transactionSynchronizationManager, goCache, stageStatusListener);
SchedulingPerformanceLogger schedulingPerformanceLogger = mock(SchedulingPerformanceLogger.class);
scheduleService = new ScheduleService(goConfigService, pipelineService, stageService, schedulingCheckerService, pipelineScheduledTopic, pipelineDao, stageDao, stageOrderService, securityService, pipelineScheduleQueue, this.jobInstanceService, jobInstanceDao, agentAssignment, environmentConfigService, pipelineLockService, serverHealthService, transactionTemplate, null, transactionSynchronizationManager, null, null, null, null, schedulingPerformanceLogger, null);
try {
transactionTemplate.executeWithExceptionHandling(new TransactionCallback() {
@Override
public Object doInTransaction(TransactionStatus status) throws Exception {
scheduleService.cancelAndTriggerRelevantStages(stage.getId(), null, null);
throw new GoUnauthorizedException();
}
});
} catch (Exception e) {
//ignore
}
verify(stageStatusTopic, never()).post(any(StageStatusMessage.class));
verify(jobResultTopic, never()).post(any(JobResultMessage.class));
verify(stageStatusListener, never()).stageStatusChanged(any(Stage.class));
}
use of com.thoughtworks.go.server.perf.SchedulingPerformanceLogger in project gocd by gocd.
the class ScheduleServiceTest method setup.
@Before
public void setup() {
jobInstanceService = mock(JobInstanceService.class);
goConfigService = mock(GoConfigService.class);
environmentConfigService = mock(EnvironmentConfigService.class);
serverHealthService = mock(ServerHealthService.class);
final TestTransactionSynchronizationManager synchronizationManager = new TestTransactionSynchronizationManager();
schedulingChecker = mock(SchedulingCheckerService.class);
pipelineScheduleQueue = mock(PipelineScheduleQueue.class);
consoleActivityMonitor = mock(ConsoleActivityMonitor.class);
pipelinePauseService = mock(PipelinePauseService.class);
stageService = mock(StageService.class);
securityService = mock(SecurityService.class);
pipelineService = mock(PipelineService.class);
localizer = mock(Localizer.class);
timeProvider = new TimeProvider();
schedulingPerformanceLogger = mock(SchedulingPerformanceLogger.class);
elasticProfileService = mock(ElasticProfileService.class);
service = new ScheduleService(goConfigService, pipelineService, stageService, schedulingChecker, mock(PipelineScheduledTopic.class), mock(PipelineDao.class), mock(StageDao.class), mock(StageOrderService.class), securityService, pipelineScheduleQueue, jobInstanceService, mock(JobInstanceDao.class), mock(AgentAssignment.class), environmentConfigService, mock(PipelineLockService.class), serverHealthService, new TestTransactionTemplate(synchronizationManager), mock(AgentService.class), synchronizationManager, timeProvider, consoleActivityMonitor, pipelinePauseService, instanceFactory, schedulingPerformanceLogger, elasticProfileService);
}
use of com.thoughtworks.go.server.perf.SchedulingPerformanceLogger in project gocd by gocd.
the class JobRerunScheduleServiceTest method setup.
@Before
public void setup() {
jobInstanceService = mock(JobInstanceService.class);
goConfigService = mock(GoConfigService.class);
environmentConfigService = mock(EnvironmentConfigService.class);
serverHealthService = mock(ServerHealthService.class);
final TestTransactionSynchronizationManager synchronizationManager = new TestTransactionSynchronizationManager();
schedulingChecker = mock(SchedulingCheckerService.class);
pipelineScheduleQueue = mock(PipelineScheduleQueue.class);
pipelineService = mock(PipelineService.class);
stageService = mock(StageService.class);
securityService = mock(SecurityService.class);
lockService = mock(PipelineLockService.class);
txnTemplate = new TestTransactionTemplate(synchronizationManager);
timeProvider = new TimeProvider();
instanceFactory = mock(InstanceFactory.class);
schedulingPerformanceLogger = mock(SchedulingPerformanceLogger.class);
elasticProfileService = mock(ElasticProfileService.class);
service = new ScheduleService(goConfigService, pipelineService, stageService, schedulingChecker, mock(PipelineScheduledTopic.class), mock(PipelineDao.class), mock(StageDao.class), mock(StageOrderService.class), securityService, pipelineScheduleQueue, jobInstanceService, mock(JobInstanceDao.class), mock(AgentAssignment.class), environmentConfigService, lockService, serverHealthService, txnTemplate, mock(AgentService.class), synchronizationManager, timeProvider, null, null, instanceFactory, schedulingPerformanceLogger, elasticProfileService);
}
use of com.thoughtworks.go.server.perf.SchedulingPerformanceLogger in project gocd by gocd.
the class PipelineSchedulerTest method setUp.
@Before
public void setUp() {
queue = mock(ScheduleCheckQueue.class);
configService = mock(GoConfigService.class);
ServerHealthService serverHealthService = mock(ServerHealthService.class);
SchedulingCheckerService schedulingCheckerService = mock(SchedulingCheckerService.class);
buildCauseProducerService = mock(BuildCauseProducerService.class);
topic = mock(ScheduleCheckCompletedTopic.class);
schedulingPerformanceLogger = mock(SchedulingPerformanceLogger.class);
scheduler = new PipelineScheduler(configService, serverHealthService, schedulingCheckerService, buildCauseProducerService, queue, topic, schedulingPerformanceLogger);
}
use of com.thoughtworks.go.server.perf.SchedulingPerformanceLogger in project gocd by gocd.
the class ScheduleServiceStageTriggerTest method shouldDoCancellationInTransaction.
@Test
public void shouldDoCancellationInTransaction() throws Exception {
Pipeline oldest = preCondition.createPipelineWithFirstStagePassedAndSecondStageRunning();
preCondition.createPipelineWithFirstStagePassedAndSecondStageHasNotStarted();
preCondition.createPipelineWithFirstStagePassedAndSecondStageHasNotStarted();
Stage stage = oldest.getStages().byName(preCondition.ftStage);
StageStatusTopic stageStatusTopic = mock(StageStatusTopic.class);
JobResultTopic jobResultTopic = mock(JobResultTopic.class);
StageStatusListener stageStatusListener = mock(StageStatusListener.class);
StageService stageService = mock(StageService.class);
when(stageService.stageById(stage.getId())).thenReturn(stage);
Mockito.doAnswer(new Answer() {
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
throw new RuntimeException();
}
}).when(stageService).cancelStage(stage);
StageOrderService stageOrderService = mock(StageOrderService.class);
SchedulingPerformanceLogger schedulingPerformanceLogger = mock(SchedulingPerformanceLogger.class);
scheduleService = new ScheduleService(goConfigService, pipelineService, stageService, schedulingCheckerService, pipelineScheduledTopic, pipelineDao, stageDao, stageOrderService, securityService, pipelineScheduleQueue, this.jobInstanceService, jobInstanceDao, agentAssignment, environmentConfigService, pipelineLockService, serverHealthService, transactionTemplate, null, transactionSynchronizationManager, null, null, null, null, schedulingPerformanceLogger, null);
try {
scheduleService.cancelAndTriggerRelevantStages(stage.getId(), null, null);
} catch (RuntimeException e) {
//ignore
}
verify(stageStatusTopic, never()).post(any(StageStatusMessage.class));
verify(jobResultTopic, never()).post(any(JobResultMessage.class));
verify(stageStatusListener, never()).stageStatusChanged(any(Stage.class));
}
Aggregations