Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
chengyouling committed Dec 19, 2023
1 parent bc09176 commit 6ef5fe1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,19 +223,11 @@ public void testApacheZone() {
}

/**
* 测试alibaba rule中route有选中tag,但是没有符合版本的实例,invoker命中fallback版本实例的情况
* rule中route有选中tag,但是没有符合版本的实例,invoker命中fallback版本实例的情况
*/
@Test
public void testAlibabaV1Fallback() {
List<Route> fallback = new ArrayList<>();
Map<String, String> tags = new HashMap<>();
tags.put(RouterConstant.DUBBO_VERSION_KEY, "0.0.3");
Route route = new Route();
route.setTags(tags);
route.setWeight(100);
fallback.add(route);
rule.setFallback(fallback);

setFallbackRoute();
List<Object> invokers = new ArrayList<>();
AlibabaInvoker<Object> invoker1 = new AlibabaInvoker<>("0.0.3");
invokers.add(invoker1);
Expand All @@ -249,11 +241,7 @@ public void testAlibabaV1Fallback() {
Assert.assertEquals(invoker1, matchInvokers.get(0));
}

/**
* 测试alibaba rule中设置route、fallback,且权重均有命中tag,但是invoker均未命中版本实例的情况
*/
@Test
public void testAlibabaV1NotMathRouteFallback() {
private void setFallbackRoute() {
List<Route> fallback = new ArrayList<>();
Map<String, String> tags = new HashMap<>();
tags.put(RouterConstant.DUBBO_VERSION_KEY, "0.0.3");
Expand All @@ -262,7 +250,14 @@ public void testAlibabaV1NotMathRouteFallback() {
route.setWeight(100);
fallback.add(route);
rule.setFallback(fallback);
}

/**
* rule中设置route、fallback,且权重均有命中tag,但是invoker均未命中版本实例的情况
*/
@Test
public void testAlibabaV1NotMathRouteFallback() {
setFallbackRoute();
List<Object> invokers = new ArrayList<>();
ApacheInvoker<Object> invoker1 = new ApacheInvoker<>("0.0.2");
invokers.add(invoker1);
Expand All @@ -275,18 +270,11 @@ public void testAlibabaV1NotMathRouteFallback() {
}

/**
* 测试alibaba rule中设置routes但权重计算未命中,invoker命中fallback版本实例的情况
* rule中设置routes但权重计算未命中,invoker命中fallback版本实例的情况
*/
@Test
public void testAlibabaV1MathFallback() {
List<Route> fallback = new ArrayList<>();
Map<String, String> tags = new HashMap<>();
tags.put(RouterConstant.DUBBO_VERSION_KEY, "0.0.3");
Route route = new Route();
route.setTags(tags);
route.setWeight(100);
fallback.add(route);
rule.setFallback(fallback);
setFallbackRoute();
routes.get(0).setWeight(0);
routes.get(1).setWeight(0);

Expand All @@ -303,18 +291,11 @@ public void testAlibabaV1MathFallback() {
}

/**
* 测试alibaba rule中设置routes但权重计算未命中,同时fallback也未命中实例,invoker返回未设置规则版本号版本实例的情况
* rule中设置routes但权重计算未命中,同时fallback也未命中实例,invoker返回未设置规则版本号版本实例的情况
*/
@Test
public void testAlibabaV1BothNotMathFallbackRoute() {
List<Route> fallback = new ArrayList<>();
Map<String, String> tags = new HashMap<>();
tags.put(RouterConstant.DUBBO_VERSION_KEY, "0.0.3");
Route route = new Route();
route.setTags(tags);
route.setWeight(100);
fallback.add(route);
rule.setFallback(fallback);
setFallbackRoute();
routes.get(0).setWeight(0);
routes.get(1).setWeight(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,7 @@ public void testZoneFoo() {
*/
@Test
public void testMatchV1Fallback() {
List<Route> fallback = new ArrayList<>();
Map<String, String> tags = new HashMap<>();
tags.put(RouterConstant.DUBBO_VERSION_KEY, "0.0.3");
Route route = new Route();
route.setTags(tags);
route.setWeight(100);
fallback.add(route);
rule.setFallback(fallback);
setFallbackRoute();

List<Object> instances = new ArrayList<>();
ServiceInstance instance1 = TestDefaultServiceInstance.getTestDefaultServiceInstance("0.0.3");
Expand All @@ -170,11 +163,7 @@ public void testMatchV1Fallback() {
Assert.assertEquals(instance1, matchInvoker.get(0));
}

/**
* rule中设置route、fallback,且权重均有命中tag,但是invoker均未命中版本实例的情况
*/
@Test
public void testSpringV1NotMathRouteFallback() {
private void setFallbackRoute() {
List<Route> fallback = new ArrayList<>();
Map<String, String> tags = new HashMap<>();
tags.put(RouterConstant.DUBBO_VERSION_KEY, "0.0.3");
Expand All @@ -183,6 +172,14 @@ public void testSpringV1NotMathRouteFallback() {
route.setWeight(100);
fallback.add(route);
rule.setFallback(fallback);
}

/**
* rule中设置route、fallback,且权重均有命中tag,但是invoker均未命中版本实例的情况
*/
@Test
public void testSpringV1NotMathRouteFallback() {
setFallbackRoute();

List<Object> instances = new ArrayList<>();
ServiceInstance instance1 = TestDefaultServiceInstance.getTestDefaultServiceInstance("0.0.2");
Expand All @@ -199,14 +196,7 @@ public void testSpringV1NotMathRouteFallback() {
*/
@Test
public void testSpringV1MathFallback() {
List<Route> fallback = new ArrayList<>();
Map<String, String> tags = new HashMap<>();
tags.put(RouterConstant.DUBBO_VERSION_KEY, "0.0.3");
Route route = new Route();
route.setTags(tags);
route.setWeight(100);
fallback.add(route);
rule.setFallback(fallback);
setFallbackRoute();
routes.get(0).setWeight(0);
routes.get(1).setWeight(0);

Expand All @@ -226,14 +216,7 @@ public void testSpringV1MathFallback() {
*/
@Test
public void testSpringV1BothNotMathFallbackRoute() {
List<Route> fallback = new ArrayList<>();
Map<String, String> tags = new HashMap<>();
tags.put(RouterConstant.DUBBO_VERSION_KEY, "0.0.3");
Route route = new Route();
route.setTags(tags);
route.setWeight(100);
fallback.add(route);
rule.setFallback(fallback);
setFallbackRoute();
routes.get(0).setWeight(0);
routes.get(1).setWeight(0);

Expand Down

0 comments on commit 6ef5fe1

Please sign in to comment.