use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class DBStackToDatabaseStackConverterTest method testConversionGcpWithGcpEncryptionResourcesPresent.
@Test
public void testConversionGcpWithGcpEncryptionResourcesPresent() {
Network network = new Network();
network.setAttributes(new Json(NETWORK_ATTRIBUTES));
dbStack.setNetwork(network);
dbStack.setCloudPlatform("GCP");
dbStack.setParameters(new HashMap<>());
DatabaseServer server = new DatabaseServer();
server.setDatabaseVendor(DatabaseVendor.POSTGRES);
server.setAttributes(new Json(DATABASE_SERVER_ATTRIBUTES));
dbStack.setDatabaseServer(server);
dbStack.setTags(new Json(STACK_TAGS));
dbStack.setTemplate("template");
DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
environmentResponse.setCloudPlatform("GCP");
environmentResponse.setGcp(GcpEnvironmentParameters.builder().withResourceEncryptionParameters(GcpResourceEncryptionParameters.builder().withEncryptionKey("value").build()).build());
when(environmentService.getByCrn(anyString())).thenReturn(environmentResponse);
DatabaseStack convertedStack = underTest.convert(dbStack);
Map<String, Object> parameters = convertedStack.getDatabaseServer().getParameters();
assertThat(parameters.get("key").toString()).isEqualTo("value");
assertThat(parameters.size()).isEqualTo(3);
}
use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class DBStackToDatabaseStackConverterTest method testConversionAwsWithAwsEncryptionResourcesPresent.
@Test
public void testConversionAwsWithAwsEncryptionResourcesPresent() {
Network network = new Network();
network.setAttributes(new Json(NETWORK_ATTRIBUTES));
dbStack.setNetwork(network);
dbStack.setCloudPlatform("AWS");
dbStack.setParameters(new HashMap<>());
DatabaseServer server = new DatabaseServer();
server.setDatabaseVendor(DatabaseVendor.POSTGRES);
server.setAttributes(new Json(DATABASE_SERVER_ATTRIBUTES));
dbStack.setDatabaseServer(server);
dbStack.setTags(new Json(STACK_TAGS));
dbStack.setTemplate("template");
DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
environmentResponse.setCloudPlatform("AWS");
environmentResponse.setAws(AwsEnvironmentParameters.builder().withAwsDiskEncryptionParameters(AwsDiskEncryptionParameters.builder().withEncryptionKeyArn("value").build()).build());
when(environmentService.getByCrn(anyString())).thenReturn(environmentResponse);
DatabaseStack convertedStack = underTest.convert(dbStack);
Map<String, Object> parameters = convertedStack.getDatabaseServer().getParameters();
assertThat(parameters.get("key").toString()).isEqualTo("value");
assertThat(parameters.size()).isEqualTo(3);
}
use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method createStack.
private Stack createStack(StackType type, String subnetId, String cloudPlatform, boolean makePrivate) {
Cluster cluster = new Cluster();
cluster.setBlueprint(blueprint);
Set<InstanceGroup> instanceGroups = new HashSet<>();
InstanceGroup instanceGroup1 = new InstanceGroup();
instanceGroup1.setGroupName("master");
instanceGroup1.setAttributes(new Json(new HashMap<String, Object>()));
InstanceGroup instanceGroup2 = new InstanceGroup();
instanceGroup2.setGroupName("manager");
instanceGroup2.setAttributes(new Json(new HashMap<String, Object>()));
instanceGroups.add(instanceGroup1);
instanceGroups.add(instanceGroup2);
InstanceMetaData imd1 = new InstanceMetaData();
InstanceMetaData imd2 = new InstanceMetaData();
Set<InstanceMetaData> imdSet = Set.of(imd1, imd2);
instanceGroup1.setInstanceMetaData(imdSet);
instanceGroup2.setInstanceMetaData(imdSet);
Stack stack = new Stack();
stack.setType(type);
stack.setCluster(cluster);
stack.setInstanceGroups(instanceGroups);
stack.setCloudPlatform(cloudPlatform);
Network network = new Network();
Map<String, Object> attributes = new HashMap<>();
if (StringUtils.isNotEmpty(subnetId)) {
attributes.put("subnetId", subnetId);
}
if (AZURE.equals(cloudPlatform)) {
attributes.put("noPublicIp", makePrivate);
InstanceGroup instanceGroup3 = new InstanceGroup();
instanceGroup3.setGroupName("worker");
instanceGroups.add(instanceGroup3);
}
network.setAttributes(new Json(attributes));
stack.setNetwork(network);
return stack;
}
use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class MultiAzCalculatorServiceTest method calculateByRoundRobinTestWhenCloudInstanceAndNoSubnetIds.
@ParameterizedTest(name = "{0}")
@MethodSource("calculateByRoundRobinTestWhenCloudInstanceAndNoSubnetIdsDataProvider")
void calculateByRoundRobinTestWhenCloudInstanceAndNoSubnetIds(String testCaseName, boolean disableNetwork, boolean disableAttributes, boolean disableSubnetIdsAttribute, boolean prepopulateCloudInstanceSubnet) {
InstanceGroup instanceGroup = instanceGroup(CloudPlatform.AWS, SINGLE_INSTANCE, NO_SUBNETS);
if (disableNetwork) {
instanceGroup.setInstanceGroupNetwork(null);
} else if (disableAttributes) {
instanceGroup.getInstanceGroupNetwork().setAttributes(null);
} else if (disableSubnetIdsAttribute) {
instanceGroup.getInstanceGroupNetwork().setAttributes(new Json(Map.of()));
}
String cloudInstanceSubnetId = prepopulateCloudInstanceSubnet ? SUBNET_ID : null;
String cloudInstanceAvailabilityZone = prepopulateCloudInstanceSubnet ? AVAILABILITY_ZONE : null;
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setSubnetId(cloudInstanceSubnetId);
instanceMetaData.setAvailabilityZone(cloudInstanceAvailabilityZone);
underTest.calculateByRoundRobin(subnetAzPairs(NO_SUBNETS), instanceGroup, instanceMetaData, NetworkScaleDetails.getEmpty());
verifyCloudInstance(cloudInstanceSubnetId == null ? Set.of() : Set.of(cloudInstanceSubnetId), cloudInstanceAvailabilityZone == null ? Set.of() : Set.of(cloudInstanceAvailabilityZone), instanceMetaData);
instanceGroup.getAllInstanceMetaData().forEach(instance -> {
assertThat(instance.getSubnetId()).isNull();
assertThat(instance.getAvailabilityZone()).isNull();
});
}
use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class MultiAzCalculatorServiceTest method calculateByRoundRobinTestWhenWholeInstanceGroupAndNoSubnetIds.
@ParameterizedTest(name = "{0}")
@MethodSource("calculateByRoundRobinTestWhenWholeInstanceGroupAndNoSubnetIdsDataProvider")
void calculateByRoundRobinTestWhenWholeInstanceGroupAndNoSubnetIds(String testCaseName, boolean disableNetwork, boolean disableAttributes, boolean disableSubnetIdsAttribute) {
InstanceGroup instanceGroup = instanceGroup(CloudPlatform.AWS, SINGLE_INSTANCE, NO_SUBNETS);
if (disableNetwork) {
instanceGroup.setInstanceGroupNetwork(null);
} else if (disableAttributes) {
instanceGroup.getInstanceGroupNetwork().setAttributes(null);
} else if (disableSubnetIdsAttribute) {
instanceGroup.getInstanceGroupNetwork().setAttributes(new Json(Map.of()));
}
underTest.calculateByRoundRobin(subnetAzPairs(NO_SUBNETS), instanceGroup);
instanceGroup.getAllInstanceMetaData().forEach(instance -> {
assertThat(instance.getSubnetId()).isNull();
assertThat(instance.getAvailabilityZone()).isNull();
});
}
Aggregations