From 4db18e929af2c15676d2df83ecc8593244de86af Mon Sep 17 00:00:00 2001 From: yasmin-tr Date: Wed, 22 Jan 2025 15:17:17 +0200 Subject: [PATCH 1/2] DEV-47397 - Fix failing tests on TestTemplateDefaultData due to changes for append timeframe for panel/dashboard URL tests needed to be fixed as well --- pkg/services/ngalert/notifier/templates_test.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pkg/services/ngalert/notifier/templates_test.go b/pkg/services/ngalert/notifier/templates_test.go index 850b51a20e01e..d9ccad774759b 100644 --- a/pkg/services/ngalert/notifier/templates_test.go +++ b/pkg/services/ngalert/notifier/templates_test.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "testing" + "time" "github.com/go-openapi/strfmt" alertingModels "github.com/grafana/alerting/models" @@ -125,8 +126,11 @@ CommonAnnotations: {{ range .CommonAnnotations.SortedPairs }}{{ .Name }}={{ .Val Results: []alertingNotify.TestTemplatesResult{{ Name: "slack.title", // LOGZ.IO GRAFANA CHANGE :: DEV-45707: remove org id query param from notification urls - Text: fmt.Sprintf("http://localhost:9093/d/%s", - DefaultAnnotations[alertingModels.DashboardUIDAnnotation]), + // LOGZ.IO GRAFANA CHANGE :: DEV-47397 - Append timeframe for panel/dashboard URL + Text: fmt.Sprintf("http://localhost:9093/d/%s?from=%d&to=%d", + DefaultAnnotations[alertingModels.DashboardUIDAnnotation], + time.Time(simpleAlert.StartsAt).Add(-5*time.Minute).UnixMilli(), + time.Time(simpleAlert.EndsAt).UnixMilli()), // LOGZ.IO GRAFANA CHANGE :: End }}, Errors: nil, @@ -142,9 +146,12 @@ CommonAnnotations: {{ range .CommonAnnotations.SortedPairs }}{{ .Name }}={{ .Val Results: []alertingNotify.TestTemplatesResult{{ Name: "slack.title", // LOGZ.IO GRAFANA CHANGE :: DEV-45707: remove org id query param from notification urls - Text: fmt.Sprintf("http://localhost:9093/d/%s?viewPanel=%s", + // LOGZ.IO GRAFANA CHANGE :: DEV-47397 - Append timeframe for panel/dashboard URL + Text: fmt.Sprintf("http://localhost:9093/d/%s?viewPanel=%s&from=%d&to=%d", DefaultAnnotations[alertingModels.DashboardUIDAnnotation], - DefaultAnnotations[alertingModels.PanelIDAnnotation]), + DefaultAnnotations[alertingModels.PanelIDAnnotation], + time.Time(simpleAlert.StartsAt).Add(-5*time.Minute).UnixMilli(), + time.Time(simpleAlert.EndsAt).UnixMilli()), // LOGZ.IO GRAFANA CHANGE :: End }}, Errors: nil, From 7a5c56930ec0d91f248a1e1229a810daff14b135 Mon Sep 17 00:00:00 2001 From: yasmin-tr Date: Wed, 22 Jan 2025 20:15:07 +0200 Subject: [PATCH 2/2] add ticket comment for reference --- pkg/services/ngalert/notifier/templates_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/services/ngalert/notifier/templates_test.go b/pkg/services/ngalert/notifier/templates_test.go index d9ccad774759b..59b280559c5b6 100644 --- a/pkg/services/ngalert/notifier/templates_test.go +++ b/pkg/services/ngalert/notifier/templates_test.go @@ -4,7 +4,7 @@ import ( "context" "fmt" "testing" - "time" + "time" // LOGZ.IO GRAFANA CHANGE :: DEV-47397 - Append timeframe for panel/dashboard URL "github.com/go-openapi/strfmt" alertingModels "github.com/grafana/alerting/models"