use of com.sequenceiq.cloudbreak.cloud.template.ResourceContextBuilder in project cloudbreak by hortonworks.
the class GcpResourceConnectorTest method testUpscaleWhenEverythingIsFine.
@Test
public void testUpscaleWhenEverythingIsFine() throws QuotaExceededException {
AuthenticatedContext authenticatedContext = mock(AuthenticatedContext.class);
CloudStack cloudStack = mock(CloudStack.class);
Network network = mock(Network.class);
CloudContext cloudContext = mock(CloudContext.class);
ResourceBuilderContext resourceBuilderContext = mock(ResourceBuilderContext.class);
ResourceContextBuilder resourceContextBuilder = mock(ResourceContextBuilder.class);
List<CloudResource> cloudResourceList = List.of(cloudResource("test-5", GCP_ATTACHED_DISKSET));
when(authenticatedContext.getCloudContext()).thenReturn(cloudContext);
when(cloudStack.getNetwork()).thenReturn(network);
when(cloudContext.getPlatform()).thenReturn(platform("GCP"));
when(cloudContext.getVariant()).thenReturn(GcpConstants.GCP_VARIANT);
when(contextBuilders.get(any(Platform.class))).thenReturn(resourceContextBuilder);
when(resourceContextBuilder.contextInit(any(CloudContext.class), any(AuthenticatedContext.class), any(Network.class), anyList(), anyBoolean())).thenReturn(resourceBuilderContext);
when(networkResourceService.getNetworkResources(any(Variant.class), anyList())).thenReturn(new ArrayList<>());
doNothing().when(resourceBuilderContext).addNetworkResources(anyCollection());
when(groupResourceService.getGroupResources(any(Variant.class), anyCollection())).thenReturn(List.of(cloudResource("test-1", GCP_INSTANCE)));
Group master = group("master");
master.getInstances().get(0).putParameter(CloudInstance.FQDN, "fqdn");
when(cloudStack.getGroups()).thenReturn(List.of(master));
doNothing().when(resourceBuilderContext).addComputeResources(anyLong(), anyList());
when(computeResourceService.buildResourcesForUpscale(any(ResourceBuilderContext.class), any(AuthenticatedContext.class), any(CloudStack.class), anyCollection(), any())).thenReturn(List.of());
underTest.upscale(authenticatedContext, cloudStack, cloudResourceList, new AdjustmentTypeWithThreshold(AdjustmentType.EXACT, 0L));
verify(contextBuilders, times(1)).get(any(Platform.class));
verify(networkResourceService, times(1)).getNetworkResources(any(Variant.class), anyList());
verify(groupResourceService, times(1)).getGroupResources(any(Variant.class), anyList());
verify(resourceBuilderContext, times(1)).addComputeResources(anyLong(), anyList());
verify(computeResourceService, times(1)).buildResourcesForUpscale(any(ResourceBuilderContext.class), any(AuthenticatedContext.class), any(CloudStack.class), anyCollection(), any());
}
use of com.sequenceiq.cloudbreak.cloud.template.ResourceContextBuilder in project cloudbreak by hortonworks.
the class GcpResourceConnectorTest method testLaunchLoadBalancersWhenEverythingIsFine.
@Test
public void testLaunchLoadBalancersWhenEverythingIsFine() throws Exception {
AuthenticatedContext authenticatedContext = mock(AuthenticatedContext.class);
CloudStack cloudStack = mock(CloudStack.class);
PersistenceNotifier persistenceNotifier = mock(PersistenceNotifier.class);
Network network = mock(Network.class);
CloudContext cloudContext = mock(CloudContext.class);
ResourceBuilderContext resourceBuilderContext = mock(ResourceBuilderContext.class);
ResourceContextBuilder resourceContextBuilder = mock(ResourceContextBuilder.class);
when(authenticatedContext.getCloudContext()).thenReturn(cloudContext);
when(cloudStack.getNetwork()).thenReturn(network);
when(cloudContext.getPlatform()).thenReturn(platform("GCP"));
when(contextBuilders.get(any(Platform.class))).thenReturn(resourceContextBuilder);
when(resourceContextBuilder.contextInit(any(CloudContext.class), any(AuthenticatedContext.class), any(Network.class), anyList(), anyBoolean())).thenReturn(resourceBuilderContext);
when(loadBalancerResourceService.buildResources(any(ResourceBuilderContext.class), any(AuthenticatedContext.class), any(CloudStack.class))).thenReturn(List.of());
underTest.launchLoadBalancers(authenticatedContext, cloudStack, persistenceNotifier);
verify(contextBuilders, times(1)).get(any(Platform.class));
verify(loadBalancerResourceService, times(1)).buildResources(any(ResourceBuilderContext.class), any(AuthenticatedContext.class), any(CloudStack.class));
}
Aggregations