moira icon indicating copy to clipboard operation
moira copied to clipboard

Adding ability to automatically close incident in PagerDuty

Open tantra35 opened this issue 5 years ago • 10 comments

Adding ability to automatically close incident in PagerDuty when moira decided that alert is resolved(send OK status).

This change conform incident lifecycle, that described in https://v2.developer.pagerduty.com/docs/send-an-event-events-api-v2

For playing with api link below can be used: https://v2.developer.pagerduty.com/docs/send-an-event-events-api-v2

tantra35 avatar Jan 16 '20 13:01 tantra35

You have failing tests. Please fix it before we can merge your PR into master. CI log:

=== RUN   TestBuildEvent

  Build pagerduty event tests 
    Build pagerduty event with one moira event ✘
    Build pagerduty event with one moira event and plot ✘
    Build pagerduty event with one event and throttled ✘
    Build pagerduty event with 10 events and throttled ✘


Failures:

  * /home/travis/gopath/src/github.com/moira-alert/moira/senders/pagerduty/send_test.go 
  Line 69:
  Expected: 'pagerduty.V2Event{RoutingKey:"mock routing key", Action:"trigger", DedupKey:"", Images:[]interface{}(nil), Client:"", ClientURL:"", Payload:(*pagerduty.V2Payload){Summary:"NODATA Trigger Name [tag1][tag2]", Source:"moira", Severity:"warning", Timestamp:"1974-10-03T02:40:00Z", Component:"", Group:"", Class:"", Details:map[string]interface{}{"Description":"bold text italics code regular", "Events":"\n02:40: Metric name = 97.4458331200185 (OK to NODATA)", "Trigger Name":"Trigger Name", "Trigger URI":"http://moira.url/trigger/TriggerID"}}}'
  Actual:   'pagerduty.V2Event{RoutingKey:"mock routing key", Action:"trigger", DedupKey:"TriggerID", Images:[]interface{}(nil), Client:"", ClientURL:"", Payload:(*pagerduty.V2Payload){Summary:"NODATA Trigger Name [tag1][tag2]", Source:"moira", Severity:"warning", Timestamp:"1974-10-03T02:40:00Z", Component:"", Group:"", Class:"", Details:map[string]interface{}{"Description":"bold text italics code regular", "Events":"\n02:40: Metric name = 97.4458331200185 (OK to NODATA)", "Trigger Name":"Trigger Name", "Trigger URI":"http://moira.url/trigger/TriggerID"}}}'
  (Should resemble)!
  Diff:     'pagerduty.V2Event{RoutingKey:"mock routing key", Action:"trigger", DedupKey:"[32mTriggerID[0m", Images:[]interface{}(nil), Client:"", ClientURL:"", Payload:(*pagerduty.V2Payload){Summary:"NODATA Trigger Name [tag1][tag2]", Source:"moira", Severity:"warning", Timestamp:"1974-10-03T02:40:00Z", Component:"", Group:"", Class:"", Details:map[string]interface{}{"Description":"bold text italics code regular", "Events":"\n02:40: Metric name = 97.4458331200185 (OK to NODATA)", "Trigger Name":"Trigger Name", "Trigger URI":"http://moira.url/trigger/TriggerID"}}}'
  goroutine 8 [running]:
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/reporting/reports.go:143 +0x6d
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/reporting/reports.go:103 +0x6c
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:176 +0xec
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/doc.go:125 +0x63
  github.com/moira-alert/moira/senders/pagerduty.TestBuildEvent.func1.1()
  	/home/travis/gopath/src/github.com/moira-alert/moira/senders/pagerduty/send_test.go:69 +0x47b
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/discovery.go:80 +0x24
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:261 +0x1b2
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:163 +0x48
  github.com/jtolds/gls.(*ContextManager).SetValues.func1(0x0)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/context.go:97 +0x466
  github.com/jtolds/gls.EnsureGoroutineId(0xc000106960)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/gid.go:19 +0x111
  github.com/jtolds/gls.(*ContextManager).SetValues(0xc000033500, 0xc000106900, 0xc00000f200)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/context.go:63 +0x14b
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:162 +0x1bf
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/doc.go:77 +0x92
  github.com/moira-alert/moira/senders/pagerduty.TestBuildEvent.func1()
  	/home/travis/gopath/src/github.com/moira-alert/moira/senders/pagerduty/send_test.go:59 +0x54c
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/discovery.go:80 +0x24
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:261 +0x1b2
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:110 +0xfb
  github.com/jtolds/gls.(*ContextManager).SetValues.func1(0x0)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/context.go:97 +0x466
  github.com/jtolds/gls.EnsureGoroutineId.func1()
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/gid.go:24 +0x2e
  github.com/jtolds/gls._m(0x0, 0xc00000f180)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/stack_tags.go:108 +0x31
  github.com/jtolds/gls.github_com_jtolds_gls_markS(0x0, 0xc00000f180)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/stack_tags.go:56 +0x35
  github.com/jtolds/gls.addStackTag(...)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/stack_tags.go:49
  github.com/jtolds/gls.EnsureGoroutineId(0xc0001067e0)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/gid.go:24 +0xdf
  github.com/jtolds/gls.(*ContextManager).SetValues(0xc000033500, 0xc000106780, 0xc00000f140)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/context.go:63 +0x14b
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:105 +0x227
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/doc.go:75 +0xbe
  github.com/moira-alert/moira/senders/pagerduty.TestBuildEvent(0xc0000ee400)
  	/home/travis/gopath/src/github.com/moira-alert/moira/senders/pagerduty/send_test.go:23 +0x352
  testing.tRunner(0xc0000ee400, 0x7bc878)
  	/home/travis/.gimme/versions/go1.13.1.linux.amd64/src/testing/testing.go:909 +0xc9
  created by testing.(*T).Run
  	/home/travis/.gimme/versions/go1.13.1.linux.amd64/src/testing/testing.go:960 +0x350
  

  * /home/travis/gopath/src/github.com/moira-alert/moira/senders/pagerduty/send_test.go 
  Line 91:
  Expected: 'pagerduty.V2Event{RoutingKey:"mock routing key", Action:"trigger", DedupKey:"", Images:[]interface{}{map[string]string{"alt":"Plot", "src":"test"}}, Client:"", ClientURL:"", Payload:(*pagerduty.V2Payload){Summary:"NODATA Trigger Name [tag1][tag2]", Source:"moira", Severity:"warning", Timestamp:"1974-10-03T02:40:00Z", Component:"", Group:"", Class:"", Details:map[string]interface{}{"Description":"bold text italics code regular", "Events":"\n02:40: Metric name = 97.4458331200185 (OK to NODATA)", "Trigger Name":"Trigger Name", "Trigger URI":"http://moira.url/trigger/TriggerID"}}}'
  Actual:   'pagerduty.V2Event{RoutingKey:"mock routing key", Action:"trigger", DedupKey:"TriggerID", Images:[]interface{}{map[string]string{"alt":"Plot", "src":"test"}}, Client:"", ClientURL:"", Payload:(*pagerduty.V2Payload){Summary:"NODATA Trigger Name [tag1][tag2]", Source:"moira", Severity:"warning", Timestamp:"1974-10-03T02:40:00Z", Component:"", Group:"", Class:"", Details:map[string]interface{}{"Description":"bold text italics code regular", "Events":"\n02:40: Metric name = 97.4458331200185 (OK to NODATA)", "Trigger Name":"Trigger Name", "Trigger URI":"http://moira.url/trigger/TriggerID"}}}'
  (Should resemble)!
  Diff:     'pagerduty.V2Event{RoutingKey:"mock routing key", Action:"trigger", DedupKey:"[32mTriggerID[0m", Images:[]interface{}{map[string]string{"alt":"Plot", "src":"test"}}, Client:"", ClientURL:"", Payload:(*pagerduty.V2Payload){Summary:"NODATA Trigger Name [tag1][tag2]", Source:"moira", Severity:"warning", Timestamp:"1974-10-03T02:40:00Z", Component:"", Group:"", Class:"", Details:map[string]interface{}{"Description":"bold text italics code regular", "Events":"\n02:40: Metric name = 97.4458331200185 (OK to NODATA)", "Trigger Name":"Trigger Name", "Trigger URI":"http://moira.url/trigger/TriggerID"}}}'
  goroutine 8 [running]:
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/reporting/reports.go:143 +0x6d
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/reporting/reports.go:103 +0x6c
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:176 +0xec
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/doc.go:125 +0x63
  github.com/moira-alert/moira/senders/pagerduty.TestBuildEvent.func1.2()
  	/home/travis/gopath/src/github.com/moira-alert/moira/senders/pagerduty/send_test.go:91 +0x6e2
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/discovery.go:80 +0x24
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:261 +0x1b2
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:163 +0x48
  github.com/jtolds/gls.(*ContextManager).SetValues.func1(0x0)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/context.go:97 +0x466
  github.com/jtolds/gls.EnsureGoroutineId(0xc000106f30)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/gid.go:19 +0x111
  github.com/jtolds/gls.(*ContextManager).SetValues(0xc000033500, 0xc000106ed0, 0xc00000f540)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/context.go:63 +0x14b
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:162 +0x1bf
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/doc.go:77 +0x92
  github.com/moira-alert/moira/senders/pagerduty.TestBuildEvent.func1()
  	/home/travis/gopath/src/github.com/moira-alert/moira/senders/pagerduty/send_test.go:72 +0x6c7
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/discovery.go:80 +0x24
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:261 +0x1b2
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:110 +0xfb
  github.com/jtolds/gls.(*ContextManager).SetValues.func1(0x0)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/context.go:97 +0x466
  github.com/jtolds/gls.EnsureGoroutineId.func1()
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/gid.go:24 +0x2e
  github.com/jtolds/gls._m(0x0, 0xc00000f180)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/stack_tags.go:108 +0x31
  github.com/jtolds/gls.github_com_jtolds_gls_markS(0x0, 0xc00000f180)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/stack_tags.go:56 +0x35
  github.com/jtolds/gls.addStackTag(...)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/stack_tags.go:49
  github.com/jtolds/gls.EnsureGoroutineId(0xc0001067e0)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/gid.go:24 +0xdf
  github.com/jtolds/gls.(*ContextManager).SetValues(0xc000033500, 0xc000106780, 0xc00000f140)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/context.go:63 +0x14b
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:105 +0x227
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/doc.go:75 +0xbe
  github.com/moira-alert/moira/senders/pagerduty.TestBuildEvent(0xc0000ee400)
  	/home/travis/gopath/src/github.com/moira-alert/moira/senders/pagerduty/send_test.go:23 +0x352
  testing.tRunner(0xc0000ee400, 0x7bc878)
  	/home/travis/.gimme/versions/go1.13.1.linux.amd64/src/testing/testing.go:909 +0xc9
  created by testing.(*T).Run
  	/home/travis/.gimme/versions/go1.13.1.linux.amd64/src/testing/testing.go:960 +0x350
  

  * /home/travis/gopath/src/github.com/moira-alert/moira/senders/pagerduty/send_test.go 
  Line 105:
  Expected: 'pagerduty.V2Event{RoutingKey:"mock routing key", Action:"trigger", DedupKey:"", Images:[]interface{}(nil), Client:"", ClientURL:"", Payload:(*pagerduty.V2Payload){Summary:"NODATA Trigger Name [tag1][tag2]", Source:"moira", Severity:"warning", Timestamp:"1974-10-03T02:40:00Z", Component:"", Group:"", Class:"", Details:map[string]interface{}{"Description":"bold text italics code regular", "Events":"\n02:40: Metric name = 97.4458331200185 (OK to NODATA)", "Message":"Please, fix your system or tune this trigger to generate less events.", "Trigger Name":"Trigger Name", "Trigger URI":"http://moira.url/trigger/TriggerID"}}}'
  Actual:   'pagerduty.V2Event{RoutingKey:"mock routing key", Action:"trigger", DedupKey:"TriggerID", Images:[]interface{}(nil), Client:"", ClientURL:"", Payload:(*pagerduty.V2Payload){Summary:"NODATA Trigger Name [tag1][tag2]", Source:"moira", Severity:"warning", Timestamp:"1974-10-03T02:40:00Z", Component:"", Group:"", Class:"", Details:map[string]interface{}{"Description":"bold text italics code regular", "Events":"\n02:40: Metric name = 97.4458331200185 (OK to NODATA)", "Message":"Please, fix your system or tune this trigger to generate less events.", "Trigger Name":"Trigger Name", "Trigger URI":"http://moira.url/trigger/TriggerID"}}}'
  (Should resemble)!
  Diff:     'pagerduty.V2Event{RoutingKey:"mock routing key", Action:"trigger", DedupKey:"[32mTriggerID[0m", Images:[]interface{}(nil), Client:"", ClientURL:"", Payload:(*pagerduty.V2Payload){Summary:"NODATA Trigger Name [tag1][tag2]", Source:"moira", Severity:"warning", Timestamp:"1974-10-03T02:40:00Z", Component:"", Group:"", Class:"", Details:map[string]interface{}{"Description":"bold text italics code regular", "Events":"\n02:40: Metric name = 97.4458331200185 (OK to NODATA)", "Message":"Please, fix your system or tune this trigger to generate less events.", "Trigger Name":"Trigger Name", "Trigger URI":"http://moira.url/trigger/TriggerID"}}}'
  goroutine 8 [running]:
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/reporting/reports.go:143 +0x6d
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/reporting/reports.go:103 +0x6c
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:176 +0xec
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/doc.go:125 +0x63
  github.com/moira-alert/moira/senders/pagerduty.TestBuildEvent.func1.3()
  	/home/travis/gopath/src/github.com/moira-alert/moira/senders/pagerduty/send_test.go:105 +0x4d4
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/discovery.go:80 +0x24
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:261 +0x1b2
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:163 +0x48
  github.com/jtolds/gls.(*ContextManager).SetValues.func1(0x0)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/context.go:97 +0x466
  github.com/jtolds/gls.EnsureGoroutineId(0xc0001073b0)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/gid.go:19 +0x111
  github.com/jtolds/gls.(*ContextManager).SetValues(0xc000033500, 0xc000107350, 0xc00000f840)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/context.go:63 +0x14b
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:162 +0x1bf
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/doc.go:77 +0x92
  github.com/moira-alert/moira/senders/pagerduty.TestBuildEvent.func1()
  	/home/travis/gopath/src/github.com/moira-alert/moira/senders/pagerduty/send_test.go:94 +0x839
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/discovery.go:80 +0x24
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:261 +0x1b2
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:110 +0xfb
  github.com/jtolds/gls.(*ContextManager).SetValues.func1(0x0)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/context.go:97 +0x466
  github.com/jtolds/gls.EnsureGoroutineId.func1()
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/gid.go:24 +0x2e
  github.com/jtolds/gls._m(0x0, 0xc00000f180)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/stack_tags.go:108 +0x31
  github.com/jtolds/gls.github_com_jtolds_gls_markS(0x0, 0xc00000f180)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/stack_tags.go:56 +0x35
  github.com/jtolds/gls.addStackTag(...)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/stack_tags.go:49
  github.com/jtolds/gls.EnsureGoroutineId(0xc0001067e0)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/gid.go:24 +0xdf
  github.com/jtolds/gls.(*ContextManager).SetValues(0xc000033500, 0xc000106780, 0xc00000f140)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/context.go:63 +0x14b
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:105 +0x227
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/doc.go:75 +0xbe
  github.com/moira-alert/moira/senders/pagerduty.TestBuildEvent(0xc0000ee400)
  	/home/travis/gopath/src/github.com/moira-alert/moira/senders/pagerduty/send_test.go:23 +0x352
  testing.tRunner(0xc0000ee400, 0x7bc878)
  	/home/travis/.gimme/versions/go1.13.1.linux.amd64/src/testing/testing.go:909 +0xc9
  created by testing.(*T).Run
  	/home/travis/.gimme/versions/go1.13.1.linux.amd64/src/testing/testing.go:960 +0x350
  

  * /home/travis/gopath/src/github.com/moira-alert/moira/senders/pagerduty/send_test.go 
  Line 133:
  Expected: 'pagerduty.V2Event{RoutingKey:"mock routing key", Action:"trigger", DedupKey:"", Images:[]interface{}(nil), Client:"", ClientURL:"", Payload:(*pagerduty.V2Payload){Summary:"NODATA Trigger Name [tag1][tag2]", Source:"moira", Severity:"warning", Timestamp:"1974-10-03T02:40:00Z", Component:"", Group:"", Class:"", Details:map[string]interface{}{"Description":"bold text italics code regular", "Events":"\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)", "Message":"Please, fix your system or tune this trigger to generate less events.", "Trigger Name":"Trigger Name", "Trigger URI":"http://moira.url/trigger/TriggerID"}}}'
  Actual:   'pagerduty.V2Event{RoutingKey:"mock routing key", Action:"trigger", DedupKey:"TriggerID", Images:[]interface{}(nil), Client:"", ClientURL:"", Payload:(*pagerduty.V2Payload){Summary:"NODATA Trigger Name [tag1][tag2]", Source:"moira", Severity:"warning", Timestamp:"1974-10-03T02:40:00Z", Component:"", Group:"", Class:"", Details:map[string]interface{}{"Description":"bold text italics code regular", "Events":"\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)", "Message":"Please, fix your system or tune this trigger to generate less events.", "Trigger Name":"Trigger Name", "Trigger URI":"http://moira.url/trigger/TriggerID"}}}'
  (Should resemble)!
  Diff:     'pagerduty.V2Event{RoutingKey:"mock routing key", Action:"trigger", DedupKey:"[32mTriggerID[0m", Images:[]interface{}(nil), Client:"", ClientURL:"", Payload:(*pagerduty.V2Payload){Summary:"NODATA Trigger Name [tag1][tag2]", Source:"moira", Severity:"warning", Timestamp:"1974-10-03T02:40:00Z", Component:"", Group:"", Class:"", Details:map[string]interface{}{"Description":"bold text italics code regular", "Events":"\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)\n02:40: Metric name = 97.4458331200185 (OK to NODATA)", "Message":"Please, fix your system or tune this trigger to generate less events.", "Trigger Name":"Trigger Name", "Trigger URI":"http://moira.url/trigger/TriggerID"}}}'
  goroutine 8 [running]:
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/reporting/reports.go:143 +0x6d
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/reporting/reports.go:103 +0x6c
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:176 +0xec
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/doc.go:125 +0x63
  github.com/moira-alert/moira/senders/pagerduty.TestBuildEvent.func1.4()
  	/home/travis/gopath/src/github.com/moira-alert/moira/senders/pagerduty/send_test.go:133 +0x601
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/discovery.go:80 +0x24
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:261 +0x1b2
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:163 +0x48
  github.com/jtolds/gls.(*ContextManager).SetValues.func1(0x0)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/context.go:97 +0x466
  github.com/jtolds/gls.EnsureGoroutineId(0xc000107680)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/gid.go:19 +0x111
  github.com/jtolds/gls.(*ContextManager).SetValues(0xc000033500, 0xc000107620, 0xc00000f9e0)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/context.go:63 +0x14b
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:162 +0x1bf
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/doc.go:77 +0x92
  github.com/moira-alert/moira/senders/pagerduty.TestBuildEvent.func1()
  	/home/travis/gopath/src/github.com/moira-alert/moira/senders/pagerduty/send_test.go:108 +0x9a1
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/discovery.go:80 +0x24
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:261 +0x1b2
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:110 +0xfb
  github.com/jtolds/gls.(*ContextManager).SetValues.func1(0x0)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/context.go:97 +0x466
  github.com/jtolds/gls.EnsureGoroutineId.func1()
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/gid.go:24 +0x2e
  github.com/jtolds/gls._m(0x0, 0xc00000f180)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/stack_tags.go:108 +0x31
  github.com/jtolds/gls.github_com_jtolds_gls_markS(0x0, 0xc00000f180)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/stack_tags.go:56 +0x35
  github.com/jtolds/gls.addStackTag(...)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/stack_tags.go:49
  github.com/jtolds/gls.EnsureGoroutineId(0xc0001067e0)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/gid.go:24 +0xdf
  github.com/jtolds/gls.(*ContextManager).SetValues(0xc000033500, 0xc000106780, 0xc00000f140)
  	/home/travis/gopath/pkg/mod/github.com/jtolds/[email protected]+incompatible/context.go:63 +0x14b
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:105 +0x227
  	/home/travis/gopath/pkg/mod/github.com/smartystreets/[email protected]/convey/doc.go:75 +0xbe
  github.com/moira-alert/moira/senders/pagerduty.TestBuildEvent(0xc0000ee400)
  	/home/travis/gopath/src/github.com/moira-alert/moira/senders/pagerduty/send_test.go:23 +0x352
  testing.tRunner(0xc0000ee400, 0x7bc878)
  	/home/travis/.gimme/versions/go1.13.1.linux.amd64/src/testing/testing.go:909 +0xc9
  created by testing.(*T).Run
  	/home/travis/.gimme/versions/go1.13.1.linux.amd64/src/testing/testing.go:960 +0x350
  


