Skip to content

Commit

Permalink
fix: 修改motan插件的e2e测试
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmXu committed Dec 29, 2023
1 parent ac92bb4 commit 07918b1
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,16 @@ public class MotanPluginCases implements ShenYuScenarioProvider {

@Override
public List<ScenarioSpec> get() {
return new ArrayList<>();
// return Lists.newArrayList(
// testWithUriEquals()
//// testWithUriPathPattern(),
//// testWithUriStartWith(),
//// testWithEndWith(),
//// testWithMethodGet(),
//// testWithMethodPost(),
//// testWithMethodPut(),
//// testWithMethodDelete()
// );
return Lists.newArrayList(
testWithUriEquals()
// testWithUriPathPattern(),
// testWithUriStartWith(),
// testWithEndWith(),
// testWithMethodGet(),
// testWithMethodPost(),
// testWithMethodPut(),
// testWithMethodDelete()
);
}

/**
Expand All @@ -68,26 +67,26 @@ public ShenYuScenarioSpec testWithUriEquals() {
ShenYuBeforeEachSpec.builder()
.addSelectorAndRule(
newSelectorBuilder("selector", Plugin.MOTAN)
.conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hello"))
.conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hi"))
.build(),
newRuleBuilder("rule")
.conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hello"))
.conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hi"))
.handle(DivideRuleHandle.builder().timeout(100000).retry(10).build())
.build()
)
.checker(notExists("/motan/demo/hello"))
.waiting(exists("/motan/demo/hello"))
.checker(notExists("/motan/demo/hi"))
.waiting(exists("/motan/demo/hi"))
.build()
)
.caseSpec(
ShenYuCaseSpec.builder()
.addExists("/motan/demo/hello")
.addExists("/motan/demo/hi")
.addNotExists("/motan/demo/h")
.addNotExists("/put")
.addNotExists("/get")
.build()
)
.afterEachSpec(ShenYuAfterEachSpec.builder().deleteWaiting(notExists("/motan/demo/hello")).build())
.afterEachSpec(ShenYuAfterEachSpec.builder().deleteWaiting(notExists("/motan/demo/hi")).build())
.build();
}

Expand All @@ -109,18 +108,18 @@ public ShenYuScenarioSpec testWithUriPathPattern() {
.conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.PATH_PATTERN, "/motan/demo/**"))
.build()
)
.checker(notExists("/motan/demo/hello"))
.waiting(exists("/motan/demo/hello"))
.checker(notExists("/motan/demo/hi"))
.waiting(exists("/motan/demo/hi"))
.build()
).caseSpec(
ShenYuCaseSpec.builder()
.addExists("/motan/demo/hello")
.addExists("/motan/demo/hi")
.addNotExists("/motan/de")
.addExists(Method.POST, "/motan/demo/hello")
.addExists(Method.PUT, "/motan/demo/hello")
.addExists(Method.DELETE, "/motan/demo/hello")
.addExists(Method.POST, "/motan/demo/hi")
.addExists(Method.PUT, "/motan/demo/hi")
.addExists(Method.DELETE, "/motan/demo/hi")
.build())
.afterEachSpec(ShenYuAfterEachSpec.builder().deleteWaiting(notExists("/motan/demo/hello")).build())
.afterEachSpec(ShenYuAfterEachSpec.builder().deleteWaiting(notExists("/motan/demo/hi")).build())
.build();
}

Expand All @@ -142,19 +141,19 @@ public ShenYuScenarioSpec testWithUriStartWith() {
.conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.STARTS_WITH, "/motan/"))
.build()
)
.checker(notExists("/motan/demo/hello"))
.waiting(exists("/motan/demo/hello"))
.checker(notExists("/motan/demo/hi"))
.waiting(exists("/motan/demo/hi"))
.build()
)
.caseSpec(
ShenYuCaseSpec.builder()
.addExists("/motan/demo/hello")
.addExists("/motan/demo/hi")
.addNotExists("/mota/")
.addExists(Method.POST, "/motan/demo/hello")
.addExists(Method.PUT, "/motan/demo/hello")
.addExists(Method.DELETE, "/motan/demo/hello")
.addExists(Method.POST, "/motan/demo/hi")
.addExists(Method.PUT, "/motan/demo/hi")
.addExists(Method.DELETE, "/motan/demo/hi")
.build())
.afterEachSpec(ShenYuAfterEachSpec.builder().deleteWaiting(notExists("/motan/demo/hello")).build())
.afterEachSpec(ShenYuAfterEachSpec.builder().deleteWaiting(notExists("/motan/demo/hi")).build())
.build();
}

Expand All @@ -176,19 +175,19 @@ public ShenYuScenarioSpec testWithEndWith() {
.conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.ENDS_WITH, "/hi"))
.build()
)
.checker(notExists("/motan/demo/hello"))
.waiting(exists("/motan/demo/hello"))
.checker(notExists("/motan/demo/hi"))
.waiting(exists("/motan/demo/hi"))
.build()
)
.caseSpec(
ShenYuCaseSpec.builder()
.addExists("/motan/demo/hello")
.addExists("/motan/demo/hi")
.addNotExists("/motan/demo/h")
.addExists(Method.POST, "/motan/demo/hello")
.addExists(Method.PUT, "/motan/demo/hello")
.addExists(Method.DELETE, "/motan/demo/hello")
.addExists(Method.POST, "/motan/demo/hi")
.addExists(Method.PUT, "/motan/demo/hi")
.addExists(Method.DELETE, "/motan/demo/hi")
.build())
.afterEachSpec(ShenYuAfterEachSpec.builder().deleteWaiting(notExists("/motan/demo/hello")).build())
.afterEachSpec(ShenYuAfterEachSpec.builder().deleteWaiting(notExists("/motan/demo/hi")).build())
.build();
}

Expand All @@ -206,29 +205,29 @@ public ShenYuScenarioSpec testWithMethodGet() {
newSelectorBuilder("selector", Plugin.MOTAN)
.conditionList(Lists.newArrayList(
newCondition(Condition.ParamType.METHOD, Condition.Operator.EQUAL, "GET"),
newCondition(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hello")
newCondition(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hi")
))
.build(),
newRuleBuilder("rule")
.conditionList(Lists.newArrayList(
newCondition(Condition.ParamType.METHOD, Condition.Operator.EQUAL, "GET"),
newCondition(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hello")
newCondition(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hi")
))
.build()
)
.checker(notExists(Method.GET, "/motan/demo/hello"))
.waiting(exists(Method.GET, "/motan/demo/hello"))
.checker(notExists(Method.GET, "/motan/demo/hi"))
.waiting(exists(Method.GET, "/motan/demo/hi"))
.build()
)
.caseSpec(
ShenYuCaseSpec.builder()
.addExists(Method.GET, "/motan/demo/hello")
.addExists(Method.GET, "/motan/demo/hi")
.addNotExists(Method.GET, "/motan/demo/h")
.addNotExists(Method.POST, "/motan/demo/hello")
.addNotExists(Method.PUT, "/motan/demo/hello")
.addNotExists(Method.DELETE, "/motan/demo/hello")
.addNotExists(Method.POST, "/motan/demo/hi")
.addNotExists(Method.PUT, "/motan/demo/hi")
.addNotExists(Method.DELETE, "/motan/demo/hi")
.build())
.afterEachSpec(ShenYuAfterEachSpec.builder().deleteWaiting(notExists(Method.GET, "/motan/demo/hello")).build())
.afterEachSpec(ShenYuAfterEachSpec.builder().deleteWaiting(notExists(Method.GET, "/motan/demo/hi")).build())
.build();
}

Expand All @@ -246,29 +245,29 @@ public ShenYuScenarioSpec testWithMethodPost() {
newSelectorBuilder("selector", Plugin.MOTAN)
.conditionList(Lists.newArrayList(
newCondition(Condition.ParamType.METHOD, Condition.Operator.EQUAL, "POST"),
newCondition(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hello")
newCondition(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hi")
))
.build(),
newRuleBuilder("rule")
.conditionList(Lists.newArrayList(
newCondition(Condition.ParamType.METHOD, Condition.Operator.EQUAL, "POST"),
newCondition(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hello")
newCondition(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hi")
))
.build()
)
.checker(notExists(Method.POST, "/motan/demo/hello"))
.waiting(exists(Method.POST, "/motan/demo/hello"))
.checker(notExists(Method.POST, "/motan/demo/hi"))
.waiting(exists(Method.POST, "/motan/demo/hi"))
.build()
)
.caseSpec(
ShenYuCaseSpec.builder()
.addExists(Method.POST, "/motan/demo/hello")
.addExists(Method.POST, "/motan/demo/hi")
.addNotExists(Method.POST, "/motan/demo/h")
.addNotExists(Method.GET, "/motan/demo/hello")
.addNotExists(Method.PUT, "/motan/demo/hello")
.addNotExists(Method.DELETE, "/motan/demo/hello")
.addNotExists(Method.GET, "/motan/demo/hi")
.addNotExists(Method.PUT, "/motan/demo/hi")
.addNotExists(Method.DELETE, "/motan/demo/hi")
.build())
.afterEachSpec(ShenYuAfterEachSpec.builder().deleteWaiting(notExists(Method.POST, "/motan/demo/hello")).build())
.afterEachSpec(ShenYuAfterEachSpec.builder().deleteWaiting(notExists(Method.POST, "/motan/demo/hi")).build())
.build();
}

Expand All @@ -286,29 +285,29 @@ public ShenYuScenarioSpec testWithMethodPut() {
newSelectorBuilder("selector", Plugin.MOTAN)
.conditionList(Lists.newArrayList(
newCondition(Condition.ParamType.METHOD, Condition.Operator.EQUAL, "PUT"),
newCondition(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hello")
newCondition(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hi")
))
.build(),
newRuleBuilder("rule")
.conditionList(Lists.newArrayList(
newCondition(Condition.ParamType.METHOD, Condition.Operator.EQUAL, "PUT"),
newCondition(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hello")
newCondition(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hi")
))
.build()
)
.checker(notExists(Method.PUT, "/motan/demo/hello"))
.waiting(exists(Method.PUT, "/motan/demo/hello"))
.checker(notExists(Method.PUT, "/motan/demo/hi"))
.waiting(exists(Method.PUT, "/motan/demo/hi"))
.build()
)
.caseSpec(
ShenYuCaseSpec.builder()
.addExists(Method.PUT, "/motan/demo/hello")
.addExists(Method.PUT, "/motan/demo/hi")
.addNotExists(Method.PUT, "/motan/demo/h")
.addNotExists(Method.GET, "/motan/demo/hello")
.addNotExists(Method.POST, "/motan/demo/hello")
.addNotExists(Method.DELETE, "/motan/demo/hello")
.addNotExists(Method.GET, "/motan/demo/hi")
.addNotExists(Method.POST, "/motan/demo/hi")
.addNotExists(Method.DELETE, "/motan/demo/hi")
.build())
.afterEachSpec(ShenYuAfterEachSpec.builder().deleteWaiting(notExists(Method.PUT, "/motan/demo/hello")).build())
.afterEachSpec(ShenYuAfterEachSpec.builder().deleteWaiting(notExists(Method.PUT, "/motan/demo/hi")).build())
.build();
}

Expand All @@ -327,29 +326,29 @@ public ShenYuScenarioSpec testWithMethodDelete() {
newSelectorBuilder("selector", Plugin.MOTAN)
.conditionList(Lists.newArrayList(
newCondition(Condition.ParamType.METHOD, Condition.Operator.EQUAL, "DELETE"),
newCondition(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hello")
newCondition(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hi")
))
.build(),
newRuleBuilder("rule")
.conditionList(Lists.newArrayList(
newCondition(Condition.ParamType.METHOD, Condition.Operator.EQUAL, "DELETE"),
newCondition(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hello")
newCondition(Condition.ParamType.URI, Condition.Operator.EQUAL, "/motan/demo/hi")
))
.build()
)
.checker(notExists(Method.DELETE, "/motan/demo/hello"))
.waiting(exists(Method.DELETE, "/motan/demo/hello"))
.checker(notExists(Method.DELETE, "/motan/demo/hi"))
.waiting(exists(Method.DELETE, "/motan/demo/hi"))
.build()
)
.caseSpec(
ShenYuCaseSpec.builder()
.addExists(Method.DELETE, "/motan/demo/hello")
.addExists(Method.DELETE, "/motan/demo/hi")
.addNotExists(Method.DELETE, "/motan/demo/h")
.addNotExists(Method.GET, "/motan/demo/hello")
.addNotExists(Method.POST, "/motan/demo/hello")
.addNotExists(Method.PUT, "/motan/demo/hello")
.addNotExists(Method.GET, "/motan/demo/hi")
.addNotExists(Method.POST, "/motan/demo/hi")
.addNotExists(Method.PUT, "/motan/demo/hi")
.build())
.afterEachSpec(ShenYuAfterEachSpec.builder().deleteWaiting(notExists(Method.DELETE, "/motan/demo/hello")).build())
.afterEachSpec(ShenYuAfterEachSpec.builder().deleteWaiting(notExists(Method.DELETE, "/motan/demo/hi")).build())
.build();
}
}
Loading

0 comments on commit 07918b1

Please sign in to comment.