Search in sources :

Example 6 with InstanceInfoGenerator

use of com.netflix.discovery.util.InstanceInfoGenerator in project eureka by Netflix.

the class DiscoveryClientRegistryTest method testCacheRefreshSingleAppForLocalRegion.

@Test
public void testCacheRefreshSingleAppForLocalRegion() throws Exception {
    InstanceInfoGenerator instanceGen = InstanceInfoGenerator.newBuilder(2, "testApp").build();
    Applications initialApps = instanceGen.takeDelta(1);
    String vipAddress = initialApps.getRegisteredApplications().get(0).getInstances().get(0).getVIPAddress();
    DiscoveryClientResource vipClientResource = discoveryClientResource.fork().withVipFetch(vipAddress).build();
    // Take first portion
    when(requestHandler.getVip(vipAddress, TEST_REMOTE_REGION)).thenReturn(anEurekaHttpResponse(200, initialApps).type(MediaType.APPLICATION_JSON_TYPE).build());
    EurekaClient vipClient = vipClientResource.getClient();
    assertThat(countInstances(vipClient.getApplications()), is(equalTo(1)));
    // Now second one
    when(requestHandler.getVip(vipAddress, TEST_REMOTE_REGION)).thenReturn(anEurekaHttpResponse(200, instanceGen.toApplications()).type(MediaType.APPLICATION_JSON_TYPE).build());
    assertThat(vipClientResource.awaitCacheUpdate(5, TimeUnit.SECONDS), is(true));
    assertThat(countInstances(vipClient.getApplications()), is(equalTo(2)));
}
Also used : Applications(com.netflix.discovery.shared.Applications) EurekaEntityFunctions.toApplications(com.netflix.discovery.util.EurekaEntityFunctions.toApplications) EurekaEntityFunctions.mergeApplications(com.netflix.discovery.util.EurekaEntityFunctions.mergeApplications) EurekaEntityFunctions.copyApplications(com.netflix.discovery.util.EurekaEntityFunctions.copyApplications) InstanceInfoGenerator(com.netflix.discovery.util.InstanceInfoGenerator) DiscoveryClientResource(com.netflix.discovery.junit.resource.DiscoveryClientResource) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 7 with InstanceInfoGenerator

use of com.netflix.discovery.util.InstanceInfoGenerator in project eureka by Netflix.

the class ApplicationResourceTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    InstanceInfoGenerator instanceInfos = InstanceInfoGenerator.newBuilder(6, 1).build();
    testApplication = instanceInfos.toApplications().getRegisteredApplications().get(0);
    applicationResource = new ApplicationResource(testApplication.getName(), serverContext.getServerConfig(), serverContext.getRegistry());
    for (InstanceInfo instanceInfo : testApplication.getInstances()) {
        registry.register(instanceInfo, false);
    }
}
Also used : InstanceInfoGenerator(com.netflix.discovery.util.InstanceInfoGenerator) InstanceInfo(com.netflix.appinfo.InstanceInfo) Before(org.junit.Before)

Example 8 with InstanceInfoGenerator

use of com.netflix.discovery.util.InstanceInfoGenerator in project eureka by Netflix.

the class ApplicationsResourceTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    InstanceInfoGenerator instanceInfos = InstanceInfoGenerator.newBuilder(20, 6).build();
    testApplications = instanceInfos.toApplications();
    applicationsResource = new ApplicationsResource(serverContext);
    for (Application application : testApplications.getRegisteredApplications()) {
        for (InstanceInfo instanceInfo : application.getInstances()) {
            registry.register(instanceInfo, false);
        }
    }
}
Also used : InstanceInfoGenerator(com.netflix.discovery.util.InstanceInfoGenerator) Application(com.netflix.discovery.shared.Application) InstanceInfo(com.netflix.appinfo.InstanceInfo) Before(org.junit.Before)

Aggregations

InstanceInfoGenerator (com.netflix.discovery.util.InstanceInfoGenerator)8 InstanceInfo (com.netflix.appinfo.InstanceInfo)5 Applications (com.netflix.discovery.shared.Applications)5 EurekaEntityFunctions.toApplications (com.netflix.discovery.util.EurekaEntityFunctions.toApplications)5 Test (org.junit.Test)5 EurekaEntityFunctions.copyApplications (com.netflix.discovery.util.EurekaEntityFunctions.copyApplications)4 EurekaEntityFunctions.mergeApplications (com.netflix.discovery.util.EurekaEntityFunctions.mergeApplications)4 Before (org.junit.Before)3 DataCenterInfo (com.netflix.appinfo.DataCenterInfo)1 EurekaAccept (com.netflix.appinfo.EurekaAccept)1 DiscoveryClientResource (com.netflix.discovery.junit.resource.DiscoveryClientResource)1 Application (com.netflix.discovery.shared.Application)1 Key (com.netflix.eureka.registry.Key)1 Response (javax.ws.rs.core.Response)1 Matchers.anyString (org.mockito.Matchers.anyString)1