Skip to content
Snippets Groups Projects
Commit 927de877 authored by Tom Wilkie's avatar Tom Wilkie
Browse files

Explictly listen on localhost in tests, to stop warning on MacOS.


Signed-off-by: default avatarTom Wilkie <tom.wilkie@gmail.com>
parent c9d3c79c
No related branches found
No related tags found
No related merge requests found
......@@ -31,10 +31,11 @@ import (
"github.com/grafana/loki/pkg/promtail/scrape"
)
const httpTestPort = 9080
func TestPromtail(t *testing.T) {
// Setup.
w := log.NewSyncWriter(os.Stderr)
logger := log.NewLogfmtLogger(w)
logger = level.NewFilter(logger, level.AllowInfo())
......@@ -71,7 +72,7 @@ func TestPromtail(t *testing.T) {
}
}()
go func() {
if err = http.ListenAndServe("127.0.0.1:3100", nil); err != nil {
if err = http.ListenAndServe("localhost:3100", nil); err != nil {
err = errors.Wrap(err, "Failed to start web server to receive logs")
}
}()
......@@ -398,7 +399,7 @@ func (h *testServerHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
func getPromMetrics(t *testing.T) ([]byte, string) {
resp, err := http.Get("http://localhost:80/metrics")
resp, err := http.Get(fmt.Sprintf("http://localhost:%d/metrics", httpTestPort))
if err != nil {
t.Fatal("Could not query metrics endpoint", err)
}
......@@ -457,6 +458,11 @@ func buildTestConfig(t *testing.T, positionsFileName string, logDirName string)
// Init everything with default values.
flagext.RegisterFlags(&cfg)
// Make promtail listen on localhost to avoid prompts on MacOS.
cfg.ServerConfig.HTTPListenHost = "localhost"
cfg.ServerConfig.HTTPListenPort = httpTestPort
cfg.ServerConfig.GRPCListenHost = "localhost"
// Override some of those defaults
cfg.ClientConfig.URL = clientURL
cfg.ClientConfig.BatchWait = 10 * time.Millisecond
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment