@ -134,17 +134,17 @@ func TestAddAutogenConfig(t *testing.T) {
MuteTimeIntervals : [ ] string { "maintenance" } ,
} ) ,
withChildRoutes ( basicContactRoute ( "receiver1" ) , & definitions . Route {
Receiver : "receiver1" ,
ObjectMatchers : matcher ( models . AutogeneratedRouteSettingsHashLabel , "dde34b8127e68f31" ) ,
GroupInterval : util . Pointer ( model . Duration ( 1 * time . Minute ) ) ,
} , & definitions . Route {
Receiver : "receiver1" ,
ObjectMatchers : matcher ( models . AutogeneratedRouteSettingsHashLabel , "ed4038c5d6733607 " ) ,
GroupByStr : [ ] string { model . AlertNameLabel , models . FolderTitl eLabel, "custom" } ,
ObjectMatchers : matcher ( models . AutogeneratedRouteSettingsHashLabel , "4f095749ddf3eeeb" ) ,
GroupByStr : [ ] string { models . FolderTitleLabel , model . AlertNameLabel , "custom" } ,
GroupInterval : util . Pointer ( model . Duration ( 1 * time . Minute ) ) ,
GroupWait : util . Pointer ( model . Duration ( 2 * time . Minute ) ) ,
RepeatInterval : util . Pointer ( model . Duration ( 3 * time . Minute ) ) ,
MuteTimeIntervals : [ ] string { "maintenance" } ,
} , & definitions . Route {
Receiver : "receiver1" ,
ObjectMatchers : matcher ( models . AutogeneratedRouteSettingsHashLabel , "dde34b8127e68f31" ) ,
GroupInterval : util . Pointer ( model . Duration ( 1 * time . Minute ) ) ,
} ) ,
withChildRoutes ( basicContactRoute ( "receiver2" ) , & definitions . Route {
Receiver : "receiver2" ,
@ -153,8 +153,8 @@ func TestAddAutogenConfig(t *testing.T) {
} ) ,
withChildRoutes ( basicContactRoute ( "receiver4" ) , & definitions . Route {
Receiver : "receiver4" ,
ObjectMatchers : matcher ( models . AutogeneratedRouteSettingsHashLabel , "5e5ab8d592b12e86 " ) ,
GroupByStr : [ ] string { model . AlertNameLabel , models . FolderTitl eLabel, "custom" } ,
ObjectMatchers : matcher ( models . AutogeneratedRouteSettingsHashLabel , "b3a2fa5e615dcc7e " ) ,
GroupByStr : [ ] string { models . FolderTitleLabel , model . AlertNam eLabel , "custom" } ,
} ) ,
withChildRoutes ( basicContactRoute ( "receiver3" ) , & definitions . Route {
Receiver : "receiver3" ,
@ -164,6 +164,71 @@ func TestAddAutogenConfig(t *testing.T) {
} ,
} ) ,
} ,
{
name : "settings with custom options and nil groupBy, groupBy should inherit from parent" ,
existingConfig : configGen ( [ ] string { "receiver1" } , nil ) ,
storeSettings : [ ] models . NotificationSettings {
models . CopyNotificationSettings ( models . NewDefaultNotificationSettings ( "receiver1" ) , models . NSMuts . WithGroupInterval ( util . Pointer ( 1 * time . Minute ) ) , models . NSMuts . WithGroupBy ( ) ) ,
} ,
expRoute : withChildRoutes ( rootRoute ( ) , & definitions . Route {
Receiver : "default" ,
ObjectMatchers : matcher ( models . AutogeneratedRouteLabel , "true" ) ,
Routes : [ ] * definitions . Route {
withChildRoutes ( basicContactRoute ( "receiver1" ) , & definitions . Route {
Receiver : "receiver1" ,
ObjectMatchers : matcher ( models . AutogeneratedRouteSettingsHashLabel , "dde34b8127e68f31" ) ,
GroupByStr : nil ,
GroupInterval : util . Pointer ( model . Duration ( 1 * time . Minute ) ) ,
} ) ,
} ,
} ) ,
} ,
{
name : "settings with nil groupBy should have different fingerprint than default groupBy" ,
existingConfig : configGen ( [ ] string { "receiver1" } , nil ) ,
storeSettings : [ ] models . NotificationSettings {
models . CopyNotificationSettings ( models . NewDefaultNotificationSettings ( "receiver1" ) , models . NSMuts . WithGroupInterval ( util . Pointer ( 1 * time . Minute ) ) , models . NSMuts . WithGroupBy ( ) ) ,
models . CopyNotificationSettings ( models . NewDefaultNotificationSettings ( "receiver1" ) , models . NSMuts . WithGroupInterval ( util . Pointer ( 1 * time . Minute ) ) , models . NSMuts . WithGroupBy ( models . DefaultNotificationSettingsGroupBy ... ) ) ,
} ,
expRoute : withChildRoutes ( rootRoute ( ) , & definitions . Route {
Receiver : "default" ,
ObjectMatchers : matcher ( models . AutogeneratedRouteLabel , "true" ) ,
Routes : [ ] * definitions . Route {
withChildRoutes ( basicContactRoute ( "receiver1" ) , & definitions . Route {
Receiver : "receiver1" ,
ObjectMatchers : matcher ( models . AutogeneratedRouteSettingsHashLabel , "dde34b8127e68f31" ) ,
GroupByStr : nil ,
GroupInterval : util . Pointer ( model . Duration ( 1 * time . Minute ) ) ,
} , & definitions . Route {
Receiver : "receiver1" ,
ObjectMatchers : matcher ( models . AutogeneratedRouteSettingsHashLabel , "e1f3a275a8918385" ) , // Different hash.
GroupByStr : [ ] string { models . FolderTitleLabel , model . AlertNameLabel } ,
GroupInterval : util . Pointer ( model . Duration ( 1 * time . Minute ) ) ,
} ) ,
} ,
} ) ,
} ,
{
name : "settings with incomplete required groupBy labels will be completed and should have the same fingerprint" ,
existingConfig : configGen ( [ ] string { "receiver1" } , nil ) ,
storeSettings : [ ] models . NotificationSettings {
models . CopyNotificationSettings ( models . NewDefaultNotificationSettings ( "receiver1" ) , models . NSMuts . WithGroupInterval ( util . Pointer ( 1 * time . Minute ) ) , models . NSMuts . WithGroupBy ( models . FolderTitleLabel ) ) ,
models . CopyNotificationSettings ( models . NewDefaultNotificationSettings ( "receiver1" ) , models . NSMuts . WithGroupInterval ( util . Pointer ( 1 * time . Minute ) ) , models . NSMuts . WithGroupBy ( model . AlertNameLabel ) ) ,
models . CopyNotificationSettings ( models . NewDefaultNotificationSettings ( "receiver1" ) , models . NSMuts . WithGroupInterval ( util . Pointer ( 1 * time . Minute ) ) , models . NSMuts . WithGroupBy ( models . DefaultNotificationSettingsGroupBy ... ) ) ,
} ,
expRoute : withChildRoutes ( rootRoute ( ) , & definitions . Route {
Receiver : "default" ,
ObjectMatchers : matcher ( models . AutogeneratedRouteLabel , "true" ) ,
Routes : [ ] * definitions . Route {
withChildRoutes ( basicContactRoute ( "receiver1" ) , & definitions . Route {
Receiver : "receiver1" ,
ObjectMatchers : matcher ( models . AutogeneratedRouteSettingsHashLabel , "e1f3a275a8918385" ) ,
GroupByStr : [ ] string { models . FolderTitleLabel , model . AlertNameLabel } ,
GroupInterval : util . Pointer ( model . Duration ( 1 * time . Minute ) ) ,
} ) ,
} ,
} ) ,
} ,
{
name : "when skipInvalid=true, invalid settings are skipped" ,
existingConfig : configGen ( [ ] string { "receiver1" , "receiver2" , "receiver3" } , nil ) ,