You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by GitBox <gi...@apache.org> on 2022/12/05 07:09:49 UTC
[GitHub] [shenyu] tian-pengfei opened a new pull request, #4236: mock plugin supports generation of mock data on request
tian-pengfei opened a new pull request, #4236:
URL: https://github.com/apache/shenyu/pull/4236
<!-- Describe your PR here; eg. Fixes #issueNo -->
<!--
Thank you for proposing a pull request. This template will guide you through the essential steps necessary for a pull request.
-->
Make sure that:
- [x] You have read the [contribution guidelines](https://shenyu.apache.org/community/contributor-guide).
- [x] You submit test cases (unit or integration tests) that back your changes.
- [x] Your local test passed `./mvnw clean install -Dmaven.javadoc.skip=true`.
**Function Display**
+ config
![image](https://user-images.githubusercontent.com/42602026/205571164-a313a890-998a-4c22-add9-9e74eee874bc.png)
![image](https://user-images.githubusercontent.com/42602026/205571610-e5d86cb2-74ea-430e-86b3-4e4514a76878.png)
responseContent:
```tex
{
"name": ${expression|#req.json.name},
"country":${expression|#req.json.address.country},
"header_name":${expression|#req.headers[header_name]},
"method":${expression|#req.method},
"json_id":${expression|#req.json.id},
"query_id":${expression|#req.queries[id]},
"uri":${expression|#req.uri}
}
```
+ send request
![image](https://user-images.githubusercontent.com/42602026/205572582-8da41488-e683-4cbe-8579-9a9c944f0588.png)
![image](https://user-images.githubusercontent.com/42602026/205572448-2e684a87-36f0-49ab-8722-3b9dbbda5707.png)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shenyu] tian-pengfei commented on a diff in pull request #4236: [ISSUE #4235]supports generation of mock data on request
Posted by GitBox <gi...@apache.org>.
tian-pengfei commented on code in PR #4236:
URL: https://github.com/apache/shenyu/pull/4236#discussion_r1039223105
##########
shenyu-plugin/shenyu-plugin-mock/src/main/java/org/apache/shenyu/plugin/mock/generator/ExpressionGenerator.java:
##########
@@ -49,8 +47,10 @@ public String getName() {
public String doGenerate(final List<String> params, final String rule, final MockRequest mockRequest) {
String expression = params.get(0);
- CONTEXT.setVariable("req", mockRequest);
- Object val = PARSER.parseExpression(expression).getValue(CONTEXT);
+ EvaluationContext context = initContext();
Review Comment:
Generation mock data on request in multithreading is not safe, this commit slove this preoblem .but it isnt a good method .
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shenyu] codecov-commenter commented on pull request #4236: [ISSUE #4235]supports generation of mock data on request
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #4236:
URL: https://github.com/apache/shenyu/pull/4236#issuecomment-1336882059
# [Codecov](https://codecov.io/gh/apache/shenyu/pull/4236?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#4236](https://codecov.io/gh/apache/shenyu/pull/4236?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (18582f0) into [master](https://codecov.io/gh/apache/shenyu/commit/8ed89a82a7f89d3e2cc8cc8623ad34430de20131?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8ed89a8) will **decrease** coverage by `0.29%`.
> The diff coverage is `60.00%`.
```diff
@@ Coverage Diff @@
## master #4236 +/- ##
============================================
- Coverage 69.62% 69.32% -0.30%
+ Complexity 7348 7318 -30
============================================
Files 987 988 +1
Lines 27783 27826 +43
Branches 2466 2467 +1
============================================
- Hits 19344 19291 -53
- Misses 6969 7072 +103
+ Partials 1470 1463 -7
```
| [Impacted Files](https://codecov.io/gh/apache/shenyu/pull/4236?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...a/org/apache/shenyu/common/constant/Constants.java](https://codecov.io/gh/apache/shenyu/pull/4236/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hlbnl1L2NvbW1vbi9jb25zdGFudC9Db25zdGFudHMuamF2YQ==) | `66.66% <ø> (ø)` | |
| [.../org/apache/shenyu/plugin/divide/DividePlugin.java](https://codecov.io/gh/apache/shenyu/pull/4236/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LXBsdWdpbi9zaGVueXUtcGx1Z2luLWRpdmlkZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hlbnl1L3BsdWdpbi9kaXZpZGUvRGl2aWRlUGx1Z2luLmphdmE=) | `58.00% <0.00%> (-2.42%)` | :arrow_down: |
| [...java/org/apache/shenyu/plugin/mock/MockPlugin.java](https://codecov.io/gh/apache/shenyu/pull/4236/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LXBsdWdpbi9zaGVueXUtcGx1Z2luLW1vY2svc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoZW55dS9wbHVnaW4vbW9jay9Nb2NrUGx1Z2luLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...he/shenyu/plugin/mock/generator/BoolGenerator.java](https://codecov.io/gh/apache/shenyu/pull/4236/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LXBsdWdpbi9zaGVueXUtcGx1Z2luLW1vY2svc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoZW55dS9wbHVnaW4vbW9jay9nZW5lcmF0b3IvQm9vbEdlbmVyYXRvci5qYXZh) | `80.00% <ø> (ø)` | |
| [...yu/plugin/mock/generator/CurrentTimeGenerator.java](https://codecov.io/gh/apache/shenyu/pull/4236/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LXBsdWdpbi9zaGVueXUtcGx1Z2luLW1vY2svc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoZW55dS9wbHVnaW4vbW9jay9nZW5lcmF0b3IvQ3VycmVudFRpbWVHZW5lcmF0b3IuamF2YQ==) | `77.77% <ø> (ø)` | |
| [...e/shenyu/plugin/mock/generator/EmailGenerator.java](https://codecov.io/gh/apache/shenyu/pull/4236/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LXBsdWdpbi9zaGVueXUtcGx1Z2luLW1vY2svc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoZW55dS9wbHVnaW4vbW9jay9nZW5lcmF0b3IvRW1haWxHZW5lcmF0b3IuamF2YQ==) | `66.66% <ø> (ø)` | |
| [...henyu/plugin/mock/generator/EnStringGenerator.java](https://codecov.io/gh/apache/shenyu/pull/4236/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LXBsdWdpbi9zaGVueXUtcGx1Z2luLW1vY2svc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoZW55dS9wbHVnaW4vbW9jay9nZW5lcmF0b3IvRW5TdHJpbmdHZW5lcmF0b3IuamF2YQ==) | `77.77% <ø> (ø)` | |
| [...e/shenyu/plugin/mock/generator/PhoneGenerator.java](https://codecov.io/gh/apache/shenyu/pull/4236/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LXBsdWdpbi9zaGVueXUtcGx1Z2luLW1vY2svc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoZW55dS9wbHVnaW4vbW9jay9nZW5lcmF0b3IvUGhvbmVHZW5lcmF0b3IuamF2YQ==) | `83.33% <ø> (ø)` | |
| [...u/plugin/mock/generator/RandomDoubleGenerator.java](https://codecov.io/gh/apache/shenyu/pull/4236/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LXBsdWdpbi9zaGVueXUtcGx1Z2luLW1vY2svc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoZW55dS9wbHVnaW4vbW9jay9nZW5lcmF0b3IvUmFuZG9tRG91YmxlR2VuZXJhdG9yLmphdmE=) | `75.00% <ø> (ø)` | |
| [...enyu/plugin/mock/generator/RandomIntGenerator.java](https://codecov.io/gh/apache/shenyu/pull/4236/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LXBsdWdpbi9zaGVueXUtcGx1Z2luLW1vY2svc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoZW55dS9wbHVnaW4vbW9jay9nZW5lcmF0b3IvUmFuZG9tSW50R2VuZXJhdG9yLmphdmE=) | `87.50% <ø> (ø)` | |
| ... and [42 more](https://codecov.io/gh/apache/shenyu/pull/4236/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shenyu] yu199195 commented on a diff in pull request #4236: [ISSUE #4235]supports generation of mock data on request
Posted by GitBox <gi...@apache.org>.
yu199195 commented on code in PR #4236:
URL: https://github.com/apache/shenyu/pull/4236#discussion_r1040497698
##########
shenyu-plugin/shenyu-plugin-mock/src/main/java/org/apache/shenyu/plugin/mock/generator/ExpressionGenerator.java:
##########
@@ -49,8 +47,10 @@ public String getName() {
public String doGenerate(final List<String> params, final String rule, final MockRequest mockRequest) {
String expression = params.get(0);
- CONTEXT.setVariable("req", mockRequest);
- Object val = PARSER.parseExpression(expression).getValue(CONTEXT);
+ EvaluationContext context = initContext();
Review Comment:
yes~
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shenyu] yu199195 merged pull request #4236: [ISSUE #4235]supports generation of mock data on request
Posted by GitBox <gi...@apache.org>.
yu199195 merged PR #4236:
URL: https://github.com/apache/shenyu/pull/4236
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shenyu] yu199195 commented on a diff in pull request #4236: mock plugin supports generation of mock data on request
Posted by GitBox <gi...@apache.org>.
yu199195 commented on code in PR #4236:
URL: https://github.com/apache/shenyu/pull/4236#discussion_r1039221318
##########
shenyu-plugin/shenyu-plugin-mock/src/main/java/org/apache/shenyu/plugin/mock/generator/ExpressionGenerator.java:
##########
@@ -49,8 +47,10 @@ public String getName() {
public String doGenerate(final List<String> params, final String rule, final MockRequest mockRequest) {
String expression = params.get(0);
- CONTEXT.setVariable("req", mockRequest);
- Object val = PARSER.parseExpression(expression).getValue(CONTEXT);
+ EvaluationContext context = initContext();
Review Comment:
Do you need to initialize each time?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shenyu] tian-pengfei commented on a diff in pull request #4236: [ISSUE #4235]supports generation of mock data on request
Posted by GitBox <gi...@apache.org>.
tian-pengfei commented on code in PR #4236:
URL: https://github.com/apache/shenyu/pull/4236#discussion_r1039223105
##########
shenyu-plugin/shenyu-plugin-mock/src/main/java/org/apache/shenyu/plugin/mock/generator/ExpressionGenerator.java:
##########
@@ -49,8 +47,10 @@ public String getName() {
public String doGenerate(final List<String> params, final String rule, final MockRequest mockRequest) {
String expression = params.get(0);
- CONTEXT.setVariable("req", mockRequest);
- Object val = PARSER.parseExpression(expression).getValue(CONTEXT);
+ EvaluationContext context = initContext();
Review Comment:
Generation mock data on request in multithreading is not safe
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shenyu] yu199195 commented on a diff in pull request #4236: [ISSUE #4235]supports generation of mock data on request
Posted by GitBox <gi...@apache.org>.
yu199195 commented on code in PR #4236:
URL: https://github.com/apache/shenyu/pull/4236#discussion_r1040385687
##########
shenyu-plugin/shenyu-plugin-mock/src/main/java/org/apache/shenyu/plugin/mock/generator/ExpressionGenerator.java:
##########
@@ -49,8 +47,10 @@ public String getName() {
public String doGenerate(final List<String> params, final String rule, final MockRequest mockRequest) {
String expression = params.get(0);
- CONTEXT.setVariable("req", mockRequest);
- Object val = PARSER.parseExpression(expression).getValue(CONTEXT);
+ EvaluationContext context = initContext();
Review Comment:
here,no thread safety .
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shenyu] tian-pengfei commented on a diff in pull request #4236: [ISSUE #4235]supports generation of mock data on request
Posted by GitBox <gi...@apache.org>.
tian-pengfei commented on code in PR #4236:
URL: https://github.com/apache/shenyu/pull/4236#discussion_r1040442434
##########
shenyu-plugin/shenyu-plugin-mock/src/main/java/org/apache/shenyu/plugin/mock/generator/ExpressionGenerator.java:
##########
@@ -49,8 +47,10 @@ public String getName() {
public String doGenerate(final List<String> params, final String rule, final MockRequest mockRequest) {
String expression = params.get(0);
- CONTEXT.setVariable("req", mockRequest);
- Object val = PARSER.parseExpression(expression).getValue(CONTEXT);
+ EvaluationContext context = initContext();
Review Comment:
you mean ,thread safety is not required here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org