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

fix: skipped bookend ems whose key is node-name #1237

Merged
merged 5 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
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
16 changes: 11 additions & 5 deletions integration/test/alert/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ func GetEmsAlerts(dir string, fileName string) ([]EmsData, []EmsData) {
return totalEms, bookendEms
}

func GenerateEvents(emsNames []EmsData) []string {
func GenerateEvents(emsNames []EmsData, nodeScopedEms []string) []string {
supportedEms := make([]string, 0)
addr, user, pass := GetPollerDetail()
var jsonValue []byte
addr, user, pass, nodeName := GetPollerDetail()
url := "https://" + addr + "/api/private/cli/event/generate"
method := "POST"

Expand All @@ -105,7 +106,12 @@ func GenerateEvents(emsNames []EmsData) []string {
vserverArwCount++
}

jsonValue := []byte(fmt.Sprintf(`{"message-name": "%s", "values": [%s,2,3,4,5,6,7,8,9]}`, ems, value))
// Handle for node-scoped ems, Passing node-name as input
if utils.Contains(nodeScopedEms, ems) {
jsonValue = []byte(fmt.Sprintf(`{"message-name": "%s", "values": [%s,2,3,4,5,6,7,8,9]}, "node": "%s"`, ems, value, nodeName))
}

jsonValue = []byte(fmt.Sprintf(`{"message-name": "%s", "values": [%s,2,3,4,5,6,7,8,9]}`, ems, value))
var data map[string]interface{}
data = utils.SendPostReqAndGetRes(url, method, jsonValue, user, pass)
if response := data["error"]; response != nil {
Expand All @@ -123,7 +129,7 @@ func GenerateEvents(emsNames []EmsData) []string {
return supportedEms
}

func GetPollerDetail() (string, string, string) {
func GetPollerDetail() (string, string, string, string) {
var (
err error
poller *conf.Poller
Expand All @@ -137,5 +143,5 @@ func GetPollerDetail() (string, string, string) {
utils.PanicIfNotNil(err)
}

return poller.Addr, "admin", poller.Password
return poller.Addr, "admin", poller.Password, "umeng-aff300-06"
}
9 changes: 8 additions & 1 deletion integration/test/all_ems_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ var skippedEmsList = []string{
"scsitarget.fct.port.full",
}

// These bookend issuing ems are node scoped and have bookendKey as node-name only.
var nodeScopedIssuingEmsList = []string{
"callhome.battery.low",
"sp.ipmi.lost.shutdown",
"sp.notConfigured",
}

type AlertRulesTestSuite struct {
suite.Suite
}
Expand All @@ -44,7 +51,7 @@ func (suite *AlertRulesTestSuite) SetupSuite() {
totalEmsNames, _ = promAlerts.GetEmsAlerts(emsConfigDir, "ems.yaml")

// Identify supported ems names for the given cluster
supportedEms = promAlerts.GenerateEvents(totalEmsNames)
supportedEms = promAlerts.GenerateEvents(totalEmsNames, nodeScopedIssuingEmsList)
log.Info().Msgf("Total supported ems: %d", len(supportedEms))

// Fetch prometheus alerts
Expand Down
8 changes: 7 additions & 1 deletion integration/test/bookend_ems_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ var supportedEms []string
var oldAlertsData map[string]int
var newAlertsData map[string]int

// These bookend resolving ems are node scoped and have bookendKey as node-name only.
var nodeScopedResolvingEmsList = []string{
"nvram.battery.charging.normal",
"sp.heartbeat.resumed",
}

type EmsTestSuite struct {
suite.Suite
}
Expand All @@ -34,7 +40,7 @@ func (suite *EmsTestSuite) SetupSuite() {
oldAlertsData, _ = promAlerts.GetAlerts()

// Identify supported ems names for the given cluster
supportedEms = promAlerts.GenerateEvents(resolvingEmsNames)
supportedEms = promAlerts.GenerateEvents(resolvingEmsNames, nodeScopedResolvingEmsList)
log.Info().Msgf("Supported Bookend ems:%d", len(supportedEms))

// Fetch current prometheus alerts
Expand Down