13 total assertions

--- FAIL: TestBuildEvent (0.01s)
FAIL
coverage: 79.7% of statements
exit status 1
FAIL	github.com/moira-alert/moira/senders/pagerduty	0.010s
FAIL

litleleprikon avatar Feb 10 '20 14:02 litleleprikon

@tantra35 Would you like to fix tests for this PR?

litleleprikon avatar Feb 18 '20 09:02 litleleprikon

@litleleprikon we will try

tantra35 avatar Feb 18 '20 10:02 tantra35

@litleleprikon how we can launch make lint? if it reports tons of erross like this

goroutine 2545 [semacquire, 76 minutes]:
sync.runtime_SemacquireMutex(0xc000fb4054, 0x0, 0x1)
        /usr/local/go/src/runtime/sema.go:71 +0x47
sync.(*Mutex).lockSlow(0xc000fb4050)
        /usr/local/go/src/sync/mutex.go:138 +0xfc
sync.(*Mutex).Lock(...)
        /usr/local/go/src/sync/mutex.go:81
sync.(*Once).doSlow(0xc000fb404c, 0xc001c68f68)
        /usr/local/go/src/sync/once.go:62 +0x122
sync.(*Once).Do(...)
        /usr/local/go/src/sync/once.go:57
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive(0xc000fb4000, 0x2, 0xc000eee120)
        /Users/denis/go/src/github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner.go:987 +0x7e
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive.func1.1(0x2, 0xc000eee120, 0xc000772900, 0xc000fb4000)
        /Users/denis/go/src/github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner.go:993 +0x3f
created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive.func1
        /Users/denis/go/src/github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner.go:992 +0x113

tantra35 avatar Feb 18 '20 15:02 tantra35

Coverage Status

Coverage decreased (-0.01%) to 80.477% when pulling 093c90d75556ffdc94b5fd4df08f0b638a81e11a on tantra35:pagerduty-autoresolve into ac13c29cb020273607b1250cea22732d25b47a25 on moira-alert:master.

coveralls avatar Feb 18 '20 15:02 coveralls

@tantra35 which version of go are you using?

litleleprikon avatar Feb 19 '20 14:02 litleleprikon

@litleleprikon we use 1.13

tantra35 avatar Feb 25 '20 11:02 tantra35

@tantra35 I do not know why you are not able to run linter but my general advice will be to use docker container to run linter

litleleprikon avatar Feb 26 '20 10:02 litleleprikon

Hi @tantra35 this PR is almost ready to be merged into master. Would you like to rebase on a new master and fix issues?

litleleprikon avatar Mar 30 '20 08:03 litleleprikon

@tantra35 please complete this PR. Personally, we are really looking forward to the appearance of this PR in the master branch. Thanks.

bilkoua avatar Apr 30 '20 09:04 bilkoua