Search in sources :

Example 81 with InstanceInfo

use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.

the class EurekaHttpClientCompatibilityTestSuite method testStatusUpdateDeleteRequest.

@Test
public void testStatusUpdateDeleteRequest() throws Exception {
    InstanceInfo instance = InstanceInfoGenerator.takeOne();
    when(requestHandler.deleteStatusOverride(instance.getAppName(), instance.getId(), null)).thenReturn(EurekaHttpResponse.status(200));
    EurekaHttpResponse<Void> httpResponse = getEurekaHttpClient().deleteStatusOverride(instance.getAppName(), instance.getId(), instance);
    assertThat(httpResponse.getStatusCode(), is(equalTo(200)));
}
Also used : InstanceInfo(com.netflix.appinfo.InstanceInfo) Test(org.junit.Test)

Example 82 with InstanceInfo

use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.

the class SimpleEurekaHttpServer method handleAppsPost.

private void handleAppsPost(HttpExchange httpExchange) throws IOException {
    EurekaHttpResponse<?> httpResponse;
    String path = httpExchange.getRequestURI().getPath();
    if (path.matches("/v2/apps/([^/]+)(/)?")) {
        InstanceInfo instance = decoder.decode(httpExchange.getRequestBody(), InstanceInfo.class);
        httpResponse = requestHandler.register(instance);
    } else {
        httpExchange.sendResponseHeaders(HttpServletResponse.SC_NOT_FOUND, 0);
        return;
    }
    mapResponse(httpExchange, httpResponse);
}
Also used : InstanceInfo(com.netflix.appinfo.InstanceInfo)

Example 83 with InstanceInfo

use of com.netflix.appinfo.InstanceInfo in project ribbon by Netflix.

the class DiscoveryEnabledLoadBalancerSupportsPortOverrideTest method setupMock.

@Before
public void setupMock() {
    List<InstanceInfo> dummyII = getDummyInstanceInfo("dummy", "http://www.host.com", "1.1.1.1", 8001);
    List<InstanceInfo> secureDummyII = getDummyInstanceInfo("secureDummy", "http://www.host.com", "1.1.1.1", 8002);
    PowerMock.mockStatic(DiscoveryManager.class);
    PowerMock.mockStatic(DiscoveryClient.class);
    DiscoveryClient mockedDiscoveryClient = createMock(DiscoveryClient.class);
    DiscoveryManager mockedDiscoveryManager = createMock(DiscoveryManager.class);
    expect(DiscoveryClient.getZone((InstanceInfo) EasyMock.anyObject())).andReturn("dummyZone").anyTimes();
    expect(DiscoveryManager.getInstance()).andReturn(mockedDiscoveryManager).anyTimes();
    expect(mockedDiscoveryManager.getDiscoveryClient()).andReturn(mockedDiscoveryClient).anyTimes();
    expect(mockedDiscoveryClient.getInstancesByVipAddress("dummy", false, "region")).andReturn(dummyII).anyTimes();
    expect(mockedDiscoveryClient.getInstancesByVipAddress("secureDummy", true, "region")).andReturn(secureDummyII).anyTimes();
    replay(DiscoveryManager.class);
    replay(DiscoveryClient.class);
    replay(mockedDiscoveryManager);
    replay(mockedDiscoveryClient);
}
Also used : DiscoveryManager(com.netflix.discovery.DiscoveryManager) DiscoveryClient(com.netflix.discovery.DiscoveryClient) InstanceInfo(com.netflix.appinfo.InstanceInfo) Before(org.junit.Before)

Example 84 with InstanceInfo

use of com.netflix.appinfo.InstanceInfo in project ribbon by Netflix.

the class DiscoveryEnabledLoadBalancerSupportsPortOverrideTest method getDummyInstanceInfo.

protected static List<InstanceInfo> getDummyInstanceInfo(String appName, String host, String ipAddr, int port) {
    List<InstanceInfo> list = new ArrayList<InstanceInfo>();
    InstanceInfo info = InstanceInfo.Builder.newBuilder().setAppName(appName).setHostName(host).setIPAddr(ipAddr).setPort(port).build();
    list.add(info);
    return list;
}
Also used : ArrayList(java.util.ArrayList) InstanceInfo(com.netflix.appinfo.InstanceInfo)

Example 85 with InstanceInfo

use of com.netflix.appinfo.InstanceInfo in project chassis by Kixeye.

the class ChassisEurekaRegistrationTest method testServiceRegistration.

@Test
public void testServiceRegistration() throws InterruptedException {
    // Registers "chasis-default-name" with a Eurkea server running on local host.
    //   http://localhost:8184/v2/apps/chassis-default-name
    // tell eureka the service is up which causes a registration
    ApplicationInfoManager.getInstance().setInstanceStatus(InstanceInfo.InstanceStatus.UP);
    // get application registration from Eureka
    DiscoveryClient client = DiscoveryManager.getInstance().getDiscoveryClient();
    InstanceInfo instanceInfo = null;
    for (int i = 0; (instanceInfo == null) && (i < 50); i++) {
        Thread.sleep(5000);
        try {
            instanceInfo = client.getNextServerFromEureka("default-service", false);
        } catch (RuntimeException e) {
        // eat not found runtime exception
        }
    }
    Assert.assertNotNull(instanceInfo);
    Assert.assertEquals(InstanceStatus.UP, instanceInfo.getStatus());
    System.out.println("done");
}
Also used : DiscoveryClient(com.netflix.discovery.DiscoveryClient) InstanceInfo(com.netflix.appinfo.InstanceInfo) Test(org.junit.Test)

Aggregations

InstanceInfo (com.netflix.appinfo.InstanceInfo)192 Test (org.junit.Test)74 Application (com.netflix.discovery.shared.Application)35 Applications (com.netflix.discovery.shared.Applications)22 AmazonInfo (com.netflix.appinfo.AmazonInfo)21 ArrayList (java.util.ArrayList)19 InstanceStatus (com.netflix.appinfo.InstanceInfo.InstanceStatus)11 Before (org.junit.Before)11 DiscoveryClient (com.netflix.discovery.DiscoveryClient)10 DecoderWrapper (com.netflix.discovery.converters.wrappers.DecoderWrapper)10 Lease (com.netflix.eureka.lease.Lease)9 HashMap (java.util.HashMap)8 Response (javax.ws.rs.core.Response)8 DataCenterInfo (com.netflix.appinfo.DataCenterInfo)7 CodecWrappers (com.netflix.discovery.converters.wrappers.CodecWrappers)7 EncoderWrapper (com.netflix.discovery.converters.wrappers.EncoderWrapper)7 ByteArrayInputStream (java.io.ByteArrayInputStream)7 ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)6 EurekaEntityFunctions.mergeApplications (com.netflix.discovery.util.EurekaEntityFunctions.mergeApplications)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)6