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