Search in sources :

Example 21 with DiscoveryTreeNode

use of org.apache.servicecomb.registry.discovery.DiscoveryTreeNode in project java-chassis by ServiceComb.

the class TestDiscoveryTree method isMatch_no.

@Test
public void isMatch_no() {
    parent.cacheVersion(0);
    Assert.assertFalse(discoveryTree.isExpired(new DiscoveryTreeNode().cacheVersion(1), parent));
}
Also used : DiscoveryTreeNode(org.apache.servicecomb.registry.discovery.DiscoveryTreeNode) Test(org.junit.Test)

Example 22 with DiscoveryTreeNode

use of org.apache.servicecomb.registry.discovery.DiscoveryTreeNode in project java-chassis by ServiceComb.

the class TestDiscoveryTree method isExpired_yes.

@Test
public void isExpired_yes() {
    parent.cacheVersion(1);
    Assert.assertTrue(discoveryTree.isExpired(new DiscoveryTreeNode().cacheVersion(0), parent));
}
Also used : DiscoveryTreeNode(org.apache.servicecomb.registry.discovery.DiscoveryTreeNode) Test(org.junit.Test)

Example 23 with DiscoveryTreeNode

use of org.apache.servicecomb.registry.discovery.DiscoveryTreeNode in project java-chassis by ServiceComb.

the class TestDiscoveryTree method isExpired_no.

@Test
public void isExpired_no() {
    parent.cacheVersion(0);
    Assert.assertFalse(discoveryTree.isExpired(new DiscoveryTreeNode().cacheVersion(0), parent));
}
Also used : DiscoveryTreeNode(org.apache.servicecomb.registry.discovery.DiscoveryTreeNode) Test(org.junit.Test)

Example 24 with DiscoveryTreeNode

use of org.apache.servicecomb.registry.discovery.DiscoveryTreeNode in project java-chassis by ServiceComb.

the class IsolationDiscoveryFilterTest method discovery_no_instance_reach_error_threshold.

@Test
public void discovery_no_instance_reach_error_threshold() {
    DiscoveryTreeNode childNode = filter.discovery(discoveryContext, discoveryTreeNode);
    Map<String, MicroserviceInstance> childNodeData = childNode.data();
    Assert.assertThat(childNodeData.keySet(), Matchers.containsInAnyOrder("i0", "i1", "i2"));
    Assert.assertEquals(data.get("i0"), childNodeData.get("i0"));
    Assert.assertEquals(data.get("i1"), childNodeData.get("i1"));
    Assert.assertEquals(data.get("i2"), childNodeData.get("i2"));
}
Also used : DiscoveryTreeNode(org.apache.servicecomb.registry.discovery.DiscoveryTreeNode) MicroserviceInstance(org.apache.servicecomb.registry.api.registry.MicroserviceInstance) Test(org.junit.Test)

Example 25 with DiscoveryTreeNode

use of org.apache.servicecomb.registry.discovery.DiscoveryTreeNode in project java-chassis by ServiceComb.

the class IsolationDiscoveryFilterTest method discovery_recover_instance.

@Test
public void discovery_recover_instance() {
    ServiceCombServer server0 = ServiceCombLoadBalancerStats.INSTANCE.getServiceCombServer(data.get("i0"));
    ServiceCombLoadBalancerStats.INSTANCE.markSuccess(server0);
    ServiceCombServerStats serviceCombServerStats = ServiceCombLoadBalancerStats.INSTANCE.getServiceCombServerStats(server0);
    ServiceCombLoadBalancerStats.INSTANCE.markIsolated(server0, true);
    Deencapsulation.setField(serviceCombServerStats, "isolatedTime", System.currentTimeMillis() - Configuration.INSTANCE.getMinIsolationTime(invocation.getMicroserviceName()) - 1);
    DiscoveryTreeNode childNode = filter.discovery(discoveryContext, discoveryTreeNode);
    Map<String, MicroserviceInstance> childNodeData = childNode.data();
    Assert.assertThat(childNodeData.keySet(), Matchers.containsInAnyOrder("i0", "i1", "i2"));
    Assert.assertEquals(data.get("i0"), childNodeData.get("i0"));
    Assert.assertEquals(data.get("i1"), childNodeData.get("i1"));
    Assert.assertEquals(data.get("i2"), childNodeData.get("i2"));
    Assert.assertFalse(ServiceCombLoadBalancerStats.INSTANCE.getServiceCombServerStats(server0).isIsolated());
}
Also used : ServiceCombServer(org.apache.servicecomb.loadbalance.ServiceCombServer) DiscoveryTreeNode(org.apache.servicecomb.registry.discovery.DiscoveryTreeNode) MicroserviceInstance(org.apache.servicecomb.registry.api.registry.MicroserviceInstance) ServiceCombServerStats(org.apache.servicecomb.loadbalance.ServiceCombServerStats) TestServiceCombServerStats(org.apache.servicecomb.loadbalance.TestServiceCombServerStats) Test(org.junit.Test)

Aggregations

DiscoveryTreeNode (org.apache.servicecomb.registry.discovery.DiscoveryTreeNode)33 Test (org.junit.Test)25 MicroserviceInstance (org.apache.servicecomb.registry.api.registry.MicroserviceInstance)20 HashMap (java.util.HashMap)11 Invocation (org.apache.servicecomb.core.Invocation)11 ArrayList (java.util.ArrayList)6 NonSwaggerInvocation (org.apache.servicecomb.core.NonSwaggerInvocation)6 Transport (org.apache.servicecomb.core.Transport)6 TransportManager (org.apache.servicecomb.core.transport.TransportManager)6 ServiceCombServer (org.apache.servicecomb.loadbalance.ServiceCombServer)6 InstanceCacheManager (org.apache.servicecomb.registry.cache.InstanceCacheManager)6 MicroserviceMeta (org.apache.servicecomb.core.definition.MicroserviceMeta)5 OperationMeta (org.apache.servicecomb.core.definition.OperationMeta)5 DataCenterInfo (org.apache.servicecomb.registry.api.registry.DataCenterInfo)5 DiscoveryContext (org.apache.servicecomb.registry.discovery.DiscoveryContext)5 InvocationRuntimeType (org.apache.servicecomb.core.definition.InvocationRuntimeType)4 SchemaMeta (org.apache.servicecomb.core.definition.SchemaMeta)4 ReferenceConfig (org.apache.servicecomb.core.provider.consumer.ReferenceConfig)4 ServiceCombServerStats (org.apache.servicecomb.loadbalance.ServiceCombServerStats)4 TestServiceCombServerStats (org.apache.servicecomb.loadbalance.TestServiceCombServerStats)4