use of com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair in project cloudbreak by hortonworks.
the class AwsLoadBalancerCommonServiceTest method createCloudLoadBalancerWithEndpointGateay.
private CloudLoadBalancer createCloudLoadBalancerWithEndpointGateay(LoadBalancerType type, List<String> instanceGroupNetworkSubnetIds, List<String> endpointGatewaySubnetIds) {
Group group = new Group(INSTANCE_NAME, GATEWAY, List.of(), null, null, null, null, null, null, 100, null, createGroupNetwork(instanceGroupNetworkSubnetIds, endpointGatewaySubnetIds), emptyMap());
CloudLoadBalancer cloudLoadBalancer = new CloudLoadBalancer(type);
cloudLoadBalancer.addPortToTargetGroupMapping(new TargetGroupPortPair(PORT, PORT), Set.of(group));
return cloudLoadBalancer;
}
use of com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair in project cloudbreak by hortonworks.
the class AzureLoadBalancerModelBuilderTest method createCloudLoadBalancer.
private CloudLoadBalancer createCloudLoadBalancer(LoadBalancerSku sku, LoadBalancerType type) {
Group targetGroup = new Group(INSTANCE_GROUP_NAME, InstanceGroupType.GATEWAY, List.of(new CloudInstance(INSTANCE_NAME, null, null, "subnet-1", "az1")), null, null, null, null, null, 64, null, createGroupNetwork(), emptyMap());
CloudLoadBalancer cloudLoadBalancer = new CloudLoadBalancer(type, sku);
cloudLoadBalancer.addPortToTargetGroupMapping(new TargetGroupPortPair(443, 443), Set.of(targetGroup));
return cloudLoadBalancer;
}
use of com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair in project cloudbreak by hortonworks.
the class AzureTemplateBuilderTest method buildWithGatewayInstanceGroupTypeAndMultipleLoadBalancers.
@ParameterizedTest(name = "buildWithGatewayInstanceGroupTypeAndMultipleLoadBalancers {0}")
@MethodSource("templatesPathDataProvider")
public void buildWithGatewayInstanceGroupTypeAndMultipleLoadBalancers(String templatePath) {
ReflectionTestUtils.setField(azureTemplateBuilder, FIELD_ARM_TEMPLATE_PATH, templatePath);
// GIVEN
assumeTrue(isTemplateVersionGreaterOrEqualThan(templatePath, "2.7.3.0"));
Network network = new Network(new Subnet(SUBNET_CIDR));
Map<String, String> parameters = new HashMap<>();
parameters.put("persistentStorage", "persistentStorageTest");
parameters.put("attachedStorageOption", "attachedStorageOptionTest");
InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
groups.add(new Group("gateway-group", InstanceGroupType.GATEWAY, Collections.singletonList(instance), security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey(), ROOT_VOLUME_SIZE, Optional.empty(), createGroupNetwork(), emptyMap()));
List<CloudLoadBalancer> loadBalancers = new ArrayList<>();
CloudLoadBalancer publicLb = new CloudLoadBalancer(LoadBalancerType.PUBLIC);
publicLb.addPortToTargetGroupMapping(new TargetGroupPortPair(443, 8443), new HashSet<>(groups));
loadBalancers.add(publicLb);
CloudLoadBalancer privateLb = new CloudLoadBalancer(LoadBalancerType.PRIVATE);
privateLb.addPortToTargetGroupMapping(new TargetGroupPortPair(443, 8443), new HashSet<>(groups));
loadBalancers.add(privateLb);
cloudStack = new CloudStack(groups, network, image, parameters, tags, azureTemplateBuilder.getTemplateString(), instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey(), null, loadBalancers);
azureStackView = new AzureStackView("mystack", 3, groups, azureStorageView, azureSubnetStrategy, Collections.emptyMap());
// WHEN
when(azureAcceleratedNetworkValidator.validate(any())).thenReturn(ACCELERATED_NETWORK_SUPPORT);
when(azureStorage.getImageStorageName(any(AzureCredentialView.class), any(CloudContext.class), any(CloudStack.class))).thenReturn("test");
when(azureStorage.getDiskContainerName(any(CloudContext.class))).thenReturn("testStorageContainer");
String templateString = azureTemplateBuilder.build(stackName, CUSTOM_IMAGE_NAME, azureCredentialView, azureStackView, cloudContext, cloudStack, AzureInstanceTemplateOperation.PROVISION, null);
// THEN
gson.fromJson(templateString, Map.class);
assertTrue(templateString.contains("\"type\": \"Microsoft.Network/loadBalancers\","));
assertTrue(templateString.contains("\"frontendPort\": 443,"));
assertTrue(templateString.contains("\"backendPort\": 443,"));
assertEquals(2, StringUtils.countMatches(templateString, "\"name\": \"port-443-rule\","));
assertTrue(templateString.contains("\"name\": \"port-8443-probe\","));
assertTrue(templateString.contains("\"type\": \"Microsoft.Network/publicIPAddresses\","));
assertTrue(templateString.contains("\"name\": \"" + LoadBalancerSku.getDefault().getTemplateName() + "\""));
assertEquals(2, StringUtils.countMatches(templateString, "\"[resourceId('Microsoft.Network/loadBalancers'"));
assertEquals(2, StringUtils.countMatches(templateString, "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', 'LoadBalancertestStackPUBLIC', 'gateway-group-pool')]"));
assertEquals(2, StringUtils.countMatches(templateString, "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', 'LoadBalancertestStackPRIVATE', 'gateway-group-pool')]"));
assertEquals(2, StringUtils.countMatches(templateString, "\"type\": \"Microsoft.Network/loadBalancers\","));
assertEquals(1, StringUtils.countMatches(templateString, "\"id\": \"[resourceId('Microsoft.Network/publicIPAddresses', 'LoadBalancertestStackPUBLIC-publicIp')]\""));
assertFalse(StringUtils.contains(templateString, "\"name\": \"group-gateway-group-outbound-rule\","));
}
use of com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair in project cloudbreak by hortonworks.
the class AzureTemplateBuilderTest method buildWithGatewayInstanceGroupTypeAndOutboundLoadBalancer.
@ParameterizedTest(name = "buildWithGatewayInstanceGroupTypeAndOutboundLoadBalancer {0}")
@MethodSource("templatesPathDataProvider")
public void buildWithGatewayInstanceGroupTypeAndOutboundLoadBalancer(String templatePath) {
assumeTrue(isTemplateVersionGreaterOrEqualThan(templatePath, "2.7.3.0"));
// GIVEN
ReflectionTestUtils.setField(azureTemplateBuilder, FIELD_ARM_TEMPLATE_PATH, templatePath);
Network network = new Network(new Subnet(SUBNET_CIDR));
Map<String, String> parameters = new HashMap<>();
parameters.put("persistentStorage", "persistentStorageTest");
parameters.put("attachedStorageOption", "attachedStorageOptionTest");
InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
groups.add(new Group("gateway-group", InstanceGroupType.GATEWAY, Collections.singletonList(instance), security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey(), ROOT_VOLUME_SIZE, Optional.empty(), createGroupNetwork(), emptyMap()));
List<CloudLoadBalancer> loadBalancers = new ArrayList<>();
CloudLoadBalancer privateLb = new CloudLoadBalancer(LoadBalancerType.PRIVATE);
privateLb.addPortToTargetGroupMapping(new TargetGroupPortPair(443, 8443), new HashSet<>(groups));
loadBalancers.add(privateLb);
CloudLoadBalancer outboundLb = new CloudLoadBalancer(LoadBalancerType.OUTBOUND);
outboundLb.addPortToTargetGroupMapping(new TargetGroupPortPair(443, 8443), new HashSet<>(groups));
loadBalancers.add(outboundLb);
cloudStack = new CloudStack(groups, network, image, parameters, tags, azureTemplateBuilder.getTemplateString(), instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey(), null, loadBalancers);
azureStackView = new AzureStackView("mystack", 3, groups, azureStorageView, azureSubnetStrategy, Collections.emptyMap());
// WHEN
when(azureAcceleratedNetworkValidator.validate(any())).thenReturn(ACCELERATED_NETWORK_SUPPORT);
when(azureStorage.getImageStorageName(any(AzureCredentialView.class), any(CloudContext.class), any(CloudStack.class))).thenReturn("test");
when(azureStorage.getDiskContainerName(any(CloudContext.class))).thenReturn("testStorageContainer");
String templateString = azureTemplateBuilder.build(stackName, CUSTOM_IMAGE_NAME, azureCredentialView, azureStackView, cloudContext, cloudStack, AzureInstanceTemplateOperation.PROVISION, null);
// THEN
gson.fromJson(templateString, Map.class);
assertTrue(templateString.contains("\"type\": \"Microsoft.Network/loadBalancers\","));
assertTrue(templateString.contains("\"frontendPort\": 443,"));
assertTrue(templateString.contains("\"backendPort\": 443,"));
assertEquals(1, StringUtils.countMatches(templateString, "\"name\": \"port-443-rule\","));
assertEquals(1, StringUtils.countMatches(templateString, "\"name\": \"group-gateway-group-outbound-rule\","));
assertTrue(templateString.contains("\"name\": \"port-8443-probe\","));
assertTrue(templateString.contains("\"name\": \"" + LoadBalancerSku.getDefault().getTemplateName() + "\""));
assertEquals(2, StringUtils.countMatches(templateString, "\"[resourceId('Microsoft.Network/loadBalancers'"));
assertEquals(2, StringUtils.countMatches(templateString, "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', 'LoadBalancertestStackOUTBOUND', 'gateway-group-pool')]"));
assertEquals(2, StringUtils.countMatches(templateString, "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', 'LoadBalancertestStackPRIVATE', 'gateway-group-pool')]"));
assertEquals(2, StringUtils.countMatches(templateString, "\"type\": \"Microsoft.Network/loadBalancers\","));
assertEquals(1, StringUtils.countMatches(templateString, "\"id\": \"[resourceId('Microsoft.Network/publicIPAddresses', 'LoadBalancertestStackOUTBOUND-publicIp')]\""));
}
use of com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair in project cloudbreak by hortonworks.
the class AzureTemplateBuilderTest method testNicDependenciesWhenNoSecurityGroupsNoFirewallRulesAndNoPublicIp.
@ParameterizedTest(name = "testNicDependenciesWhenNoSecurityGroupsNoFirewallRulesAndNoPublicIp {displayName}_{0}")
@MethodSource("templatesPathDataProvider")
public void testNicDependenciesWhenNoSecurityGroupsNoFirewallRulesAndNoPublicIp(String templatePath) {
ReflectionTestUtils.setField(azureTemplateBuilder, FIELD_ARM_TEMPLATE_PATH, templatePath);
// GIVEN
assumeTrue(isTemplateVersionGreaterOrEqualThan(templatePath, "2.7.3.0"));
Network network = new Network(new Subnet(SUBNET_CIDR));
Map<String, String> parameters = new HashMap<>();
parameters.put("persistentStorage", "persistentStorageTest");
parameters.put("attachedStorageOption", "attachedStorageOptionTest");
InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
groups.add(new Group("gateway-group", InstanceGroupType.GATEWAY, Collections.singletonList(instance), security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey(), ROOT_VOLUME_SIZE, Optional.empty(), createGroupNetwork(), emptyMap()));
List<CloudLoadBalancer> loadBalancers = new ArrayList<>();
CloudLoadBalancer publicLb = new CloudLoadBalancer(LoadBalancerType.PUBLIC);
publicLb.addPortToTargetGroupMapping(new TargetGroupPortPair(443, 8443), new HashSet<>(groups));
loadBalancers.add(publicLb);
CloudLoadBalancer privateLb = new CloudLoadBalancer(LoadBalancerType.PRIVATE);
privateLb.addPortToTargetGroupMapping(new TargetGroupPortPair(443, 8443), new HashSet<>(groups));
loadBalancers.add(privateLb);
cloudStack = new CloudStack(groups, network, image, parameters, tags, azureTemplateBuilder.getTemplateString(), instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey(), null, loadBalancers);
azureStackView = new AzureStackView("mystack", 3, groups, azureStorageView, azureSubnetStrategy, Collections.emptyMap());
// WHEN
when(azureAcceleratedNetworkValidator.validate(any())).thenReturn(ACCELERATED_NETWORK_SUPPORT);
when(azureStorage.getImageStorageName(any(AzureCredentialView.class), any(CloudContext.class), any(CloudStack.class))).thenReturn("test");
when(azureStorage.getDiskContainerName(any(CloudContext.class))).thenReturn("testStorageContainer");
when(azureUtils.getCustomResourceGroupName(any())).thenReturn("custom-resource-group-name");
when(azureUtils.getCustomNetworkId(any())).thenReturn("custom-vnet-id");
when(azureUtils.isExistingNetwork(any())).thenReturn(false);
when(azureUtils.isPrivateIp(any())).thenReturn(true);
String templateString = azureTemplateBuilder.build(stackName, CUSTOM_IMAGE_NAME, azureCredentialView, azureStackView, cloudContext, cloudStack, AzureInstanceTemplateOperation.UPSCALE, null);
// THEN
validateJson(templateString);
}
Aggregations