Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testbed: Support UDP in addition to TCP for agent health check #2633

Merged
merged 3 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions testbed/testbed/senders.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"fmt"
"log"
"net"

"go.uber.org/zap"

Expand Down Expand Up @@ -45,8 +46,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 @@ -82,8 +83,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 @@ -132,7 +134,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 @@ -163,7 +165,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 @@ -384,7 +386,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 @@ -579,7 +581,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