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

Tests: Listen on localhost instead of 0.0.0.0 #609

Merged
merged 1 commit into from
Oct 21, 2024
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
4 changes: 3 additions & 1 deletion kv/memberlist/tcp_transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestTCPTransport_WriteTo_ShouldNotLogAsWarningExpectedFailures(t *testing.T

cfg := TCPTransportConfig{}
flagext.DefaultValues(&cfg)
cfg.BindAddrs = []string{"127.0.0.1"}
cfg.BindAddrs = getLocalhostAddrs()
cfg.BindPort = 0
if testData.setup != nil {
testData.setup(t, &cfg)
Expand Down Expand Up @@ -88,6 +88,7 @@ func TestTCPTransportWriteToUnreachableAddr(t *testing.T) {

cfg := TCPTransportConfig{}
flagext.DefaultValues(&cfg)
cfg.BindAddrs = getLocalhostAddrs()
cfg.MaxConcurrentWrites = writeCt
cfg.PacketDialTimeout = 500 * time.Millisecond
transport, err := NewTCPTransport(cfg, logger, nil)
Expand Down Expand Up @@ -128,6 +129,7 @@ func TestTCPTransportWriterAcquireTimeout(t *testing.T) {

cfg := TCPTransportConfig{}
flagext.DefaultValues(&cfg)
cfg.BindAddrs = getLocalhostAddrs()
cfg.MaxConcurrentWrites = 1
cfg.AcquireWriterTimeout = 1 * time.Millisecond // very short timeout
transport, err := NewTCPTransport(cfg, logger, nil)
Expand Down
4 changes: 4 additions & 0 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ func TestTCPv4Network(t *testing.T) {
func TestDefaultAddresses(t *testing.T) {
var cfg Config
cfg.RegisterFlags(flag.NewFlagSet("", flag.ExitOnError))
cfg.GRPCListenAddress = "localhost"
cfg.HTTPListenAddress = "localhost"
cfg.HTTPListenPort = 9090
cfg.MetricsNamespace = "testing_addresses"

Expand Down Expand Up @@ -949,6 +951,8 @@ func TestGrpcOverProxyProtocol(t *testing.T) {
cfg.RegisterFlags(flag.NewFlagSet("", flag.ExitOnError))
cfg.ProxyProtocolEnabled = true
// Set this to 0 to have it choose a random port
cfg.HTTPListenAddress = "localhost"
cfg.GRPCListenAddress = "localhost"
cfg.HTTPListenPort = 0

fakeSourceIP := "1.2.3.4"
Expand Down