use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.gcp.GcpLoadBalancerNamesDb in project cloudbreak by hortonworks.
the class LoadBalancerConfigConverterTest method testConvertGcpTargetGroup.
@Test
public void testConvertGcpTargetGroup() {
CloudLoadBalancerMetadata cloudLoadBalancerMetadata = new CloudLoadBalancerMetadata.Builder().withParameters(creatGcpParams(1)).build();
TargetGroup targetGroup = new TargetGroup();
targetGroup.setType(TargetGroupType.KNOX);
TargetGroupPortPair portPair = new TargetGroupPortPair(PORT1, PORT2);
when(loadBalancerConfigService.getTargetGroupPortPairs(eq(targetGroup))).thenReturn(Set.of(portPair));
TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = underTest.convertTargetGroup(GCP, cloudLoadBalancerMetadata, targetGroup);
assertNotNull(targetGroupConfigDbWrapper.getGcpConfig());
GcpTargetGroupConfigDb gcpTargetGroupConfigDb = targetGroupConfigDbWrapper.getGcpConfig();
assertEquals(1, gcpTargetGroupConfigDb.getPortMapping().size());
assertEquals(PORT1, gcpTargetGroupConfigDb.getPortMapping().keySet().iterator().next());
GcpLoadBalancerNamesDb gcpLoadBalancerNamesDb = gcpTargetGroupConfigDb.getPortMapping().get(PORT1);
assertEquals(BACKEND_SERVICE_NAME, gcpLoadBalancerNamesDb.getBackendServiceName());
assertEquals(INSTANCE_GROUP_NAME, gcpLoadBalancerNamesDb.getInstanceGroupName());
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.gcp.GcpLoadBalancerNamesDb in project cloudbreak by hortonworks.
the class LoadBalancerConfigConverter method buildGcpConfig.
private TargetGroupConfigDbWrapper buildGcpConfig(GcpLoadBalancerMetadataView gcpMetadata, TargetGroup targetGroup) {
Set<Integer> trafficPorts = getTrafficPorts(targetGroup);
TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = new TargetGroupConfigDbWrapper();
GcpTargetGroupConfigDb gcpTargetGroupConfigDb = new GcpTargetGroupConfigDb();
for (Integer port : trafficPorts) {
GcpLoadBalancerNamesDb namesDb = new GcpLoadBalancerNamesDb();
namesDb.setInstanceGroupName(gcpMetadata.getInstanceGroupByPort(port));
namesDb.setBackendServiceName(gcpMetadata.getBackendServiceByPort(port));
gcpTargetGroupConfigDb.addPortNameMapping(port, namesDb);
}
targetGroupConfigDbWrapper.setGcpConfig(gcpTargetGroupConfigDb);
return targetGroupConfigDbWrapper;
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.gcp.GcpLoadBalancerNamesDb in project cloudbreak by hortonworks.
the class LoadBalancerToLoadBalancerResponseConverterTest method creatGcpTargetGroups.
private Set<TargetGroup> creatGcpTargetGroups() {
GcpTargetGroupConfigDb gcpTargetGroupConfigDb = new GcpTargetGroupConfigDb();
GcpLoadBalancerNamesDb gcpLoadBalancerNamesDb = new GcpLoadBalancerNamesDb();
gcpLoadBalancerNamesDb.setBackendServiceName(GCP_BACKEND_SERVICE_NAME);
gcpLoadBalancerNamesDb.setInstanceGroupName(GCP_INSTANCE_GROUP_NAME);
gcpTargetGroupConfigDb.addPortNameMapping(PORT, gcpLoadBalancerNamesDb);
TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = new TargetGroupConfigDbWrapper();
targetGroupConfigDbWrapper.setGcpConfig(gcpTargetGroupConfigDb);
TargetGroup targetGroup = new TargetGroup();
targetGroup.setProviderConfig(targetGroupConfigDbWrapper);
return Set.of(targetGroup);
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.gcp.GcpLoadBalancerNamesDb in project cloudbreak by hortonworks.
the class LoadBalancerToLoadBalancerResponseConverter method convertGcpTargetGroup.
private GcpTargetGroupResponse convertGcpTargetGroup(GcpTargetGroupConfigDb gcpConfig, Integer port) {
if (gcpConfig != null) {
GcpLoadBalancerNamesDb gcpLoadBalancerNamesDb = gcpConfig.getPortMapping().get(port);
GcpTargetGroupResponse gcpTargetGroupResponse = new GcpTargetGroupResponse();
gcpTargetGroupResponse.setGcpInstanceGroupName(gcpLoadBalancerNamesDb.getInstanceGroupName());
gcpTargetGroupResponse.setGcpBackendServiceName(gcpLoadBalancerNamesDb.getBackendServiceName());
return gcpTargetGroupResponse;
}
return null;
}
Aggregations