-
Notifications
You must be signed in to change notification settings - Fork 542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: storage grafana path in to etcd #2362
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2362 +/- ##
==========================================
- Coverage 69.75% 64.51% -5.25%
==========================================
Files 184 58 -126
Lines 7284 3965 -3319
Branches 832 0 -832
==========================================
- Hits 5081 2558 -2523
+ Misses 1907 1044 -863
- Partials 296 363 +67
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Frontend e2e test error, pls rerun thx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the front-end should also support it.
Frontend e2e test error, pls rerun thx |
@bzp2010 have a check, thx |
api/conf/schema.json
Outdated
@@ -3022,6 +3022,34 @@ | |||
"upstream_hash_vars_schema": { | |||
"pattern": "^((uri|server_name|server_addr|request_uri|remote_port|remote_addr|query_string|host|hostname)|arg_[0-9a-zA-z_-]+)$", | |||
"type": "string" | |||
}, | |||
"system_config":{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to add a schema for this, this file will only be exported by the APISIX control API. The model looks simple and we check it manually when we modify the data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at this issue, schema.json will be automatically generated by control API only, if we add it manually, it will be difficult to maintain. Do you have any suggestion?
@jwrookie I think the comment only needs to be resolved
by the reviewer himself, if it is always closed by your, other reviewers will not be aware of the progress of the review and existing problems. This time I didn't notice this review. 😂
@nic-chen Please take a look at this issue, schema.json
will be automatically generated by control API only, if we add it manually, it will be difficult to maintain. Do you have any suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, I handled it the wrong way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bzp2010
good catch!
we could put the schema into another file, and when the Manager API starts, we need to merge its content into schema.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be happy to do it by other pr
"github.com/apisix/manager-api/internal/core/store" | ||
) | ||
|
||
func TestSystem_Get(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, we can remove these meaningless test cases, just keep only the E2E test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the unit test is also required, it can quickly detect coding problems
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func TestStructUnmarshal(t *testing.T) { | |
// define and parse data | |
jsonStr := `{ | |
"id": 1, | |
"create_time": 1700000000, | |
"update_time": 1700000000, | |
"desc": "desc", | |
"remote_addr": "1.1.1.1", | |
"server_addr": "2.2.2.2", | |
"server_port": 9080, | |
"sni": "example.com", | |
"upstream": { | |
"nodes": [ | |
{ | |
"host": "10.10.10.10", | |
"port": 8080, | |
"weight": 1 | |
} | |
], | |
"type": "roundrobin", | |
"scheme": "http", | |
"pass_host": "pass" | |
}, | |
"upstream_id": 1 | |
}` | |
streamRoute := entity.StreamRoute{} | |
err := json.Unmarshal([]byte(jsonStr), &streamRoute) | |
// asserts | |
assert.Nil(t, err) | |
assert.Equal(t, streamRoute.ID, float64(1)) | |
assert.Equal(t, streamRoute.CreateTime, int64(1700000000)) | |
assert.Equal(t, streamRoute.UpdateTime, int64(1700000000)) | |
assert.Equal(t, streamRoute.Desc, "desc") | |
assert.Equal(t, streamRoute.RemoteAddr, "1.1.1.1") | |
assert.Equal(t, streamRoute.ServerAddr, "2.2.2.2") | |
assert.Equal(t, streamRoute.ServerPort, 9080) | |
assert.Equal(t, streamRoute.SNI, "example.com") | |
assert.Equal(t, streamRoute.UpstreamID, float64(1)) | |
assert.NotNil(t, streamRoute.Upstream) | |
} |
You can take a look at these, I don't think it makes sense to run these tests through Mock, but unit tests can be used such as data unmarshal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean get
needs to test data unmarshal, the other operations remain unchanged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, the current use cases like Get
Put
use mock storage to test, which doesn't make a lot of sense because mock doesn't have its own storage features like in-memory, etc (We also don't know if the handler is actually working properly, because the input and output are provided by the developer code). The storage layer that is really being used will be tested in full in E2E, in unit we just do some other trivial work.
This is my own idea, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx for your reply!
I think that only the data layer would use mock instead, and the unit test can walk through the handle logic, so it makes sense.
Maybe it's because the handle very simple and you think it doesn't make sense? if that's the case, I take your advice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, most unit test cases are the same and meaningless, you could have a look at unit test cases of other handlers, they are almost the same.
We should focus on tests that are not covered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and the unit test can walk through the handling logic, so it makes sense.
I think we can keep it, even if the logic is very simple and doesn't make sense.
Once the handle contains complex logic, the effect will be obvious.
Oh, please use JSON schema to verify, not hard code, unless it can't use JSON schema
BTW, pls rerun the front e2e test ,thx |
finally, this feature come into the reality |
Please answer these questions before submitting a pull request, or your PR will get closed.
Why submit this pull request?
What changes will this PR take into?
storage grafana path in to etcd
Related issues
fix/resolve #1953
Checklist: