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 5a979de commit 824bfcb
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 272 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.apache.shenyu.e2e.testcase.motan;

import com.google.common.collect.Lists;
import io.restassured.http.Method;
import org.apache.shenyu.e2e.engine.scenario.ShenYuScenarioProvider;
import org.apache.shenyu.e2e.engine.scenario.specification.ScenarioSpec;
import org.apache.shenyu.e2e.engine.scenario.specification.ShenYuAfterEachSpec;
Expand All @@ -33,7 +32,6 @@

import static org.apache.shenyu.e2e.engine.scenario.function.HttpCheckers.exists;
import static org.apache.shenyu.e2e.engine.scenario.function.HttpCheckers.notExists;
import static org.apache.shenyu.e2e.template.ResourceDataTemplate.newCondition;
import static org.apache.shenyu.e2e.template.ResourceDataTemplate.newConditions;
import static org.apache.shenyu.e2e.template.ResourceDataTemplate.newRuleBuilder;
import static org.apache.shenyu.e2e.template.ResourceDataTemplate.newSelectorBuilder;
Expand All @@ -44,13 +42,6 @@ public class MotanPluginCases implements ShenYuScenarioProvider {
public List<ScenarioSpec> get() {
return Lists.newArrayList(
testWithUriEquals()
// testWithUriPathPattern(),
// testWithUriStartWith(),
// testWithEndWith(),
// testWithMethodGet(),
// testWithMethodPost(),
// testWithMethodPut(),
// testWithMethodDelete()
);
}

Expand Down Expand Up @@ -88,266 +79,4 @@ public ShenYuScenarioSpec testWithUriEquals() {
.afterEachSpec(ShenYuAfterEachSpec.builder().deleteWaiting(notExists("/motan/demo/hi")).build())
.build();
}

/**
* test with uri path pattern.
*
* @return ShenYuScenarioSpec
*/
public ShenYuScenarioSpec testWithUriPathPattern() {
return ShenYuScenarioSpec.builder()
.name("single-motan uri path_pattern]")
.beforeEachSpec(
ShenYuBeforeEachSpec.builder()
.addSelectorAndRule(
newSelectorBuilder("selector", Plugin.MOTAN)
.conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.PATH_PATTERN, "/motan/demo/**"))
.build(),
newRuleBuilder("rule")
.conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.PATH_PATTERN, "/motan/demo/**"))
.build()
)
.checker(notExists("/motan/demo/hi"))
.waiting(exists("/motan/demo/hi"))
.build()
).caseSpec(
ShenYuCaseSpec.builder()
.addExists("/motan/demo/hi")
.addNotExists("/motan/de")
.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/hi")).build())
.build();
}

/**
* test with uri start with.
*
* @return ShenYuScenarioSpec
*/
public ShenYuScenarioSpec testWithUriStartWith() {
return ShenYuScenarioSpec.builder()
.name("single-motan uri starts_with]")
.beforeEachSpec(
ShenYuBeforeEachSpec.builder()
.addSelectorAndRule(
newSelectorBuilder("selector", Plugin.MOTAN)
.conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.STARTS_WITH, "/motan/"))
.build(),
newRuleBuilder("rule")
.conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.STARTS_WITH, "/motan/"))
.build()
)
.checker(notExists("/motan/demo/hi"))
.waiting(exists("/motan/demo/hi"))
.build()
)
.caseSpec(
ShenYuCaseSpec.builder()
.addExists("/motan/demo/hi")
.addNotExists("/mota/")
.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/hi")).build())
.build();
}

/**
* test with uri end with.
*
* @return ShenYuScenarioSpec
*/
public ShenYuScenarioSpec testWithEndWith() {
return ShenYuScenarioSpec.builder()
.name("single-motan uri ends_with]")
.beforeEachSpec(
ShenYuBeforeEachSpec.builder()
.addSelectorAndRule(
newSelectorBuilder("selector", Plugin.MOTAN)
.conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.ENDS_WITH, "/hi"))
.build(),
newRuleBuilder("rule")
.conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.ENDS_WITH, "/hi"))
.build()
)
.checker(notExists("/motan/demo/hi"))
.waiting(exists("/motan/demo/hi"))
.build()
)
.caseSpec(
ShenYuCaseSpec.builder()
.addExists("/motan/demo/hi")
.addNotExists("/motan/demo/h")
.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/hi")).build())
.build();
}

