Search in sources :

Example 16 with InstanceStore

use of org.apache.servicecomb.registry.lightweight.store.InstanceStore in project incubator-servicecomb-java-chassis by apache.

the class StoreServiceTest method should_process_as_heartbeat_when_nothing_changed.

@Test
void should_process_as_heartbeat_when_nothing_changed() {
    should_register_microservice_and_instance_when_both_not_exist();
    InstanceStore instanceStore = store.findInstanceStore(self.getInstanceId());
    assertThat(instanceStore.getLastHeartBeat()).isEqualTo(0);
    ticker.setValues(1L);
    should_register_microservice_and_instance_when_both_not_exist();
    assertThat(instanceStore.getLastHeartBeat()).isEqualTo(1);
}
Also used : InstanceStore(org.apache.servicecomb.registry.lightweight.store.InstanceStore) Test(org.junit.jupiter.api.Test)

Example 17 with InstanceStore

use of org.apache.servicecomb.registry.lightweight.store.InstanceStore in project incubator-servicecomb-java-chassis by apache.

the class StoreServiceTest method should_register_microservice_and_instance_when_both_not_exist.

@Test
void should_register_microservice_and_instance_when_both_not_exist() {
    RegisterRequest request = self.buildRegisterRequest();
    InstanceStore instanceStore = service.register(request);
    assertThat(store.findMicroserviceStore(self.getServiceId()).getMicroservice()).isSameAs(self.getMicroservice());
    assertThat(instanceStore.getInstance()).isSameAs(self.getInstance());
    assertThat(self.getInstance().getStatus()).isEqualTo(MicroserviceInstanceStatus.UP);
}
Also used : InstanceStore(org.apache.servicecomb.registry.lightweight.store.InstanceStore) Test(org.junit.jupiter.api.Test)

Example 18 with InstanceStore

use of org.apache.servicecomb.registry.lightweight.store.InstanceStore in project incubator-servicecomb-java-chassis by apache.

the class StoreServiceTest method should_allow_update_instance_status.

@Test
void should_allow_update_instance_status() {
    should_register_microservice_and_instance_when_both_not_exist();
    RegisterRequest request = self.buildRegisterRequest().setStatus(MicroserviceInstanceStatus.TESTING);
    ticker.setValues(1L);
    InstanceStore instanceStore = service.register(request);
    assertThat(self.getInstance().getStatus()).isEqualTo(MicroserviceInstanceStatus.TESTING);
    assertThat(instanceStore.getLastHeartBeat()).isEqualTo(1);
}
Also used : InstanceStore(org.apache.servicecomb.registry.lightweight.store.InstanceStore) Test(org.junit.jupiter.api.Test)

Aggregations

InstanceStore (org.apache.servicecomb.registry.lightweight.store.InstanceStore)18 Test (org.junit.jupiter.api.Test)10 MicroserviceStore (org.apache.servicecomb.registry.lightweight.store.MicroserviceStore)6 EventBus (com.google.common.eventbus.EventBus)2 Duration (java.time.Duration)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 Endpoint (org.apache.servicecomb.core.Endpoint)2 AsyncUtils (org.apache.servicecomb.foundation.common.utils.AsyncUtils)2 Microservice (org.apache.servicecomb.registry.api.registry.Microservice)2 MicroserviceInstance (org.apache.servicecomb.registry.api.registry.MicroserviceInstance)2 Store (org.apache.servicecomb.registry.lightweight.store.Store)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Component (org.springframework.stereotype.Component)2