prometheus_test.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/apm/model/monitor"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestService_RPCMonitor(t *testing.T) {
  9. var (
  10. c = context.Background()
  11. mts []*monitor.Monitor
  12. err error
  13. )
  14. convey.Convey("Prometheus", t, func(ctx convey.C) {
  15. mts, err = svr.RPCMonitor(c)
  16. convey.Convey("Then pts should not be nil, err should be nil", func(ctx convey.C) {
  17. ctx.So(mts, convey.ShouldNotBeEmpty)
  18. ctx.So(err, convey.ShouldBeNil)
  19. for _, mt := range mts {
  20. t.Logf("mt.Interface=%s, mt.Cost=%d, mt.Count=%d", mt.Interface, mt.Cost, mt.Count)
  21. }
  22. })
  23. })
  24. }
  25. func TestService_HttpMonitor(t *testing.T) {
  26. var (
  27. c = context.Background()
  28. mts []*monitor.Monitor
  29. err error
  30. )
  31. convey.Convey("Prometheus", t, func(ctx convey.C) {
  32. mts, err = svr.HTTPMonitor(c)
  33. convey.Convey("Then pts should not be nil, err should be nil", func(ctx convey.C) {
  34. ctx.So(mts, convey.ShouldNotBeEmpty)
  35. ctx.So(err, convey.ShouldBeNil)
  36. for _, mt := range mts {
  37. t.Logf("mt.Interface=%s, mt.Cost=%d, mt.Count=%d", mt.Interface, mt.Cost, mt.Count)
  38. }
  39. })
  40. })
  41. }
  42. func TestService_TenCent(t *testing.T) {
  43. var (
  44. c = context.Background()
  45. mts = make([]*monitor.Monitor, 0)
  46. err error
  47. )
  48. convey.Convey("TenCent", t, func(ctx convey.C) {
  49. mts, err = svr.TenCent(c)
  50. convey.Convey("Then mts should not be nil, err should be nil", func(ctx convey.C) {
  51. ctx.So(mts, convey.ShouldNotBeEmpty)
  52. ctx.So(err, convey.ShouldBeNil)
  53. for _, mt := range mts {
  54. t.Logf("mt.AppID=%s, mt.Interface=%s, mt.Count=%d", mt.AppID, mt.Interface, mt.Count)
  55. }
  56. })
  57. })
  58. }
  59. func TestService_KingSoft(t *testing.T) {
  60. var (
  61. c = context.Background()
  62. mts = make([]*monitor.Monitor, 0)
  63. err error
  64. )
  65. convey.Convey("KingSoft", t, func(ctx convey.C) {
  66. mts, err = svr.KingSoft(c)
  67. convey.Convey("Then mts should not be nil, err should be nil", func(ctx convey.C) {
  68. ctx.So(mts, convey.ShouldNotBeEmpty)
  69. ctx.So(err, convey.ShouldBeNil)
  70. for _, mt := range mts {
  71. t.Logf("mt.AppID=%s, mt.Interface=%s, mt.Count=%d", mt.AppID, mt.Interface, mt.Count)
  72. }
  73. })
  74. })
  75. }
  76. func TestService_DataBus(t *testing.T) {
  77. var (
  78. c = context.Background()
  79. mts = make([]*monitor.Monitor, 0)
  80. err error
  81. )
  82. convey.Convey("DataBus", t, func(ctx convey.C) {
  83. mts, err = svr.DataBus(c)
  84. convey.Convey("Then mts should not be nil, err should be nil", func(ctx convey.C) {
  85. ctx.So(mts, convey.ShouldNotBeEmpty)
  86. ctx.So(err, convey.ShouldBeNil)
  87. for _, mt := range mts {
  88. t.Logf("mt.AppID=%s, mt.Interface=%s, mt.Count=%d", mt.AppID, mt.Interface, mt.Count)
  89. }
  90. })
  91. })
  92. }