Add unit tests for the custom plugin monitor - #1330
Conversation
This change adds tests for generateStatus, the monitor lifecycle and the metrics path. Package coverage increases from 0.8% to 95.3% of statements. A table test replays sequences of plugin results against one monitor. The table covers the five condition scenarios in generateStatus. Other tests cover the temporary rule path, the problem counter, the problem gauge and the constructor. This change adds no production code.
|
Hi @DigitalVeer. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: DigitalVeer 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 |
This PR bumps the unit test coverage for custom plugin monitor from 0.8% to 95.3%
This PR adds tests for
generateStatus, the monitor lifecycle and the metrics path.This is the first item of #1328.
pkg/custompluginmonitorWhat the tests check
TestGenerateStatusForConditionsreplays plugin resultsagainst one monitor and checks the condition and the event after each step for five scenarios.
TestGenerateStatusForTemporaryProblemchecks that a temporary rule creates an event andmoves no condition.
TestGenerateStatusMetricschecks the problem counter and the problem gauge through theexisting metrics stub. The counter increments for new problems only.
TestMonitorLoopReportsPluginResultsandTestMonitorLoopExitsWhenResultChannelClosescheck the goroutine lifecycle.
Stopmust return. A closed result channel must end theloop.
TestNewCustomPluginMonitorOrDiewrites a config file and checks that the constructorapplies the defaults.
The lifecycle tests use the plugin scripts in
pkg/custompluginmonitor/plugin/test-data.Validation
go test -cover ./pkg/custompluginmonitor/go test -timeout=1m -race -short -count=5golangci-lint run --config .golangci.yml