use of com.sequenceiq.common.api.adjustment.AdjustmentTypeWithThreshold in project cloudbreak by hortonworks.
the class AzureResourceConnectorTest method testWhenTemplateDeploymentDoesNotExistThenComputeResourceServiceBuildsTheResources.
@Test
public void testWhenTemplateDeploymentDoesNotExistThenComputeResourceServiceBuildsTheResources() {
when(client.templateDeploymentExists(RESOURCE_GROUP_NAME, STACK_NAME)).thenReturn(false);
when(client.createTemplateDeployment(any(), any(), any(), any())).thenReturn(deployment);
when(azureImageFormatValidator.isMarketplaceImageFormat(any())).thenReturn(false);
AdjustmentTypeWithThreshold adjustmentTypeWithThreshold = new AdjustmentTypeWithThreshold(ADJUSTMENT_TYPE, THRESHOLD);
underTest.launch(ac, stack, notifier, adjustmentTypeWithThreshold);
verify(azureComputeResourceService, times(1)).buildComputeResourcesForLaunch(eq(ac), eq(stack), eq(adjustmentTypeWithThreshold), eq(instances), any());
verify(azureCloudResourceService, times(1)).getInstanceCloudResources(STACK_NAME, instances, groups, RESOURCE_GROUP_NAME);
verify(azureUtils, times(1)).getCustomNetworkId(network);
verify(azureUtils, times(1)).getCustomSubnetIds(network);
verify(azureMarketplaceImageProviderService, times(0)).get(imageModel);
}
use of com.sequenceiq.common.api.adjustment.AdjustmentTypeWithThreshold in project cloudbreak by hortonworks.
the class AzureResourceConnectorTest method testWhenTemplateDeploymentExistsAndInProgressThenComputeResourceServiceBuildsTheResources.
@Test
public void testWhenTemplateDeploymentExistsAndInProgressThenComputeResourceServiceBuildsTheResources() {
when(client.templateDeploymentExists(RESOURCE_GROUP_NAME, STACK_NAME)).thenReturn(true);
when(client.getTemplateDeployment(RESOURCE_GROUP_NAME, STACK_NAME)).thenReturn(deployment);
when(client.getTemplateDeploymentStatus(RESOURCE_GROUP_NAME, STACK_NAME)).thenReturn(ResourceStatus.IN_PROGRESS);
when(azureImageFormatValidator.isMarketplaceImageFormat(imageModel)).thenReturn(false);
AdjustmentTypeWithThreshold adjustmentTypeWithThreshold = new AdjustmentTypeWithThreshold(ADJUSTMENT_TYPE, THRESHOLD);
underTest.launch(ac, stack, notifier, adjustmentTypeWithThreshold);
verify(azureComputeResourceService, times(1)).buildComputeResourcesForLaunch(any(AuthenticatedContext.class), any(CloudStack.class), eq(adjustmentTypeWithThreshold), any(), any());
verify(azureCloudResourceService, times(1)).getInstanceCloudResources(STACK_NAME, instances, groups, RESOURCE_GROUP_NAME);
verify(azureUtils, times(1)).getCustomNetworkId(network);
verify(client, never()).createTemplateDeployment(any(), any(), any(), any());
verify(client, times(2)).getTemplateDeployment(any(), any());
verify(azureMarketplaceImageProviderService, times(0)).get(imageModel);
}
use of com.sequenceiq.common.api.adjustment.AdjustmentTypeWithThreshold in project cloudbreak by hortonworks.
the class AzureResourceConnectorTest method testWhenMarketplaceImageThenTemplateBuilderUsesMarketplaceImage.
@Test
public void testWhenMarketplaceImageThenTemplateBuilderUsesMarketplaceImage() {
when(client.templateDeploymentExists(RESOURCE_GROUP_NAME, STACK_NAME)).thenReturn(false);
when(client.createTemplateDeployment(any(), any(), any(), any())).thenReturn(deployment);
when(azureImageFormatValidator.isMarketplaceImageFormat(any())).thenReturn(true);
AdjustmentTypeWithThreshold adjustmentTypeWithThreshold = new AdjustmentTypeWithThreshold(ADJUSTMENT_TYPE, THRESHOLD);
underTest.launch(ac, stack, notifier, adjustmentTypeWithThreshold);
verify(azureMarketplaceImageProviderService, times(1)).get(imageModel);
}
use of com.sequenceiq.common.api.adjustment.AdjustmentTypeWithThreshold in project cloudbreak by hortonworks.
the class MockResourceConnector method upscale.
@Override
public List<CloudResourceStatus> upscale(AuthenticatedContext authenticatedContext, CloudStack stack, List<CloudResource> resources, AdjustmentTypeWithThreshold adjustmentTypeWithThreshold) {
CloudContext cloudContext = authenticatedContext.getCloudContext();
List<Group> scaledGroups = cloudResourceHelper.getScaledGroups(stack);
List<Group> groups = scaledGroups.stream().map(g -> {
List<CloudInstance> newInstances = g.getInstances().stream().filter(i -> i.getTemplate().getStatus() == InstanceStatus.CREATE_REQUESTED).collect(Collectors.toList());
return new Group(g.getName(), g.getType(), newInstances, g.getSecurity(), g.getReferenceInstanceConfiguration(), g.getInstanceAuthentication(), g.getLoginUserName(), g.getPublicKey(), g.getRootVolumeSize(), g.getIdentity(), g.getNetwork(), g.getTags());
}).collect(Collectors.toList());
List<CloudVmInstanceStatus> resized = resize(authenticatedContext, groups);
return generateResources(cloudContext, resized);
}
use of com.sequenceiq.common.api.adjustment.AdjustmentTypeWithThreshold in project cloudbreak by hortonworks.
the class YarnResourceConnectorTest method testLaunchWithStackDefaultParameters.
@Test
public void testLaunchWithStackDefaultParameters() throws Exception {
ArgumentCaptor<CreateApplicationRequest> createRequestCaptor = ArgumentCaptor.forClass(CreateApplicationRequest.class);
ArgumentCaptor<ApplicationDetailRequest> requestCaptor = ArgumentCaptor.forClass(ApplicationDetailRequest.class);
setUpHappyPath(createRequestCaptor, requestCaptor);
when(applicationNameUtilMock.createApplicationName(authenticatedContextMock)).thenReturn("name-1-horton");
when(yarnApplicationCreationService.initializeRequest(any(), any())).thenReturn(createInitialApplicationRequest("name-1-horton"));
underTest.launch(authenticatedContextMock, stackMock, persistenceNotifierMock, new AdjustmentTypeWithThreshold(AdjustmentType.EXACT, Long.MAX_VALUE));
verify(yarnApplicationCreationService).createApplication(any(), createRequestCaptor.capture());
CreateApplicationRequest capturedCreateRequest = createRequestCaptor.getValue();
assertEquals("name-1-horton", capturedCreateRequest.getName());
}
Aggregations