use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.
the class ImageFilterParamsFactoryTest method testCreateShouldReturnsANewImageFilterParamsInstanceWhenTheStackTypeIsDataLake.
@Test
public void testCreateShouldReturnsANewImageFilterParamsInstanceWhenTheStackTypeIsDataLake() {
Image image = mock(Image.class);
Stack stack = createStack(StackType.DATALAKE);
Set<ClusterComponent> clusterComponents = createCdhClusterComponent();
String cdhName = com.sequenceiq.cloudbreak.cloud.model.component.StackType.CDH.name();
String cdhVersion = "7.2.0";
when(platformStringTransformer.getPlatformStringForImageCatalog(anyString(), anyString())).thenReturn(imageCatalogPlatform(CLOUD_PLATFORM));
when(parcelService.getParcelComponentsByBlueprint(stack)).thenReturn(clusterComponents);
when(clouderaManagerProductsProvider.findCdhProduct(clusterComponents)).thenReturn(Optional.of(createCMProduct(cdhName, cdhVersion)));
ImageFilterParams actual = underTest.create(image, true, stack, new InternalUpgradeSettings(false, true, true));
assertEquals(image, actual.getCurrentImage());
assertTrue(actual.isLockComponents());
assertEquals(cdhVersion, actual.getStackRelatedParcels().get(cdhName));
assertEquals(StackType.DATALAKE, actual.getStackType());
assertEquals(blueprint, actual.getBlueprint());
assertEquals(STACK_ID, actual.getStackId());
assertEquals(CLOUD_PLATFORM, actual.getCloudPlatform().nameToUpperCase());
verify(parcelService).getParcelComponentsByBlueprint(stack);
verify(clouderaManagerProductsProvider).findCdhProduct(clusterComponents);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.
the class ImageFilterParamsFactoryTest method testCreateShouldReturnsANewImageFilterParamsInstanceWhenTheStackTypeIsDataHub.
@Test
public void testCreateShouldReturnsANewImageFilterParamsInstanceWhenTheStackTypeIsDataHub() {
Image image = mock(Image.class);
Stack stack = createStack(StackType.WORKLOAD);
Set<ClusterComponent> cdhClusterComponent = createCdhClusterComponent();
String sparkName = "Spark";
String sparkVersion = "123";
ClouderaManagerProduct spark = createCMProduct(sparkName, sparkVersion);
String nifiName = "Nifi";
String nifiVersion = "456";
ClouderaManagerProduct nifi = createCMProduct(nifiName, nifiVersion);
when(platformStringTransformer.getPlatformStringForImageCatalog(anyString(), anyString())).thenReturn(imageCatalogPlatform(CLOUD_PLATFORM));
when(parcelService.getParcelComponentsByBlueprint(stack)).thenReturn(cdhClusterComponent);
when(clouderaManagerProductsProvider.getProducts(cdhClusterComponent)).thenReturn(Set.of(spark, nifi));
ImageFilterParams actual = underTest.create(image, true, stack, new InternalUpgradeSettings(true, true, true));
assertEquals(image, actual.getCurrentImage());
assertTrue(actual.isLockComponents());
assertTrue(actual.isSkipValidations());
assertEquals(sparkVersion, actual.getStackRelatedParcels().get(sparkName));
assertEquals(nifiVersion, actual.getStackRelatedParcels().get(nifiName));
assertEquals(StackType.WORKLOAD, actual.getStackType());
assertEquals(blueprint, actual.getBlueprint());
assertEquals(STACK_ID, actual.getStackId());
assertEquals(CLOUD_PLATFORM, actual.getCloudPlatform().nameToUpperCase());
verify(parcelService).getParcelComponentsByBlueprint(stack);
verify(clouderaManagerProductsProvider).getProducts(cdhClusterComponent);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.
the class ImageFilterParamsFactoryTest method testCreateShouldThrowExceptionThenThereIsNoCdhComponentAvailable.
@Test(expected = NotFoundException.class)
public void testCreateShouldThrowExceptionThenThereIsNoCdhComponentAvailable() {
Image image = mock(Image.class);
Stack stack = createStack(StackType.DATALAKE);
ClusterComponent clusterComponent = new ClusterComponent();
clusterComponent.setName("CM");
when(parcelService.getParcelComponentsByBlueprint(stack)).thenReturn(Collections.singleton(clusterComponent));
underTest.create(image, true, stack, new InternalUpgradeSettings(false, true, true));
verify(parcelService).getParcelComponentsByBlueprint(stack);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.
the class UpgradePermissionProviderTest method testPermitStackUpgradeShouldReturnFalseWhenTheUpgradeNotPermittedByTheUpgradeMatrix.
@Test
public void testPermitStackUpgradeShouldReturnFalseWhenTheUpgradeNotPermittedByTheUpgradeMatrix() {
String currentVersion = "7.2.1";
String targetVersion = "7.2.2";
Image currentImage = createImage(currentVersion, "2002");
Image candidateImage = createImage(targetVersion, "2001");
ImageFilterParams imageFilterParams = new ImageFilterParams(currentImage, true, Map.of(), DATALAKE_STACK_TYPE, null, STACK_ID, new InternalUpgradeSettings(false, true, true), imageCatalogPlatform(CLOUD_PLATFORM));
when(componentVersionComparator.permitCmAndStackUpgradeByComponentVersion(currentVersion, targetVersion)).thenReturn(true);
when(upgradeMatrixService.permitByUpgradeMatrix(currentVersion, targetVersion)).thenReturn(false);
when(supportedRuntimes.isSupported("7.2.2")).thenReturn(true);
boolean actual = underTest.permitStackUpgrade(imageFilterParams, candidateImage);
assertFalse(actual);
verify(componentVersionComparator).permitCmAndStackUpgradeByComponentVersion(currentVersion, targetVersion);
verify(upgradeMatrixService).permitByUpgradeMatrix(currentVersion, targetVersion);
verifyNoInteractions(componentBuildNumberComparator);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.
the class UpgradePermissionProviderTest method testPermitStackUpgradeShouldReturnTrueWhenTheCandidateCmVersionIsGreater.
@Test
public void testPermitStackUpgradeShouldReturnTrueWhenTheCandidateCmVersionIsGreater() {
String currentVersion = "7.2.1";
String targetVersion = "7.2.2";
Image currentImage = createImage(currentVersion, "2002");
Image candidateImage = createImage(targetVersion, "2001");
ImageFilterParams imageFilterParams = new ImageFilterParams(currentImage, true, Map.of(), DATALAKE_STACK_TYPE, null, STACK_ID, new InternalUpgradeSettings(false, true, true), imageCatalogPlatform(CLOUD_PLATFORM));
when(componentVersionComparator.permitCmAndStackUpgradeByComponentVersion(currentVersion, targetVersion)).thenReturn(true);
when(upgradeMatrixService.permitByUpgradeMatrix(currentVersion, targetVersion)).thenReturn(true);
when(supportedRuntimes.isSupported("7.2.2")).thenReturn(true);
boolean actual = underTest.permitStackUpgrade(imageFilterParams, candidateImage);
assertTrue(actual);
verify(componentVersionComparator).permitCmAndStackUpgradeByComponentVersion(currentVersion, targetVersion);
verify(upgradeMatrixService).permitByUpgradeMatrix(currentVersion, targetVersion);
verifyNoInteractions(componentBuildNumberComparator);
}
Aggregations