use of com.netflix.turbine.discovery.Instance in project spring-cloud-netflix by spring-cloud.
the class CommonsInstanceDiscoveryTests method testGetSecurePort.
@Test
public void testGetSecurePort() {
CommonsInstanceDiscovery discovery = createDiscovery();
String appName = "testAppName";
// int port = 8080;
int port = 8443;
String hostName = "myhost";
DefaultServiceInstance serviceInstance = new DefaultServiceInstance(appName, hostName, port, true);
Instance instance = discovery.marshall(serviceInstance);
assertEquals("port is wrong", String.valueOf(port), instance.getAttributes().get("port"));
assertEquals("securePort is wrong", String.valueOf(port), instance.getAttributes().get("securePort"));
String urlPath = SpringClusterMonitor.ClusterConfigBasedUrlClosure.getUrlPath(instance);
assertEquals("url is wrong", "https://" + hostName + ":" + port + "/actuator/hystrix.stream", urlPath);
}
use of com.netflix.turbine.discovery.Instance in project spring-cloud-netflix by spring-cloud.
the class EurekaInstanceDiscoveryTests method testCombineHostPort.
@Test
public void testCombineHostPort() {
turbineProperties.setCombineHostPort(true);
EurekaInstanceDiscovery discovery = new EurekaInstanceDiscovery(turbineProperties, eurekaClient);
String appName = "testAppName";
int port = 8080;
String hostName = "myhost";
InstanceInfo instanceInfo = builder.setAppName(appName).setHostName(hostName).setPort(port).build();
Instance instance = discovery.marshall(instanceInfo);
assertEquals("hostname is wrong", hostName + ":" + port, instance.getHostname());
assertEquals("port is wrong", String.valueOf(port), instance.getAttributes().get("port"));
String urlPath = SpringClusterMonitor.ClusterConfigBasedUrlClosure.getUrlPath(instance);
assertEquals("url is wrong", "http://" + hostName + ":" + port + "/actuator/hystrix.stream", urlPath);
String clusterName = discovery.getClusterName(instanceInfo);
assertEquals("clusterName is wrong", appName.toUpperCase(), clusterName);
}
use of com.netflix.turbine.discovery.Instance in project spring-cloud-netflix by spring-cloud.
the class EurekaInstanceDiscoveryTests method testGetPort.
@Test
public void testGetPort() {
EurekaInstanceDiscovery discovery = new EurekaInstanceDiscovery(turbineProperties, eurekaClient);
String appName = "testAppName";
int port = 8080;
String hostName = "myhost";
InstanceInfo instanceInfo = builder.setAppName(appName).setHostName(hostName).setPort(port).build();
Instance instance = discovery.marshall(instanceInfo);
assertEquals("port is wrong", String.valueOf(port), instance.getAttributes().get("port"));
String urlPath = SpringClusterMonitor.ClusterConfigBasedUrlClosure.getUrlPath(instance);
assertEquals("url is wrong", "http://" + hostName + ":" + port + "/actuator/hystrix.stream", urlPath);
}
use of com.netflix.turbine.discovery.Instance in project spring-cloud-netflix by spring-cloud.
the class EurekaInstanceDiscoveryTests method testUseManagementPortFromMetadata.
@Test
public void testUseManagementPortFromMetadata() {
EurekaInstanceDiscovery discovery = new EurekaInstanceDiscovery(turbineProperties, eurekaClient);
String appName = "testAppName";
int port = 8080;
int managementPort = 8081;
String hostName = "myhost";
InstanceInfo instanceInfo = builder.setAppName(appName).setHostName(hostName).setPort(port).build();
instanceInfo.getMetadata().put("management.port", "8081");
Instance instance = discovery.marshall(instanceInfo);
assertEquals("hostname is wrong", hostName + ":" + managementPort, instance.getHostname());
assertEquals("port is wrong", String.valueOf(managementPort), instance.getAttributes().get("port"));
String urlPath = SpringClusterMonitor.ClusterConfigBasedUrlClosure.getUrlPath(instance);
assertEquals("url is wrong", "http://" + hostName + ":" + managementPort + "/actuator/hystrix.stream", urlPath);
String clusterName = discovery.getClusterName(instanceInfo);
assertEquals("clusterName is wrong", appName.toUpperCase(), clusterName);
}
Aggregations