Search in sources :

Example 1 with Authenticator

use of com.sequenceiq.cloudbreak.cloud.Authenticator in project cloudbreak by hortonworks.

the class StackCreationServiceTest method setUp.

@BeforeEach
void setUp() {
    Whitebox.setInternalState(underTest, "ephemeralVolumeChecker", new InstanceGroupEphemeralVolumeChecker());
    CloudConnector<Object> cloudConnector = Mockito.mock(CloudConnector.class);
    when(cloudPlatformConnectors.get(any())).thenReturn(cloudConnector);
    MetadataCollector metadataCollector = Mockito.mock(MetadataCollector.class);
    when(cloudConnector.metadata()).thenReturn(metadataCollector);
    Authenticator authenticator = Mockito.mock(Authenticator.class);
    when(cloudConnector.authentication()).thenReturn(authenticator);
    InstanceStoreMetadata instanceStoreMetadata = getInstanceStoreMetadata();
    when(metadataCollector.collectInstanceStorageCount(any(), any())).thenReturn(instanceStoreMetadata);
}
Also used : InstanceGroupEphemeralVolumeChecker(com.sequenceiq.cloudbreak.service.stack.InstanceGroupEphemeralVolumeChecker) InstanceStoreMetadata(com.sequenceiq.cloudbreak.cloud.model.InstanceStoreMetadata) MetadataCollector(com.sequenceiq.cloudbreak.cloud.MetadataCollector) Authenticator(com.sequenceiq.cloudbreak.cloud.Authenticator) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with Authenticator

use of com.sequenceiq.cloudbreak.cloud.Authenticator in project cloudbreak by hortonworks.

the class ClusterUpgradeImageValidationHandlerTest method setupCloudConnector.

private void setupCloudConnector(CloudContext cloudContext, CloudCredential cloudCredential) {
    cloudConnector = mock(CloudConnector.class);
    Authenticator authenticator = mock(Authenticator.class);
    when(authenticator.authenticate(cloudContext, cloudCredential)).thenReturn(authenticatedContext);
    when(cloudConnector.authentication()).thenReturn(authenticator);
    when(cloudPlatformConnectors.get(CLOUD_PLATFORM_VARIANT)).thenReturn(cloudConnector);
}
Also used : CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) Authenticator(com.sequenceiq.cloudbreak.cloud.Authenticator)

Example 3 with Authenticator

use of com.sequenceiq.cloudbreak.cloud.Authenticator in project cloudbreak by hortonworks.

the class DelayedStartStackHandlerTest method testDelayedStopMultipleInstance.

@Test
public void testDelayedStopMultipleInstance() throws ExecutionException, InterruptedException {
    CloudContext cloudContext = mock(CloudContext.class);
    CloudCredential cloudCredential = mock(CloudCredential.class);
    CloudInstance cloudInstance1 = mock(CloudInstance.class);
    CloudInstance cloudInstance2 = mock(CloudInstance.class);
    CloudInstance cloudInstance3 = mock(CloudInstance.class);
    List<CloudInstance> cloudInstances = List.of(cloudInstance1, cloudInstance2, cloudInstance3);
    CloudConnector<Object> cloudConnector = mock(CloudConnector.class);
    when(cloudPlatformConnectors.get(any())).thenReturn(cloudConnector);
    Authenticator authenticator = mock(Authenticator.class);
    when(cloudConnector.authentication()).thenReturn(authenticator);
    AuthenticatedContext authenticatedContext = mock(AuthenticatedContext.class);
    when(authenticator.authenticate(any(), any())).thenReturn(authenticatedContext);
    InstanceConnector instanceConnector = mock(InstanceConnector.class);
    when(cloudConnector.instances()).thenReturn(instanceConnector);
    when(delayedExecutorService.runWithDelay(any(Callable.class), eq(DELAY), eq(TimeUnit.SECONDS))).thenAnswer(inv -> inv.getArgument(0, Callable.class).call());
    underTest.accept(new Event<>(new DelayedStartInstancesRequest(cloudContext, cloudCredential, List.of(), cloudInstances, DELAY)));
    ArgumentCaptor<List<CloudInstance>> instanceCaptor = ArgumentCaptor.forClass(List.class);
    verify(instanceConnector, times(3)).start(eq(authenticatedContext), eq(List.of()), instanceCaptor.capture());
    List<List<CloudInstance>> instanceCaptorAllValues = instanceCaptor.getAllValues();
    assertEquals(3, instanceCaptorAllValues.size());
    assertEquals(1, instanceCaptorAllValues.get(0).size());
    assertEquals(cloudInstance1, instanceCaptorAllValues.get(0).get(0));
    assertEquals(1, instanceCaptorAllValues.get(1).size());
    assertEquals(cloudInstance2, instanceCaptorAllValues.get(1).get(0));
    assertEquals(1, instanceCaptorAllValues.get(2).size());
    assertEquals(cloudInstance3, instanceCaptorAllValues.get(2).get(0));
    verify(delayedExecutorService, times(2)).runWithDelay(any(Callable.class), eq(DELAY), eq(TimeUnit.SECONDS));
    verify(eventBus).notify(eq(StartInstancesResult.class.getSimpleName().toUpperCase()), any(Event.class));
}
Also used : CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) InstanceConnector(com.sequenceiq.cloudbreak.cloud.InstanceConnector) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) DelayedStartInstancesRequest(com.sequenceiq.cloudbreak.cloud.event.instance.DelayedStartInstancesRequest) Callable(java.util.concurrent.Callable) StartInstancesResult(com.sequenceiq.cloudbreak.cloud.event.instance.StartInstancesResult) Event(reactor.bus.Event) List(java.util.List) Authenticator(com.sequenceiq.cloudbreak.cloud.Authenticator) Test(org.junit.jupiter.api.Test)

