chore: add SetupServer unit tests - #4021
Conversation
Signed-off-by: Neel Kumar <neelkumar247me@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Signed-off-by: Neel Kumar <neelkumar247me@gmail.com>
There was a problem hiding this comment.
Thanks @neelkumar01 for adding coverage for SetupServer; this area needs tests because it controls metrics exposure, TLS, and authentication.
I think one important issue should be addressed before approval. The insecure, secure, authentication-enabled, and unspecified-SecureServing cases all assert only whether manager.Add was called. Removing the TLS configuration, forcing SecureServing to false, or removing FilterProvider would still leave these tests passing.
Could we extract construction of metricsserver.Options into a small testable helper, or inject/capture the server constructor, and assert SecureServing, BindAddress, CertDir, TLSOpts, and FilterProvider directly? The registration tests can then remain focused on disabled-server behavior and manager error propagation.
Please also assert the identity of the manager.Add error with errors.Is rather than checking only that some error was returned.
One additional question: configuration defaulting sets SecureServing to true, while direct nil input to SetupServer is interpreted as false. The nil test should explicitly document and verify whichever behavior is intended.
With these changes, this would provide meaningful regression protection rather than primarily increasing line coverage.
ArshVermaGit
left a comment
There was a problem hiding this comment.
the PR adds tests only, but the required lgtm approval is still missing.
What this PR does / why we need it:
This PR adds unit tests for
pkg/metrics/setup.goto verify the behavior ofSetupServerThe tests cover:
SecureServingis not specifiedBindAddressis set to"0"These tests improve coverage for the metrics server setup logic and help ensure that future changes do not break its expected behavior
Notes
Which issue(s) this PR fixes:
Fixes #4019
Checklist: