mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 08:42:18 +08:00
Alerting: Fix active time intervals when time interval is renamed (#108534)
This commit is contained in:
@ -440,6 +440,12 @@ func replaceMuteTiming(route *definitions.Route, oldName, newName string) int {
|
|||||||
updated++
|
updated++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for idx := range route.ActiveTimeIntervals {
|
||||||
|
if route.ActiveTimeIntervals[idx] == oldName {
|
||||||
|
route.ActiveTimeIntervals[idx] = newName
|
||||||
|
updated++
|
||||||
|
}
|
||||||
|
}
|
||||||
for _, route := range route.Routes {
|
for _, route := range route.Routes {
|
||||||
updated += replaceMuteTiming(route, oldName, newName)
|
updated += replaceMuteTiming(route, oldName, newName)
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
],
|
],
|
||||||
"mute_time_intervals": [
|
"mute_time_intervals": [
|
||||||
"test-interval", "persisted-interval"
|
"test-interval", "persisted-interval"
|
||||||
|
],
|
||||||
|
"active_time_intervals": [
|
||||||
|
"test-interval", "persisted-interval"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -725,7 +725,9 @@ func TestIntegrationTimeIntervalReferentialIntegrity(t *testing.T) {
|
|||||||
updatedRoute := legacyCli.GetRoute(t)
|
updatedRoute := legacyCli.GetRoute(t)
|
||||||
for idx, route := range updatedRoute.Routes {
|
for idx, route := range updatedRoute.Routes {
|
||||||
expectedTimeIntervals := replace(currentRoute.Routes[idx].MuteTimeIntervals, interval.Spec.Name, actual.Spec.Name)
|
expectedTimeIntervals := replace(currentRoute.Routes[idx].MuteTimeIntervals, interval.Spec.Name, actual.Spec.Name)
|
||||||
assert.Equalf(t, expectedTimeIntervals, route.MuteTimeIntervals, "time interval in routes should have been renamed but it did not")
|
assert.Equalf(t, expectedTimeIntervals, route.MuteTimeIntervals, "mute time interval in routes should have been renamed but it did not")
|
||||||
|
expectedTimeIntervals = replace(currentRoute.Routes[idx].ActiveTimeIntervals, interval.Spec.Name, actual.Spec.Name)
|
||||||
|
assert.Equalf(t, expectedTimeIntervals, route.ActiveTimeIntervals, "active time interval in routes should have been renamed but it did not")
|
||||||
}
|
}
|
||||||
|
|
||||||
interval = *actual
|
interval = *actual
|
||||||
|
Reference in New Issue
Block a user