Skip to content

Commit

Permalink
APM: use non-default port for tests to avoid running agent (#27636)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgajg1134 authored Jul 16, 2024
1 parent edd7e6f commit 379e006
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/trace/api/api_oom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func TestOOMKill(t *testing.T) {
conf.Endpoints[0].APIKey = "apikey_2"
conf.WatchdogInterval = time.Millisecond
conf.MaxMemory = 0.1 * 1000 * 1000 // 100KB
conf.ReceiverPort = 8327 // use non-default port to avoid conflict with running agent

r := newTestReceiverFromConfig(conf)
r.Start()
Expand All @@ -58,7 +59,7 @@ func TestOOMKill(t *testing.T) {
wg.Add(1)
go func() {
defer wg.Done()
resp, err := http.Post("http://localhost:8126/v0.4/traces", "application/msgpack", bytes.NewReader(data))
resp, err := http.Post("http://localhost:8327/v0.4/traces", "application/msgpack", bytes.NewReader(data))
if err != nil {
t.Log("Error posting payload", err)
return
Expand Down
5 changes: 4 additions & 1 deletion pkg/trace/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func newTestReceiverConfig() *config.AgentConfig {
conf := config.New()
conf.Endpoints[0].APIKey = "test"
conf.DecoderTimeout = 10000
conf.ReceiverPort = 8326 // use non-default port to avoid conflict with a running agent

return conf
}
Expand Down Expand Up @@ -166,6 +167,8 @@ func TestStateHeaders(t *testing.T) {
assert := assert.New(t)
cfg := newTestReceiverConfig()
cfg.AgentVersion = "testVersion"
url := fmt.Sprintf("http://%s:%d",
cfg.ReceiverHost, cfg.ReceiverPort)
r := newTestReceiverFromConfig(cfg)
r.Start()
defer r.Stop()
Expand All @@ -183,7 +186,7 @@ func TestStateHeaders(t *testing.T) {
"/v0.5/traces",
"/v0.7/traces",
} {
resp, err := http.Post("http://localhost:8126"+e, "application/msgpack", bytes.NewReader(data))
resp, err := http.Post(url+e, "application/msgpack", bytes.NewReader(data))
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 379e006

Please sign in to comment.