Skip to content

Commit

Permalink
testbed GetEndpoint return type "net.Addr" instead of "string"
Browse files Browse the repository at this point in the history
to support udp endpoint
  • Loading branch information
wph95 committed Mar 26, 2021
1 parent e3c5965 commit 4dd3ceb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 10 additions & 8 deletions testbed/testbed/senders.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"io/ioutil"
"log"
"net"
"os"
"strconv"
"time"
Expand Down Expand Up @@ -51,8 +52,8 @@ type DataSender interface {
// Send any accumulated data.
Flush()

// Return the port to which this sender will send data.
GetEndpoint() string
// Return the address to which this sender will send data.
GetEndpoint() net.Addr

// Generate a config string to place in receiver part of collector config
// so that it can receive data from this sender.
Expand Down Expand Up @@ -88,8 +89,9 @@ type DataSenderBase struct {
Host string
}

func (dsb *DataSenderBase) GetEndpoint() string {
return fmt.Sprintf("%s:%d", dsb.Host, dsb.Port)
func (dsb *DataSenderBase) GetEndpoint() net.Addr {
addr, _ := net.ResolveTCPAddr("tcp", fmt.Sprintf("%s:%d", dsb.Host, dsb.Port))
return addr
}

func (dsb *DataSenderBase) ReportFatalError(err error) {
Expand Down Expand Up @@ -138,7 +140,7 @@ func (je *JaegerGRPCDataSender) Start() error {
cfg.RetrySettings.Enabled = false
// Disable sending queue, we should push data from the caller goroutine.
cfg.QueueSettings.Enabled = false
cfg.Endpoint = je.GetEndpoint()
cfg.Endpoint = je.GetEndpoint().String()
cfg.TLSSetting = configtls.TLSClientSetting{
Insecure: true,
}
Expand Down Expand Up @@ -169,7 +171,7 @@ type ocDataSender struct {
}

func (ods *ocDataSender) fillConfig(cfg *opencensusexporter.Config) *opencensusexporter.Config {
cfg.Endpoint = ods.GetEndpoint()
cfg.Endpoint = ods.GetEndpoint().String()
cfg.TLSSetting = configtls.TLSClientSetting{
Insecure: true,
}
Expand Down Expand Up @@ -390,7 +392,7 @@ type otlpDataSender struct {
}

func (ods *otlpDataSender) fillConfig(cfg *otlpexporter.Config) *otlpexporter.Config {
cfg.Endpoint = ods.GetEndpoint()
cfg.Endpoint = ods.GetEndpoint().String()
// Disable retries, we should push data and if error just log it.
cfg.RetrySettings.Enabled = false
// Disable sending queue, we should push data from the caller goroutine.
Expand Down Expand Up @@ -585,7 +587,7 @@ func NewPrometheusDataSender(host string, port int) *PrometheusDataSender {
func (pds *PrometheusDataSender) Start() error {
factory := prometheusexporter.NewFactory()
cfg := factory.CreateDefaultConfig().(*prometheusexporter.Config)
cfg.Endpoint = pds.GetEndpoint()
cfg.Endpoint = pds.GetEndpoint().String()
cfg.Namespace = pds.namespace

exp, err := factory.CreateMetricsExporter(context.Background(), defaultExporterParams(), cfg)
Expand Down
4 changes: 2 additions & 2 deletions testbed/testbed/test_case.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,13 @@ func (tc *TestCase) StartAgent(args ...string) {
}()

endpoint := tc.LoadGenerator.sender.GetEndpoint()
if endpoint != "" {
if endpoint != nil {
// Wait for agent to start. We consider the agent started when we can
// connect to the port to which we intend to send load. We only do this
// if the endpoint is not-empty, i.e. the sender does use network (some senders
// like text log writers don't).
tc.WaitFor(func() bool {
_, err := net.Dial("tcp", tc.LoadGenerator.sender.GetEndpoint())
_, err := net.Dial(tc.LoadGenerator.sender.GetEndpoint().Network(), tc.LoadGenerator.sender.GetEndpoint().String())
return err == nil
})
}
Expand Down

0 comments on commit 4dd3ceb

Please sign in to comment.