Example 4 with Authenticator

use of com.sequenceiq.cloudbreak.cloud.Authenticator in project cloudbreak by hortonworks.

the class DelayedStopStackHandlerTest method testDelayedStopNoInstance.

@Test
public void testDelayedStopNoInstance() {
    CloudContext cloudContext = mock(CloudContext.class);
    CloudCredential cloudCredential = mock(CloudCredential.class);
    List<CloudInstance> cloudInstances = List.of();
    CloudConnector<Object> cloudConnector = mock(CloudConnector.class);
    when(cloudPlatformConnectors.get(any())).thenReturn(cloudConnector);
    Authenticator authenticator = mock(Authenticator.class);
    when(cloudConnector.authentication()).thenReturn(authenticator);
    AuthenticatedContext authenticatedContext = mock(AuthenticatedContext.class);
    when(authenticator.authenticate(any(), any())).thenReturn(authenticatedContext);
    underTest.accept(new Event<>(new DelayedStopInstancesRequest(cloudContext, cloudCredential, List.of(), cloudInstances, DELAY)));
    verifyNoInteractions(delayedExecutorService);
    verify(cloudConnector, never()).instances();
    verify(eventBus).notify(eq(StopInstancesResult.class.getSimpleName().toUpperCase()), any(Event.class));
}
Also used : CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) StopInstancesResult(com.sequenceiq.cloudbreak.cloud.event.instance.StopInstancesResult) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) Event(reactor.bus.Event) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) Authenticator(com.sequenceiq.cloudbreak.cloud.Authenticator) DelayedStopInstancesRequest(com.sequenceiq.cloudbreak.cloud.event.instance.DelayedStopInstancesRequest) Test(org.junit.jupiter.api.Test)

Example 5 with Authenticator

use of com.sequenceiq.cloudbreak.cloud.Authenticator in project cloudbreak by hortonworks.

the class StopStartDownscaleStopInstancesHandlerTest method setUp.

@BeforeEach
public void setUp() {
    Authenticator authenticator = mock(Authenticator.class);
    AuthenticatedContext ac = mock(AuthenticatedContext.class);
    CloudPlatformVariant cloudPlatformVariant = mock(CloudPlatformVariant.class);
    reset(cloudContext);
    reset(cloudPlatformConnectors);
    reset(cloudConnector);
    lenient().when(cloudContext.getPlatformVariant()).thenReturn(cloudPlatformVariant);
    lenient().when(cloudPlatformConnectors.get(any(CloudPlatformVariant.class))).thenReturn(cloudConnector);
    lenient().when(cloudConnector.authentication()).thenReturn(authenticator);
    lenient().when(authenticator.authenticate(any(CloudContext.class), any(CloudCredential.class))).thenReturn(ac);
    lenient().when(cloudConnector.instances()).thenReturn(instanceConnector);
}
Also used : CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) Authenticator(com.sequenceiq.cloudbreak.cloud.Authenticator) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Authenticator (com.sequenceiq.cloudbreak.cloud.Authenticator)12 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)10 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)8 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)8 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)6 Test (org.junit.jupiter.api.Test)6 Event (reactor.bus.Event)6 BeforeEach (org.junit.jupiter.api.BeforeEach)5 InstanceConnector (com.sequenceiq.cloudbreak.cloud.InstanceConnector)4 List (java.util.List)4 DelayedStartInstancesRequest (com.sequenceiq.cloudbreak.cloud.event.instance.DelayedStartInstancesRequest)3 DelayedStopInstancesRequest (com.sequenceiq.cloudbreak.cloud.event.instance.DelayedStopInstancesRequest)3 StartInstancesResult (com.sequenceiq.cloudbreak.cloud.event.instance.StartInstancesResult)3 StopInstancesResult (com.sequenceiq.cloudbreak.cloud.event.instance.StopInstancesResult)3 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)2 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)2 Stack (com.sequenceiq.freeipa.entity.Stack)2 Callable (java.util.concurrent.Callable)2 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)1 MetadataCollector (com.sequenceiq.cloudbreak.cloud.MetadataCollector)1