From ede314430007fc3595d3d9f8021c45deb4c379b9 Mon Sep 17 00:00:00 2001 From: Mark Rushakoff <mark@influxdb.com> Date: Wed, 14 Dec 2016 08:17:52 -0800 Subject: [PATCH] Bind to random port in service open/close tests These tests have been flaky on Circle in the past due to those specific ports being in use. Binding to port 0 will pick a random, available port. --- services/graphite/service_test.go | 4 +++- services/opentsdb/service_test.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/services/graphite/service_test.go b/services/graphite/service_test.go index bcc62d4026..a77a24aa09 100644 --- a/services/graphite/service_test.go +++ b/services/graphite/service_test.go @@ -16,7 +16,9 @@ import ( ) func Test_Service_OpenClose(t *testing.T) { - c := Config{BindAddress: ":35422"} + // Let the OS assign a random port since we are only opening and closing the service, + // not actually connecting to it. + c := Config{BindAddress: "127.0.0.1:0"} service := NewTestService(&c) // Closing a closed service is fine. diff --git a/services/opentsdb/service_test.go b/services/opentsdb/service_test.go index 745ca40921..d5ba75acf2 100644 --- a/services/opentsdb/service_test.go +++ b/services/opentsdb/service_test.go @@ -20,7 +20,9 @@ import ( ) func Test_Service_OpenClose(t *testing.T) { - service := NewTestService("db0", "127.0.0.1:45362") + // Let the OS assign a random port since we are only opening and closing the service, + // not actually connecting to it. + service := NewTestService("db0", "127.0.0.1:0") // Closing a closed service is fine. if err := service.Service.Close(); err != nil {