Skip to content

Commit

Permalink
[chore] ensure test is testing ipv6 addressing
Browse files Browse the repository at this point in the history
This ensures that the ipv6 hostname includes a `[]` around the
host, otherwise this confuses the net library that tries to start a
server.

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
  • Loading branch information
codeboten committed Oct 17, 2024
1 parent 3456b43 commit f86add8
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions service/internal/promtest/server_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package promtest // import "go.opentelemetry.io/collector/service/internal/promtest"

import (
"fmt"
"net"
"strconv"
"testing"
Expand All @@ -14,7 +15,9 @@ import (
)

func GetAvailableLocalIPv6AddressPrometheus(t testing.TB) *config.Prometheus {
return addrToPrometheus(testutil.GetAvailableLocalIPv6Address(t))
p := addrToPrometheus(testutil.GetAvailableLocalIPv6Address(t))
p.Host = ptr(fmt.Sprintf("[%s]", *p.Host))
return p
}

func GetAvailableLocalAddressPrometheus(t testing.TB) *config.Prometheus {
Expand All @@ -31,7 +34,17 @@ func addrToPrometheus(address string) *config.Prometheus {
return nil
}
return &config.Prometheus{
Host: &host,
Port: &portInt,
Host: &host,
Port: &portInt,
WithoutScopeInfo: ptr(true),
WithoutUnits: ptr(true),
WithoutTypeSuffix: ptr(true),
WithResourceConstantLabels: &config.IncludeExclude{
Excluded: []string{},
},
}
}

func ptr[T any](v T) *T {
return &v
}

0 comments on commit f86add8

Please sign in to comment.