pprof_test.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/apm/model/pprof"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. var (
  9. text = `
  10. {
  11. "title": "主站 HTTP_SERVER 错误率过高(主告警条件)",
  12. "tags": {
  13. "app": "account.service.member",
  14. "code": "-404",
  15. "exported_job": "caster_app_metrics",
  16. "method": "x/v2/view"
  17. }
  18. }`
  19. )
  20. func TestService_ActiveWarning(t *testing.T) {
  21. convey.Convey("ActiveWarning", t, func() {
  22. err := svr.ActiveWarning(context.Background(), text)
  23. convey.So(err, convey.ShouldBeNil)
  24. })
  25. }
  26. func TestService_Pprof(t *testing.T) {
  27. var (
  28. err error
  29. req = &pprof.Params{
  30. AppID: "account.service.member",
  31. Kind: 1,
  32. SvgName: "4zf56-1539587841",
  33. }
  34. pws = make([]*pprof.Warn, 0)
  35. )
  36. convey.Convey("PprofWarn", t, func() {
  37. pws, err = svr.PprofWarn(context.Background(), req)
  38. convey.So(err, convey.ShouldBeNil)
  39. convey.So(pws, convey.ShouldNotBeEmpty)
  40. for _, pw := range pws {
  41. t.Logf("pw.Kind=%d, pw.URL=%s", pw.Kind, pw.URL)
  42. }
  43. })
  44. }