Search in sources :

Example 1 with StackPatchService

use of com.sequenceiq.cloudbreak.service.stackpatch.StackPatchService in project cloudbreak by hortonworks.

the class ExistingStackPatcherJobInitializerTest method alreadyFixedShouldNotBeRescheduled.

@Test
void alreadyFixedShouldNotBeRescheduled() {
    when(config.getPatchConfigs()).thenReturn(Map.of(UNBOUND_RESTART, getConfig(true)));
    StackPatch stackPatch = createStackPatch(stack1, UNBOUND_RESTART);
    stackPatch.setStatus(StackPatchStatus.FIXED);
    doReturn(List.of(stackPatch)).when(stackPatchService).findAllByTypeForStackIds(eq(UNBOUND_RESTART), any());
    underTest.initJobs();
    verify(jobService, times(1)).schedule(captor.capture());
    Assertions.assertThat(captor.getAllValues()).noneMatch(a -> a.getJobResource().getLocalId().equals(ID_1) && a.getStackPatchType().equals(UNBOUND_RESTART)).anyMatch(a -> a.getJobResource().getLocalId().equals(ID_2) && a.getStackPatchType().equals(UNBOUND_RESTART));
    verify(stackPatchService, never()).getOrCreate(Long.valueOf(ID_1), UNBOUND_RESTART);
    verify(stackPatchService).getOrCreate(Long.valueOf(ID_2), UNBOUND_RESTART);
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) BeforeEach(org.junit.jupiter.api.BeforeEach) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Mock(org.mockito.Mock) CREATE_IN_PROGRESS(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.CREATE_IN_PROGRESS) Mockito.lenient(org.mockito.Mockito.lenient) Captor(org.mockito.Captor) StackPatchType(com.sequenceiq.cloudbreak.domain.stack.StackPatchType) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) StackPatchStatus(com.sequenceiq.cloudbreak.domain.stack.StackPatchStatus) ArgumentCaptor(org.mockito.ArgumentCaptor) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Map(java.util.Map) Assertions(org.assertj.core.api.Assertions) Mockito.doReturn(org.mockito.Mockito.doReturn) CREATE_FAILED(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.CREATE_FAILED) LOGGING_AGENT_AUTO_RESTART(com.sequenceiq.cloudbreak.domain.stack.StackPatchType.LOGGING_AGENT_AUTO_RESTART) InjectMocks(org.mockito.InjectMocks) ExistingStackPatcherConfig(com.sequenceiq.cloudbreak.job.stackpatcher.config.ExistingStackPatcherConfig) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) METERING_AZURE_METADATA(com.sequenceiq.cloudbreak.domain.stack.StackPatchType.METERING_AZURE_METADATA) Set(java.util.Set) StackPatchTypeConfig(com.sequenceiq.cloudbreak.job.stackpatcher.config.StackPatchTypeConfig) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) JobResource(com.sequenceiq.cloudbreak.quartz.model.JobResource) DELETE_COMPLETED(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.DELETE_COMPLETED) StackPatch(com.sequenceiq.cloudbreak.domain.stack.StackPatch) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) StackPatchService(com.sequenceiq.cloudbreak.service.stackpatch.StackPatchService) Mockito.never(org.mockito.Mockito.never) List(java.util.List) DELETE_FAILED(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.DELETE_FAILED) UNBOUND_RESTART(com.sequenceiq.cloudbreak.domain.stack.StackPatchType.UNBOUND_RESTART) DELETE_IN_PROGRESS(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.DELETE_IN_PROGRESS) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) StackPatch(com.sequenceiq.cloudbreak.domain.stack.StackPatch) Test(org.junit.jupiter.api.Test)

Aggregations

CREATE_FAILED (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.CREATE_FAILED)1 CREATE_IN_PROGRESS (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.CREATE_IN_PROGRESS)1 DELETE_COMPLETED (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.DELETE_COMPLETED)1 DELETE_FAILED (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.DELETE_FAILED)1 DELETE_IN_PROGRESS (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.DELETE_IN_PROGRESS)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 StackPatch (com.sequenceiq.cloudbreak.domain.stack.StackPatch)1 StackPatchStatus (com.sequenceiq.cloudbreak.domain.stack.StackPatchStatus)1 StackPatchType (com.sequenceiq.cloudbreak.domain.stack.StackPatchType)1 LOGGING_AGENT_AUTO_RESTART (com.sequenceiq.cloudbreak.domain.stack.StackPatchType.LOGGING_AGENT_AUTO_RESTART)1 METERING_AZURE_METADATA (com.sequenceiq.cloudbreak.domain.stack.StackPatchType.METERING_AZURE_METADATA)1 UNBOUND_RESTART (com.sequenceiq.cloudbreak.domain.stack.StackPatchType.UNBOUND_RESTART)1 ExistingStackPatcherConfig (com.sequenceiq.cloudbreak.job.stackpatcher.config.ExistingStackPatcherConfig)1 StackPatchTypeConfig (com.sequenceiq.cloudbreak.job.stackpatcher.config.StackPatchTypeConfig)1 JobResource (com.sequenceiq.cloudbreak.quartz.model.JobResource)1 StackService (com.sequenceiq.cloudbreak.service.stack.StackService)1 StackPatchService (com.sequenceiq.cloudbreak.service.stackpatch.StackPatchService)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1