collect_test.go 686 B

1234567891011121314151617181920212223242526272829303132
  1. package kafkacollect
  2. import (
  3. "context"
  4. "flag"
  5. "fmt"
  6. "testing"
  7. "time"
  8. "go-common/app/service/main/dapper/model"
  9. "go-common/app/service/main/dapper/pkg/process"
  10. "go-common/library/log"
  11. )
  12. func TestKafkaCollect(t *testing.T) {
  13. flag.Parse()
  14. log.Init(nil)
  15. clt, err := New("lancer_main_dapper_collector", []string{"172.18.33.163:9092", "172.18.33.164:9092", "172.18.33.165:9092"})
  16. if err != nil {
  17. t.Fatal(err)
  18. }
  19. m := process.MockProcess(func(ctx context.Context, protoSpan *model.ProtoSpan) error {
  20. fmt.Printf("%v\n", protoSpan)
  21. return nil
  22. })
  23. clt.RegisterProcess(m)
  24. if err := clt.Start(); err != nil {
  25. t.Fatal(err)
  26. }
  27. defer clt.Close()
  28. time.Sleep(time.Minute)
  29. }