Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add operator-observability rules unit test (#1776)
* Vendor grafana/regexp package Vendor grafana/regexp package, as it's needed for the alerts and recording rules testing Signed-off-by: assafad <aadmi@redhat.com> * Add operator-observability rules unit test Add rules unit test, which ensures that alerts and recording rules definitions are following conventions. Signed-off-by: assafad <aadmi@redhat.com> --------- Signed-off-by: assafad <aadmi@redhat.com>
- Loading branch information
Showing
17 changed files
with
3,112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package rules_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestRules(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Rules Suite") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package rules_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/machadovilaca/operator-observability/pkg/testutil" | ||
|
||
"github.com/kubevirt/cluster-network-addons-operator/pkg/monitoring/rules" | ||
) | ||
|
||
var _ = Describe("Rules Validation", func() { | ||
var linter *testutil.Linter | ||
|
||
BeforeEach(func() { | ||
Expect(rules.SetupRules("")).To(Succeed()) | ||
linter = testutil.New() | ||
}) | ||
|
||
It("Should validate alerts", func() { | ||
linter.AddCustomAlertValidations( | ||
testutil.ValidateAlertNameLength, | ||
testutil.ValidateAlertRunbookURLAnnotation, | ||
testutil.ValidateAlertHealthImpactLabel, | ||
testutil.ValidateAlertPartOfAndComponentLabels) | ||
|
||
alerts := rules.ListAlerts() | ||
problems := linter.LintAlerts(alerts) | ||
Expect(problems).To(BeEmpty()) | ||
}) | ||
|
||
It("Should validate recording rules", func() { | ||
recordingRules := rules.ListRecordingRules() | ||
problems := linter.LintRecordingRules(recordingRules) | ||
Expect(problems).To(BeEmpty()) | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.