Skip to content

Commit

Permalink
Tests: Listen on localhost instead of 0.0.0.0
Browse files Browse the repository at this point in the history
Closes #381

The MacOS network dialog is a bit annoying
  • Loading branch information
julienduchesne committed Oct 10, 2024
1 parent 879ff5a commit c4c47e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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

0 comments on commit c4c47e1

Please sign in to comment.