From f50f831f323ca1d4e0ac2e45b53a9964545a2a62 Mon Sep 17 00:00:00 2001 From: Pavel Zavora Date: Thu, 4 Mar 2021 12:43:28 +0100 Subject: [PATCH 1/2] fix(bigPanda): add bigPanda to tisckscript AST parser --- pipeline/tick/alert.go | 7 +++++++ pipeline/tick/alert_test.go | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/pipeline/tick/alert.go b/pipeline/tick/alert.go index 9750fb0d0..6f4948f54 100644 --- a/pipeline/tick/alert.go +++ b/pipeline/tick/alert.go @@ -177,6 +177,13 @@ func (n *AlertNode) Build(a *pipeline.AlertNode) (ast.Node, error) { } } + for _, h := range a.BigPandaHandlers { + n.Dot("bigPanda"). + Dot("appKey", h.AppKey). + Dot("primaryProperty", h.PrimaryProperty). + Dot("secondaryProperty", h.SecondaryProperty) + } + for _, h := range a.SlackHandlers { n.Dot("slack"). Dot("workspace", h.Workspace). diff --git a/pipeline/tick/alert_test.go b/pipeline/tick/alert_test.go index b0470157d..b46805bf8 100644 --- a/pipeline/tick/alert_test.go +++ b/pipeline/tick/alert_test.go @@ -118,6 +118,28 @@ func TestAlertHTTPPost(t *testing.T) { PipelineTickTestHelper(t, pipe, want) } +func TestAlertBigPanda(t *testing.T) { + pipe, _, from := StreamFrom() + handler := from.Alert().BigPanda() + handler.AppKey = "A" + handler.PrimaryProperty = "B" + handler.SecondaryProperty = "C" + + want := `stream + |from() + |alert() + .id('{{ .Name }}:{{ .Group }}') + .message('{{ .ID }} is {{ .Level }}') + .details('{{ json . }}') + .history(21) + .bigPanda() + .appKey('A') + .primaryProperty('B') + .secondaryProperty('C') +` + PipelineTickTestHelper(t, pipe, want) +} + func TestAlertHTTPPostMultipleHeaders(t *testing.T) { pipe, _, from := StreamFrom() handler := from.Alert().Post("") From 65d107fb6dc3535661a268cd0bfa77aec836f96c Mon Sep 17 00:00:00 2001 From: Pavel Zavora Date: Thu, 4 Mar 2021 12:44:24 +0100 Subject: [PATCH 2/2] fix(serviceNow): add tisckscript AST parser test --- pipeline/tick/alert_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pipeline/tick/alert_test.go b/pipeline/tick/alert_test.go index b46805bf8..121d6111d 100644 --- a/pipeline/tick/alert_test.go +++ b/pipeline/tick/alert_test.go @@ -140,6 +140,34 @@ func TestAlertBigPanda(t *testing.T) { PipelineTickTestHelper(t, pipe, want) } +func TestAlertServiceNow(t *testing.T) { + pipe, _, from := StreamFrom() + handler := from.Alert().ServiceNow() + handler.Source = "A" + handler.Node = "B" + handler.Type = "C" + handler.Resource = "D" + handler.MetricName = "E" + handler.MessageKey = "F" + + want := `stream + |from() + |alert() + .id('{{ .Name }}:{{ .Group }}') + .message('{{ .ID }} is {{ .Level }}') + .details('{{ json . }}') + .history(21) + .serviceNow() + .source('A') + .node('B') + .type('C') + .resource('D') + .metricName('E') + .messageKey('F') +` + PipelineTickTestHelper(t, pipe, want) +} + func TestAlertHTTPPostMultipleHeaders(t *testing.T) { pipe, _, from := StreamFrom() handler := from.Alert().Post("")