Skip to content
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

ci: test 1 non-bookend ems in ci #1971

Merged
merged 1 commit into from
Apr 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 9 additions & 25 deletions integration/test/nonbookend_ems_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,17 @@ import (
"testing"
)

var nonBookendEmsNames []string
var supportedNonBookendEms []string
var alertsData map[string]int

// These EMS events are node scoped, and are not always raised from ONTAP, even when simulated via POST call.
var skippedEmsList = []string{
"callhome.hainterconnect.down",
"fabricpool.full",
"fabricpool.nearly.full",
"Nblade.cifsNoPrivShare",
"Nblade.nfsV4PoolExhaust",
"Nblade.vscanBadUserPrivAccess",
"Nblade.vscanNoRegdScanner",
"Nblade.vscanConnInactive",
"cloud.aws.iamNotInitialized",
"scsitarget.fct.port.full",
}

func setup() {
totalAlerts := 0
emsConfigDir := utils.GetHarvestRootDir() + "/conf/ems/9.6.0"
log.Info().Str("EmsConfigDir", emsConfigDir).Msg("Directory path")

// Fetch non-bookend ems configured in template
nonBookendEmsNames, _, _ = promAlerts.GetEmsAlerts(emsConfigDir, "ems.yaml")
// testing this non-bookend ems in CI
var nonBookendEmsName = []string{"wafl.vol.autoSize.done"}

// Identify supported non-bookend ems names for the given cluster
supportedNonBookendEms = promAlerts.GenerateEvents(nonBookendEmsNames, []string{})
log.Info().Msgf("Total supported non-bookend ems: %d", len(supportedNonBookendEms))
// Check if non-bookend ems name is supported for the given cluster
supportedNonBookendEms = promAlerts.GenerateEvents(nonBookendEmsName, []string{})
log.Info().Msgf("Supported non-bookend ems: %s", supportedNonBookendEms)

// Fetch prometheus alerts
alertsData, totalAlerts = promAlerts.GetAlerts()
Expand All @@ -53,12 +35,14 @@ func TestAlertRules(t *testing.T) {
notFoundNonBookendEms := make([]string, 0)

for _, nonBookendEms := range supportedNonBookendEms {
if !(alertsData[nonBookendEms] != 0 || utils.Contains(skippedEmsList, nonBookendEms)) {
if alertsData[nonBookendEms] == 0 {
notFoundNonBookendEms = append(notFoundNonBookendEms, nonBookendEms)
}
}
if len(notFoundNonBookendEms) > 0 {
log.Error().Strs("notFoundNonBookendEms", notFoundNonBookendEms).Msg("Expected all to be found")
t.Errorf("One or more ems alerts %s have not been raised", notFoundNonBookendEms)
t.Errorf("Ems alerts %s have not been raised", notFoundNonBookendEms)
} else {
log.Info().Msg("Non bookend ems test passed")
}
}