@ -16,7 +16,6 @@ package notifier
import (
import (
"bytes"
"bytes"
"context"
"context"
"crypto/md5"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
@ -467,6 +466,7 @@ alerting:
if err := yaml . UnmarshalStrict ( [ ] byte ( s ) , cfg ) ; err != nil {
if err := yaml . UnmarshalStrict ( [ ] byte ( s ) , cfg ) ; err != nil {
t . Fatalf ( "Unable to load YAML config: %s" , err )
t . Fatalf ( "Unable to load YAML config: %s" , err )
}
}
testutil . Equals ( t , 1 , len ( cfg . AlertingConfig . AlertmanagerConfigs ) )
if err := n . ApplyConfig ( cfg ) ; err != nil {
if err := n . ApplyConfig ( cfg ) ; err != nil {
t . Fatalf ( "Error Applying the config:%v" , err )
t . Fatalf ( "Error Applying the config:%v" , err )
@ -474,18 +474,16 @@ alerting:
tgs := make ( map [ string ] [ ] * targetgroup . Group )
tgs := make ( map [ string ] [ ] * targetgroup . Group )
for _ , tt := range tests {
for _ , tt := range tests {
for k := range cfg . AlertingConfig . AlertmanagerConfigs . ToMap ( ) {
b , err := json . Marshal ( cfg . AlertingConfig . AlertmanagerConfigs [ 0 ] )
tgs [ k ] = [ ] * targetgroup . Group {
if err != nil {
tt . in ,
t . Fatalf ( "Error creating config hash:%v" , err )
}
}
break
tgs [ fmt . Sprintf ( "%x" , md5 . Sum ( b ) ) ] = [ ] * targetgroup . Group {
tt . in ,
}
}
n . reload ( tgs )
n . reload ( tgs )
res := n . Alertmanagers ( ) [ 0 ] . String ( )
res := n . Alertmanagers ( ) [ 0 ] . String ( )
testutil . Equals ( t , res, tt. out )
testutil . Equals ( t , tt. out , res )
}
}
}
}
@ -522,6 +520,7 @@ alerting:
if err := yaml . UnmarshalStrict ( [ ] byte ( s ) , cfg ) ; err != nil {
if err := yaml . UnmarshalStrict ( [ ] byte ( s ) , cfg ) ; err != nil {
t . Fatalf ( "Unable to load YAML config: %s" , err )
t . Fatalf ( "Unable to load YAML config: %s" , err )
}
}
testutil . Equals ( t , 1 , len ( cfg . AlertingConfig . AlertmanagerConfigs ) )
if err := n . ApplyConfig ( cfg ) ; err != nil {
if err := n . ApplyConfig ( cfg ) ; err != nil {
t . Fatalf ( "Error Applying the config:%v" , err )
t . Fatalf ( "Error Applying the config:%v" , err )
@ -529,20 +528,18 @@ alerting:
tgs := make ( map [ string ] [ ] * targetgroup . Group )
tgs := make ( map [ string ] [ ] * targetgroup . Group )
for _ , tt := range tests {
for _ , tt := range tests {
for k := range cfg . AlertingConfig . AlertmanagerConfigs . ToMap ( ) {
b , err := json . Marshal ( cfg . AlertingConfig . AlertmanagerConfigs [ 0 ] )
tgs [ k ] = [ ] * targetgroup . Group {
if err != nil {
tt . in ,
t . Fatalf ( "Error creating config hash:%v" , err )
}
}
break
tgs [ fmt . Sprintf ( "%x" , md5 . Sum ( b ) ) ] = [ ] * targetgroup . Group {
tt . in ,
}
}
n . reload ( tgs )
n . reload ( tgs )
res := n . DroppedAlertmanagers ( ) [ 0 ] . String ( )
res := n . DroppedAlertmanagers ( ) [ 0 ] . String ( )
testutil . Equals ( t , res , tt . out )
testutil . Equals ( t , res , tt . out )
}
}
}
}
func makeInputTargetGroup ( ) * targetgroup . Group {
func makeInputTargetGroup ( ) * targetgroup . Group {