-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
Test for etcd metrics #19242
Test for etcd metrics #19242
Conversation
Hi @dims. Thanks for your PR. I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted filessee 25 files with indirect coverage changes @@ Coverage Diff @@
## main #19242 +/- ##
==========================================
+ Coverage 68.77% 68.81% +0.04%
==========================================
Files 420 420
Lines 35649 35675 +26
==========================================
+ Hits 24518 24551 +33
+ Misses 9705 9699 -6
+ Partials 1426 1425 -1 Continue to review full report in Codecov by Sentry.
|
Can we first merge the test? |
The test should be an independent change. We should finish & merge the test firstly. Afterwards, you need to rebase #19195. I think you just need to start an etcd instance (and probably write a couple of key/values), then get all the metrics using /metrics endpoint. Please refer to https://github.com/ahrtr/etcd-diagnosis/blob/main/plugins/metrics/plugin.go |
f55b375
to
040fbaa
Compare
040fbaa
to
9a2cb80
Compare
@serathius @ahrtr updated this PR, this can go first. 3 metrics are not captured currently in this test (see notes in PR text). When i update the other PR will get added. |
srv := &http.Server{Handler: promhttp.Handler()} | ||
srv.SetKeepAlivesEnabled(false) | ||
|
||
ln, err := transport.NewUnixListener(addr) | ||
if err != nil { | ||
t.Errorf("Error: %v occurred while listening on addr: %v", err, addr) | ||
} | ||
|
||
donec := make(chan struct{}) | ||
defer func() { | ||
ln.Close() | ||
<-donec | ||
}() | ||
|
||
// listen for all Prometheus metrics | ||
go func() { | ||
defer close(donec) | ||
|
||
serr := srv.Serve(ln) | ||
if serr != nil && !transport.IsClosedConnError(serr) { | ||
t.Errorf("Err serving http requests: %v", serr) | ||
} | ||
}() | ||
|
||
url := "unix://" + addr + "/metrics" |
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.
Thinking whether e2e test here would better, more accurate and would not require this custom code. But don't want to block on it.
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 getMetricsList(t *testing.T, url string) []string { |
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.
FYI "github.com/prometheus/common/expfmt" is package has a parser for metrics. Example usage https://github.com/kubernetes-sigs/metrics-server/blob/0dcee07ea614e8354ec740dfc3f528a572cacec4/test/e2e_test.go#L315-L329
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.
@serathius I will update the implementation of this test as suggested in the other PR when i rebase!
This PR follows the existing integration test cases. I am not sure how other maintainers think, but personally I don't think the existing integration tests on metrics (see below) are appropriate,
For integration test, I think it would be better to simulate the embedded use case (start etcd by calling Line 110 in 2471e41
Ideally, we should test etcd as a black box, so e2e test is much better. If we test it in integrate test, we should start etcd via Of course, it's not this PR's problem. So I am OK to let this PR in and we can discuss it separately and probably add an e2e test separately. |
thanks @ahrtr ! |
/ok-to-test |
@dims: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/ok-to-test |
Signed-off-by: Davanum Srinivas <[email protected]>
9a2cb80
to
19d405c
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahrtr, dims, serathius The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Test ONLY change to ensure #19195 does not cause a regression.
NOTE: the following 3 metrics are NOT listed here as there is no way for us to thread in
"extensive"
metrics in current tests suite. #19195 has the changes needed for that. So when we update that PR, we will add these metrics as the PR has the changes for updating the tests suite.