use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class PackageVersionCheckerTest method compareImageAndInstancesMandatoryPackageVersionMissingPackageInImage.
@Test
public void compareImageAndInstancesMandatoryPackageVersionMissingPackageInImage() throws JsonProcessingException {
String packageName = "package";
Map<String, String> packageVersions = Collections.singletonMap(packageName, "1");
when(statedImage.getImage()).thenReturn(image);
when(image.isPrewarmed()).thenReturn(true);
when(image.getPackageVersions()).thenReturn(Collections.emptyMap());
Package aPackage = new Package();
aPackage.setName(packageName);
aPackage.setPrewarmed(true);
when(instanceMetadataUpdater.getPackages()).thenReturn(Collections.singletonList(aPackage));
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setImage(new Json(new com.sequenceiq.cloudbreak.cloud.model.Image("image", Collections.emptyMap(), "os", "ostype", "catalogn", "catalogu", "id", packageVersions)));
Set<InstanceMetaData> instanceMetaDataSet = Collections.singleton(instanceMetaData);
CheckResult result = underTest.compareImageAndInstancesMandatoryPackageVersion(statedImage, instanceMetaDataSet);
assertEquals(EventStatus.FAILED, result.getStatus());
}
use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class GrainPropertiesServiceTest method testAllInOne.
@Test
public void testAllInOne() {
when(componentLocator.getComponentLocationByHostname(eq(cluster), argThat(namenodeMatcher))).thenReturn(Map.of("NAMENODE", List.of("NMHOST")));
when(componentLocator.getComponentLocationByHostname(eq(cluster), argThat(knoxGatewayMatcher))).thenReturn(Map.of("KNOX_GATEWAY", List.of("KWGHOST")));
GatewayConfig gwconfig = mock(GatewayConfig.class);
when(gwconfig.getPublicAddress()).thenReturn("GWPUBADDR");
when(gwconfig.getHostname()).thenReturn("GWHOSTNAME");
Node node1 = new Node("", "", "", "", "node1fqdn", "");
InstanceMetaData im1 = new InstanceMetaData();
im1.setDiscoveryFQDN(node1.getHostname());
InstanceGroup logIg = new InstanceGroup();
logIg.setAttributes(new Json("{}"));
logIg.setCloudIdentityType(CloudIdentityType.LOG);
im1.setInstanceGroup(logIg);
when(instanceMetaDataService.getAllInstanceMetadataByStackId(1L)).thenReturn(Set.of(im1));
List<GrainProperties> result = underTest.createGrainProperties(List.of(gwconfig), cluster, Set.of(node1));
assertThat(result, hasItem(allOf(hasProperty("properties", allOf(hasEntry("GWHOSTNAME", Map.of("gateway-address", "GWPUBADDR")))))));
assertThat(result, hasItem(allOf(hasProperty("properties", allOf(hasEntry("NMHOST", Map.of("roles", "namenode")))))));
assertThat(result, hasItem(allOf(hasProperty("properties", allOf(hasEntry("KWGHOST", Map.of("roles", "knox")))))));
assertThat(result, hasItem(allOf(hasProperty("properties", allOf(hasEntry("node1fqdn", Map.of("roles", "LOG_CLOUD_IDENTITY_ROLE")))))));
}
use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class ClouderaManagerClusterCreationSetupServiceTest method testPrewarmedClouderaManagerClusterComponentsWhenTheStackTypeIsDataLake.
@Test
public void testPrewarmedClouderaManagerClusterComponentsWhenTheStackTypeIsDataLake() throws IOException, CloudbreakImageCatalogException {
Component cmRepoComponent = spy(new Component(ComponentType.CM_REPO_DETAILS, ComponentType.CM_REPO_DETAILS.name(), new Json(getClouderaManagerRepo(false)), stack));
Component productComponent = spy(new Component(ComponentType.CDH_PRODUCT_DETAILS, ComponentType.CDH_PRODUCT_DETAILS.name(), new Json(getClouderaManagerProductRepo()), stack));
List<Component> productComponentList = List.of(productComponent);
ClouderaManagerProduct cdhProduct = clouderaManagerProduct("CDH", "1.5.0");
stack.setType(StackType.DATALAKE);
when(blueprintUtils.getCDHStackVersion(any())).thenReturn(SOME_CDH_VERSION);
when(clouderaManagerProductsProvider.getCdhProducts(anySet())).thenReturn(cdhProduct);
List<ClusterComponent> clusterComponents = underTest.prepareClouderaManagerCluster(clusterRequest, cluster, Optional.of(cmRepoComponent), productComponentList, Optional.of(imageComponent));
assertVersionsMatch(clusterComponents, CM_VERSION, SOME_CDH_VERSION);
verify(clouderaManagerProductsProvider).getCdhProducts(anySet());
verifyNoInteractions(parcelFilterService);
}
use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class ClouderaManagerClusterCreationSetupServiceTest method testPrewarmedClouderaManagerClusterComponents.
@Test
public void testPrewarmedClouderaManagerClusterComponents() throws IOException, CloudbreakImageCatalogException {
Component cmRepoComponent = spy(new Component(ComponentType.CM_REPO_DETAILS, ComponentType.CM_REPO_DETAILS.name(), new Json(getClouderaManagerRepo(false)), stack));
Component productComponent = spy(new Component(ComponentType.CDH_PRODUCT_DETAILS, ComponentType.CDH_PRODUCT_DETAILS.name(), new Json(getClouderaManagerProductRepo()), stack));
List<Component> productComponentList = List.of(productComponent);
Set<ClouderaManagerProduct> clouderaManagerProductSet = new HashSet<>();
clouderaManagerProductSet.add(clouderaManagerProduct("CDH", "1.5.0"));
when(blueprintUtils.getCDHStackVersion(any())).thenReturn(SOME_CDH_VERSION);
when(parcelFilterService.filterParcelsByBlueprint(eq(STACK_ID), anySet(), any(Blueprint.class))).thenReturn(clouderaManagerProductSet);
List<ClusterComponent> clusterComponents = underTest.prepareClouderaManagerCluster(clusterRequest, cluster, Optional.of(cmRepoComponent), productComponentList, Optional.of(imageComponent));
assertVersionsMatch(clusterComponents, CM_VERSION, SOME_CDH_VERSION);
verify(parcelFilterService, times(1)).filterParcelsByBlueprint(eq(STACK_ID), anySet(), any(Blueprint.class));
}
use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class ClusterCreationSetupServiceTest method init.
@Before
public void init() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException, IOException {
MockitoAnnotations.initMocks(this);
workspace = new Workspace();
clusterRequest = new ClusterV4Request();
stack = new Stack();
stack.setId(1L);
stack.setWorkspace(workspace);
stack.setEnvironmentCrn("env");
stack.setName("name");
blueprint = new Blueprint();
blueprint.setBlueprintText("{}");
user = new User();
Map<InstanceGroupType, String> userData = new HashMap<>();
userData.put(InstanceGroupType.CORE, "userdata");
Image image = new Image("imagename", userData, "centos7", REDHAT_7, "url", "imgcatname", "id", Collections.emptyMap());
Component imageComponent = new Component(ComponentType.IMAGE, ComponentType.IMAGE.name(), new Json(image), stack);
cluster = new Cluster();
stack.setCluster(cluster);
when(clusterDecorator.decorate(any(), any(), any(), any(), any(), any())).thenReturn(cluster);
when(componentConfigProviderService.getAllComponentsByStackIdAndType(any(), any())).thenReturn(Sets.newHashSet(imageComponent));
when(blueprintUtils.getBlueprintStackVersion(any())).thenReturn(HDP_VERSION);
when(blueprintUtils.getBlueprintStackName(any())).thenReturn("HDP");
DefaultCDHInfo defaultCDHInfo = getDefaultCDHInfo(CDH_VERSION);
when(imageBasedDefaultCDHEntries.getEntries(workspace.getId(), imageCatalogPlatform(PLATFORM), IMAGE_CATALOG_NAME)).thenReturn(Collections.singletonMap(CDH_VERSION, new ImageBasedDefaultCDHInfo(defaultCDHInfo, Mockito.mock(com.sequenceiq.cloudbreak.cloud.model.catalog.Image.class))));
when(componentConfigProviderService.getImage(anyLong())).thenReturn(image);
StackMatrixV4Response stackMatrixV4Response = new StackMatrixV4Response();
stackMatrixV4Response.setCdh(Collections.singletonMap(CDH_VERSION, null));
when(stackMatrixService.getStackMatrix(workspace.getId(), imageCatalogPlatform(PLATFORM), IMAGE_CATALOG_NAME)).thenReturn(stackMatrixV4Response);
when(clouderaManagerClusterCreationSetupService.prepareClouderaManagerCluster(any(), any(), any(), any(), any())).thenReturn(new ArrayList<>());
}
Aggregations