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);
}
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);
}
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));
}
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));
}
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);
}
Aggregations