use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class InstanceMetadataUpdaterTest method createInstanceGroup.
private InstanceGroup createInstanceGroup(String instanceId, InstanceGroupType instanceGroupType) throws JsonProcessingException {
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setInstanceGroupType(instanceGroupType);
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setInstanceStatus(InstanceStatus.SERVICES_RUNNING);
instanceMetaData.setInstanceMetadataType(InstanceMetadataType.GATEWAY_PRIMARY);
Image image = new Image("imagename", null, "os", "ostype", "catalogurl", "catalogname", "iamgeid", packageMap());
instanceMetaData.setImage(new Json(image));
instanceMetaData.setInstanceId(instanceId);
instanceMetaData.setDiscoveryFQDN(instanceId);
instanceGroup.setInstanceMetaData(Collections.singleton(instanceMetaData));
return instanceGroup;
}
use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class CurrentImageUsageConditionTest method testFilterCurrentImageShouldReturnFalseWhenOneOfTheImageJsonIsNull.
@Test
public void testFilterCurrentImageShouldReturnFalseWhenOneOfTheImageJsonIsNull() {
InstanceMetaData nullImageInstanceMetadata = new InstanceMetaData();
nullImageInstanceMetadata.setImage(new Json(null));
Set<InstanceMetaData> instanceMetaData = Set.of(createInstanceMetaData(NEW_IMAGE), nullImageInstanceMetadata);
when(instanceMetaDataService.getNotDeletedAndNotZombieInstanceMetadataByStackId(STACK_ID)).thenReturn(instanceMetaData);
assertFalse(underTest.currentImageUsedOnInstances(STACK_ID, NEW_IMAGE));
verify(instanceMetaDataService).getNotDeletedAndNotZombieInstanceMetadataByStackId(STACK_ID);
}
use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class CurrentImageUsageConditionTest method createInstanceMetaData.
private InstanceMetaData createInstanceMetaData(String imageId) {
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setImage(new Json(createImage(imageId)));
return instanceMetaData;
}
use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class InstanceMetadataServiceComponentTest method saveInstanceAndGetUpdatedStack.
@Test
public void saveInstanceAndGetUpdatedStack() {
DetailedEnvironmentResponse detailedEnvResponse = DetailedEnvironmentResponse.builder().withCrn(ENV_CRN).withNetwork(EnvironmentNetworkResponse.builder().withSubnetMetas(Map.of("sub1", cloudSubnet("az", "sub1"), "sub2", cloudSubnet("az", "sub2"), "sub3", cloudSubnet("az", "sub3"), "sub4", cloudSubnet("az1", "sub4"))).build()).build();
Stack stack = new Stack();
stack.setEnvironmentCrn(ENV_CRN);
InstanceGroup workerInstanceGroup = new InstanceGroup();
workerInstanceGroup.setGroupName("worker");
InstanceGroupNetwork instanceGroupNetwork = new InstanceGroupNetwork();
instanceGroupNetwork.setCloudPlatform("AWS");
instanceGroupNetwork.setAttributes(new Json(Map.of(SUBNET_IDS, List.of("sub1", "sub2", "sub3", "sub4"))));
workerInstanceGroup.setInstanceGroupNetwork(instanceGroupNetwork);
stack.setInstanceGroups(Set.of(workerInstanceGroup));
when(cachedEnvironmentClientService.getByCrn(ENV_CRN)).thenReturn(detailedEnvResponse);
FreeIpa freeIpa = new FreeIpa();
freeIpa.setHostname("hostname");
freeIpa.setDomain("domain");
when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
instanceMetaDataService.saveInstanceAndGetUpdatedStack(stack, cloudInstances(42));
Map<String, List<InstanceMetaData>> groupBySub = workerInstanceGroup.getInstanceMetaDataSet().stream().collect(Collectors.groupingBy(InstanceMetaData::getSubnetId, Collectors.mapping(Function.identity(), Collectors.toList())));
Map<String, List<InstanceMetaData>> groupByAz = workerInstanceGroup.getInstanceMetaDataSet().stream().collect(Collectors.groupingBy(InstanceMetaData::getAvailabilityZone, Collectors.mapping(Function.identity(), Collectors.toList())));
Assertions.assertEquals(2, groupByAz.size());
Assertions.assertEquals(21, groupByAz.get("az").size());
Assertions.assertEquals(21, groupByAz.get("az1").size());
Assertions.assertEquals(4, groupBySub.size());
Assertions.assertEquals(7, groupBySub.get("sub1").size());
Assertions.assertEquals(7, groupBySub.get("sub2").size());
Assertions.assertEquals(7, groupBySub.get("sub3").size());
Assertions.assertEquals(21, groupBySub.get("sub4").size());
}
use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class DefaultInstanceGroupProviderTest method createDefaultTemplateTestVolumeEncryptionAddedWhenAzureAndNoDESAndEncryptionAtHostEnabled.
@Test
void createDefaultTemplateTestVolumeEncryptionAddedWhenAzureAndNoDESAndEncryptionAtHostEnabled() {
when(entitlementService.isAzureEncryptionAtHostEnabled(ACCOUNT_ID)).thenReturn(Boolean.TRUE);
Template result = underTest.createDefaultTemplate(CloudPlatform.AZURE, ACCOUNT_ID, null, null, null);
assertThat(result).isNotNull();
Json attributes = result.getAttributes();
assertThat(attributes).isNotNull();
assertThat(attributes.<Object>getValue(AzureInstanceTemplate.ENCRYPTION_AT_HOST_ENABLED)).isEqualTo(Boolean.TRUE);
}
Aggregations