Search in sources :

Example 66 with InstanceInfo

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

the class EurekaClientServerRestIntegrationTest method testStatusOverrideUpdateAndDelete.

@Test
public void testStatusOverrideUpdateAndDelete() throws Exception {
    // Register first
    InstanceInfo instanceInfo = instanceInfoIt.next();
    jerseyEurekaClient.register(instanceInfo);
    // Now override status
    EurekaHttpResponse<Void> overrideUpdateResponse = jerseyEurekaClient.statusUpdate(instanceInfo.getAppName(), instanceInfo.getId(), InstanceStatus.DOWN, instanceInfo);
    assertThat(overrideUpdateResponse.getStatusCode(), is(equalTo(200)));
    InstanceInfo fetchedInstance = expectInstanceInfoInRegistry(instanceInfo);
    assertThat(fetchedInstance.getStatus(), is(equalTo(InstanceStatus.DOWN)));
    // Now remove override
    EurekaHttpResponse<Void> deleteOverrideResponse = jerseyEurekaClient.deleteStatusOverride(instanceInfo.getAppName(), instanceInfo.getId(), instanceInfo);
    assertThat(deleteOverrideResponse.getStatusCode(), is(equalTo(200)));
    fetchedInstance = expectInstanceInfoInRegistry(instanceInfo);
    assertThat(fetchedInstance.getStatus(), is(equalTo(InstanceStatus.UNKNOWN)));
}
Also used : InstanceInfo(com.netflix.appinfo.InstanceInfo) Test(org.junit.Test)

Example 67 with InstanceInfo

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

the class EurekaClientServerRestIntegrationTest method testBatch.

@Test
public void testBatch() throws Exception {
    InstanceInfo instanceInfo = instanceInfoIt.next();
    ReplicationInstance replicationInstance = ReplicationInstance.replicationInstance().withAction(Action.Register).withAppName(instanceInfo.getAppName()).withId(instanceInfo.getId()).withInstanceInfo(instanceInfo).withLastDirtyTimestamp(System.currentTimeMillis()).withStatus(instanceInfo.getStatus().name()).build();
    EurekaHttpResponse<ReplicationListResponse> httpResponse = jerseyReplicationClient.submitBatchUpdates(new ReplicationList(replicationInstance));
    assertThat(httpResponse.getStatusCode(), is(equalTo(200)));
    List<ReplicationInstanceResponse> replicationListResponse = httpResponse.getEntity().getResponseList();
    assertThat(replicationListResponse.size(), is(equalTo(1)));
    assertThat(replicationListResponse.get(0).getStatusCode(), is(equalTo(200)));
}
Also used : ReplicationListResponse(com.netflix.eureka.cluster.protocol.ReplicationListResponse) ReplicationInstance(com.netflix.eureka.cluster.protocol.ReplicationInstance) ReplicationInstanceResponse(com.netflix.eureka.cluster.protocol.ReplicationInstanceResponse) ReplicationList(com.netflix.eureka.cluster.protocol.ReplicationList) InstanceInfo(com.netflix.appinfo.InstanceInfo) Test(org.junit.Test)

Example 68 with InstanceInfo

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

the class AwsAsgUtilTest method setUp.

@Before
public void setUp() throws Exception {
    ConfigurationManager.getConfigInstance().setProperty("eureka.awsAccessId", "fakeId");
    ConfigurationManager.getConfigInstance().setProperty("eureka.awsSecretKey", "fakeKey");
    AmazonInfo dataCenterInfo = mock(AmazonInfo.class);
    EurekaServerConfig serverConfig = new DefaultEurekaServerConfig();
    InstanceInfo.Builder builder = InstanceInfo.Builder.newBuilder();
    builder.setIPAddr("10.10.101.00");
    builder.setHostName("fakeHost");
    builder.setAppName("fake-" + UUID.randomUUID());
    builder.setLeaseInfo(LeaseInfo.Builder.newBuilder().build());
    builder.setDataCenterInfo(dataCenterInfo);
    instanceInfo = builder.build();
    applicationInfoManager = new ApplicationInfoManager(new MyDataCenterInstanceConfig(), instanceInfo);
    DefaultEurekaClientConfig clientConfig = new DefaultEurekaClientConfig();
    // setup config in advance, used in initialize converter
    client = mock(DiscoveryClient.class);
    registry = mock(PeerAwareInstanceRegistry.class);
    awsAsgUtil = spy(new AwsAsgUtil(serverConfig, clientConfig, registry));
}
Also used : DefaultEurekaClientConfig(com.netflix.discovery.DefaultEurekaClientConfig) DefaultEurekaServerConfig(com.netflix.eureka.DefaultEurekaServerConfig) MyDataCenterInstanceConfig(com.netflix.appinfo.MyDataCenterInstanceConfig) AwsAsgUtil(com.netflix.eureka.aws.AwsAsgUtil) DefaultEurekaServerConfig(com.netflix.eureka.DefaultEurekaServerConfig) EurekaServerConfig(com.netflix.eureka.EurekaServerConfig) DiscoveryClient(com.netflix.discovery.DiscoveryClient) AmazonInfo(com.netflix.appinfo.AmazonInfo) InstanceInfo(com.netflix.appinfo.InstanceInfo) ApplicationInfoManager(com.netflix.appinfo.ApplicationInfoManager) PeerAwareInstanceRegistry(com.netflix.eureka.registry.PeerAwareInstanceRegistry) Before(org.junit.Before)

Example 69 with InstanceInfo

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

the class ApplicationResourceTest method testGoodRegistration.

@Test
public void testGoodRegistration() throws Exception {
    InstanceInfo noIdInfo = InstanceInfoGenerator.takeOne();
    Response response = applicationResource.addInstance(noIdInfo, false + "");
    assertThat(response.getStatus(), is(204));
}
Also used : Response(javax.ws.rs.core.Response) InstanceInfo(com.netflix.appinfo.InstanceInfo) Test(org.junit.Test)

Example 70 with InstanceInfo

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

the class ApplicationResourceTest method testMiniAppGet.

@Test
public void testMiniAppGet() throws Exception {
    Response response = applicationResource.getApplication(Version.V2.name(), MediaType.APPLICATION_JSON, EurekaAccept.compact.name());
    String json = String.valueOf(response.getEntity());
    DecoderWrapper decoder = CodecWrappers.getDecoder(CodecWrappers.LegacyJacksonJson.class);
    Application decodedApp = decoder.decode(json, Application.class);
    // assert false as one is mini, so should NOT equal
    assertThat(EurekaEntityComparators.equal(testApplication, decodedApp), is(false));
    for (InstanceInfo instanceInfo : testApplication.getInstances()) {
        InstanceInfo decodedInfo = decodedApp.getByInstanceId(instanceInfo.getId());
        assertThat(EurekaEntityComparators.equalMini(instanceInfo, decodedInfo), is(true));
    }
}
Also used : Response(javax.ws.rs.core.Response) DecoderWrapper(com.netflix.discovery.converters.wrappers.DecoderWrapper) Application(com.netflix.discovery.shared.Application) InstanceInfo(com.netflix.appinfo.InstanceInfo) CodecWrappers(com.netflix.discovery.converters.wrappers.CodecWrappers) 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