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)));
}
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);
}
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);
}
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;
}
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");
}
Aggregations