Skip to content

Commit 859a4b4

Browse files
authored
testbed: Support UDP in addition to TCP for agent health check (#2633)
Testbed hardcodes "tcp" in agent_start/health_check. but I need add testbed add a syslog_input with "udp" testcase. GetEndpoint now returns type "net.Addr" instead of "string" to support udp endpoint.
1 parent abcffc3 commit 859a4b4

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

testbed/testbed/senders.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"context"
1919
"fmt"
2020
"log"
21+
"net"
2122

2223
"go.uber.org/zap"
2324

@@ -45,8 +46,8 @@ type DataSender interface {
4546
// Send any accumulated data.
4647
Flush()
4748

48-
// Return the port to which this sender will send data.
49-
GetEndpoint() string
49+
// Return the address to which this sender will send data.
50+
GetEndpoint() net.Addr
5051

5152
// Generate a config string to place in receiver part of collector config
5253
// so that it can receive data from this sender.
@@ -82,8 +83,9 @@ type DataSenderBase struct {
8283
Host string
8384
}
8485

85-
func (dsb *DataSenderBase) GetEndpoint() string {
86-
return fmt.Sprintf("%s:%d", dsb.Host, dsb.Port)
86+
func (dsb *DataSenderBase) GetEndpoint() net.Addr {
87+
addr, _ := net.ResolveTCPAddr("tcp", fmt.Sprintf("%s:%d", dsb.Host, dsb.Port))
88+
return addr
8789
}
8890

8991
func (dsb *DataSenderBase) ReportFatalError(err error) {
@@ -132,7 +134,7 @@ func (je *JaegerGRPCDataSender) Start() error {
132134
cfg.RetrySettings.Enabled = false
133135
// Disable sending queue, we should push data from the caller goroutine.
134136
cfg.QueueSettings.Enabled = false
135-
cfg.Endpoint = je.GetEndpoint()
137+
cfg.Endpoint = je.GetEndpoint().String()
136138
cfg.TLSSetting = configtls.TLSClientSetting{
137139
Insecure: true,
138140
}
@@ -163,7 +165,7 @@ type ocDataSender struct {
163165
}
164166

165167
func (ods *ocDataSender) fillConfig(cfg *opencensusexporter.Config) *opencensusexporter.Config {
166-
cfg.Endpoint = ods.GetEndpoint()
168+
cfg.Endpoint = ods.GetEndpoint().String()
167169
cfg.TLSSetting = configtls.TLSClientSetting{
168170
Insecure: true,
169171
}
@@ -384,7 +386,7 @@ type otlpDataSender struct {
384386
}
385387

386388
func (ods *otlpDataSender) fillConfig(cfg *otlpexporter.Config) *otlpexporter.Config {
387-
cfg.Endpoint = ods.GetEndpoint()
389+
cfg.Endpoint = ods.GetEndpoint().String()
388390
// Disable retries, we should push data and if error just log it.
389391
cfg.RetrySettings.Enabled = false
390392
// Disable sending queue, we should push data from the caller goroutine.
@@ -579,7 +581,7 @@ func NewPrometheusDataSender(host string, port int) *PrometheusDataSender {
579581
func (pds *PrometheusDataSender) Start() error {
580582
factory := prometheusexporter.NewFactory()
581583
cfg := factory.CreateDefaultConfig().(*prometheusexporter.Config)
582-
cfg.Endpoint = pds.GetEndpoint()
584+
cfg.Endpoint = pds.GetEndpoint().String()
583585
cfg.Namespace = pds.namespace
584586

585587
exp, err := factory.CreateMetricsExporter(context.Background(), defaultExporterParams(), cfg)

testbed/testbed/test_case.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,13 @@ func (tc *TestCase) StartAgent(args ...string) {
189189
}()
190190

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

0 commit comments

Comments
 (0)