/**
* test with uri method get.
*
* @return ShenYuScenarioSpec
*/
public ShenYuScenarioSpec testWithMethodGet() {
return ShenYuScenarioSpec.builder()
.name("single-motan uri method GET]")
.beforeEachSpec(
ShenYuBeforeEachSpec.builder()
.addSelectorAndRule(
newSelectorBuilder("selector", Plugin.MOTAN)
.conditionList(Lists.newArrayList(
newCondition(Condition.ParamType.METHOD, Condition.Operator.EQUAL, "GET"),
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/hi")
))
.build()
)
.checker(notExists(Method.GET, "/motan/demo/hi"))
.waiting(exists(Method.GET, "/motan/demo/hi"))
.build()
)
.caseSpec(
ShenYuCaseSpec.builder()
.addExists(Method.GET, "/motan/demo/hi")
.addNotExists(Method.GET, "/motan/demo/h")
.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/hi")).build())
.build();
}

/**
* test with uri method post.
*
* @return ShenYuScenarioSpec
*/
public ShenYuScenarioSpec testWithMethodPost() {
return ShenYuScenarioSpec.builder()
.name("single-motan uri method POST]")
.beforeEachSpec(
ShenYuBeforeEachSpec.builder()
.addSelectorAndRule(
newSelectorBuilder("selector", Plugin.MOTAN)
.conditionList(Lists.newArrayList(
newCondition(Condition.ParamType.METHOD, Condition.Operator.EQUAL, "POST"),
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/hi")
))
.build()
)
.checker(notExists(Method.POST, "/motan/demo/hi"))
.waiting(exists(Method.POST, "/motan/demo/hi"))
.build()
)
.caseSpec(
ShenYuCaseSpec.builder()
.addExists(Method.POST, "/motan/demo/hi")
.addNotExists(Method.POST, "/motan/demo/h")
.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/hi")).build())
.build();
}

/**
* test with uri method put.
*
* @return ShenYuScenarioSpec
*/
public ShenYuScenarioSpec testWithMethodPut() {
return ShenYuScenarioSpec.builder()
.name("single-motan uri method PUT]")
.beforeEachSpec(
ShenYuBeforeEachSpec.builder()
.addSelectorAndRule(
newSelectorBuilder("selector", Plugin.MOTAN)
.conditionList(Lists.newArrayList(
newCondition(Condition.ParamType.METHOD, Condition.Operator.EQUAL, "PUT"),
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/hi")
))
.build()
)
.checker(notExists(Method.PUT, "/motan/demo/hi"))
.waiting(exists(Method.PUT, "/motan/demo/hi"))
.build()
)
.caseSpec(
ShenYuCaseSpec.builder()
.addExists(Method.PUT, "/motan/demo/hi")
.addNotExists(Method.PUT, "/motan/demo/h")
.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/hi")).build())
.build();
}


/**
* test with uri method delete.
*
* @return ShenYuScenarioSpec
*/
public ShenYuScenarioSpec testWithMethodDelete() {
return ShenYuScenarioSpec.builder()
.name("single-motan uri method DELETE]")
.beforeEachSpec(
ShenYuBeforeEachSpec.builder()
.addSelectorAndRule(
newSelectorBuilder("selector", Plugin.MOTAN)
.conditionList(Lists.newArrayList(
newCondition(Condition.ParamType.METHOD, Condition.Operator.EQUAL, "DELETE"),
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/hi")
))
.build()
)
.checker(notExists(Method.DELETE, "/motan/demo/hi"))
.waiting(exists(Method.DELETE, "/motan/demo/hi"))
.build()
)
.caseSpec(
ShenYuCaseSpec.builder()
.addExists(Method.DELETE, "/motan/demo/hi")
.addNotExists(Method.DELETE, "/motan/demo/h")
.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/hi")).build())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ GET http://localhost:9195/motan/demo/hi
Accept: application/json
Content-Type: application/json


### shengyu getway proxy hello
GET http://localhost:9195/motan/demo/hello
Accept: application/json
Expand Down

0 comments on commit 824bfcb

Please sign in to comment.