Search in sources :

Example 11 with Instance

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);
}
Also used : DefaultServiceInstance(org.springframework.cloud.client.DefaultServiceInstance) Instance(com.netflix.turbine.discovery.Instance) DefaultServiceInstance(org.springframework.cloud.client.DefaultServiceInstance) Test(org.junit.Test)

Example 12 with Instance

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);
}
Also used : Instance(com.netflix.turbine.discovery.Instance) InstanceInfo(com.netflix.appinfo.InstanceInfo) Test(org.junit.Test)

Example 13 with Instance

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);
}
Also used : Instance(com.netflix.turbine.discovery.Instance) InstanceInfo(com.netflix.appinfo.InstanceInfo) Test(org.junit.Test)

Example 14 with Instance

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);
}
Also used : Instance(com.netflix.turbine.discovery.Instance) InstanceInfo(com.netflix.appinfo.InstanceInfo) Test(org.junit.Test)

Aggregations

Instance (com.netflix.turbine.discovery.Instance)14 Test (org.junit.Test)10 InstanceInfo (com.netflix.appinfo.InstanceInfo)6 DefaultServiceInstance (org.springframework.cloud.client.DefaultServiceInstance)5 ArrayList (java.util.ArrayList)2 ServiceInstance (org.springframework.cloud.client.ServiceInstance)2 AmazonInfo (com.netflix.appinfo.AmazonInfo)1 DataCenterInfo (com.netflix.appinfo.DataCenterInfo)1 Application (com.netflix.discovery.shared.Application)1