diff --git a/.circleci/config.yml b/.circleci/config.yml index b55b22383..c4f376e0d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,46 +1,101 @@ --- -defaults: &defaults - docker: - - image: 'circleci/golang:1.9.4' - working_directory: '/go/src/github.com/influxdata/telegraf' +defaults: + defaults: &defaults + working_directory: '/go/src/github.com/influxdata/telegraf' + go-1_8: &go-1_8 + docker: + - image: 'circleci/golang:1.8.7' + go-1_9: &go-1_9 + docker: + - image: 'circleci/golang:1.9.5' + go-1_10: &go-1_10 + docker: + - image: 'circleci/golang:1.10.1' + version: 2 jobs: - build: - <<: *defaults + deps: + <<: [ *defaults, *go-1_10 ] steps: - checkout - run: 'make deps' + - persist_to_workspace: + root: '/go/src' + paths: + - '*' + test-go-1.8: + <<: [ *defaults, *go-1_8 ] + steps: + - attach_workspace: + at: '/go/src' + - run: 'make test-ci' + test-go-1.9: + <<: [ *defaults, *go-1_9 ] + steps: + - attach_workspace: + at: '/go/src' + - run: 'make test-ci' + test-go-1.10: + <<: [ *defaults, *go-1_10 ] + steps: + - attach_workspace: + at: '/go/src' - run: 'make test-ci' release: - <<: *defaults + <<: [ *defaults, *go-1_10 ] steps: - - checkout + - attach_workspace: + at: '/go/src' - run: './scripts/release.sh' - store_artifacts: path: './artifacts' destination: '.' nightly: - <<: *defaults + <<: [ *defaults, *go-1_10 ] steps: - - checkout + - attach_workspace: + at: '/go/src' - run: './scripts/release.sh' - store_artifacts: path: './artifacts' destination: '.' + workflows: version: 2 build_and_release: jobs: - - 'build' + - 'deps' + - 'test-go-1.8': + requires: + - 'deps' + - 'test-go-1.9': + requires: + - 'deps' + - 'test-go-1.10': + requires: + - 'deps' - 'release': requires: - - 'build' + - 'test-go-1.8' + - 'test-go-1.9' + - 'test-go-1.10' nightly: jobs: - - 'build' + - 'deps' + - 'test-go-1.8': + requires: + - 'deps' + - 'test-go-1.9': + requires: + - 'deps' + - 'test-go-1.9': + requires: + - 'deps' - 'nightly': requires: - - 'build' + - 'test-go-1.8' + - 'test-go-1.9' + - 'test-go-1.10' triggers: - schedule: cron: "0 18 * * *" diff --git a/appveyor.yml b/appveyor.yml index 91f86cbb5..7b464f6e0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,11 +13,11 @@ platform: x64 install: - IF NOT EXIST "C:\Cache" mkdir C:\Cache - - IF NOT EXIST "C:\Cache\go1.9.4.msi" curl -o "C:\Cache\go1.9.4.msi" https://storage.googleapis.com/golang/go1.9.4.windows-amd64.msi + - IF NOT EXIST "C:\Cache\go1.10.1.msi" curl -o "C:\Cache\go1.10.1.msi" https://storage.googleapis.com/golang/go1.10.1.windows-amd64.msi - IF NOT EXIST "C:\Cache\gnuwin32-bin.zip" curl -o "C:\Cache\gnuwin32-bin.zip" https://dl.influxdata.com/telegraf/ci/make-3.81-bin.zip - IF NOT EXIST "C:\Cache\gnuwin32-dep.zip" curl -o "C:\Cache\gnuwin32-dep.zip" https://dl.influxdata.com/telegraf/ci/make-3.81-dep.zip - IF EXIST "C:\Go" rmdir /S /Q C:\Go - - msiexec.exe /i "C:\Cache\go1.9.4.msi" /quiet + - msiexec.exe /i "C:\Cache\go1.10.1.msi" /quiet - 7z x "C:\Cache\gnuwin32-bin.zip" -oC:\GnuWin32 -y - 7z x "C:\Cache\gnuwin32-dep.zip" -oC:\GnuWin32 -y - go version diff --git a/plugins/inputs/statsd/statsd_test.go b/plugins/inputs/statsd/statsd_test.go index a9161e5ba..3fbc45640 100644 --- a/plugins/inputs/statsd/statsd_test.go +++ b/plugins/inputs/statsd/statsd_test.go @@ -59,7 +59,7 @@ func TestConcurrentConns(t *testing.T) { require.NoError(t, listener.Start(acc)) defer listener.Stop() - time.Sleep(time.Millisecond * 25) + time.Sleep(time.Millisecond * 250) _, err := net.Dial("tcp", "127.0.0.1:8125") assert.NoError(t, err) _, err = net.Dial("tcp", "127.0.0.1:8125") @@ -72,7 +72,7 @@ func TestConcurrentConns(t *testing.T) { assert.NoError(t, err) _, err = conn.Write([]byte(testMsg)) assert.NoError(t, err) - time.Sleep(time.Millisecond * 10) + time.Sleep(time.Millisecond * 100) assert.Zero(t, acc.NFields()) } @@ -89,7 +89,7 @@ func TestConcurrentConns1(t *testing.T) { require.NoError(t, listener.Start(acc)) defer listener.Stop() - time.Sleep(time.Millisecond * 25) + time.Sleep(time.Millisecond * 250) _, err := net.Dial("tcp", "127.0.0.1:8125") assert.NoError(t, err) @@ -100,7 +100,7 @@ func TestConcurrentConns1(t *testing.T) { assert.NoError(t, err) _, err = conn.Write([]byte(testMsg)) assert.NoError(t, err) - time.Sleep(time.Millisecond * 10) + time.Sleep(time.Millisecond * 100) assert.Zero(t, acc.NFields()) } @@ -116,7 +116,7 @@ func TestCloseConcurrentConns(t *testing.T) { acc := &testutil.Accumulator{} require.NoError(t, listener.Start(acc)) - time.Sleep(time.Millisecond * 25) + time.Sleep(time.Millisecond * 250) _, err := net.Dial("tcp", "127.0.0.1:8125") assert.NoError(t, err) _, err = net.Dial("tcp", "127.0.0.1:8125") @@ -141,7 +141,7 @@ func BenchmarkUDP(b *testing.B) { panic(err) } - time.Sleep(time.Millisecond * 25) + time.Sleep(time.Millisecond * 250) conn, err := net.Dial("udp", "127.0.0.1:8125") if err != nil { panic(err) @@ -172,7 +172,7 @@ func BenchmarkTCP(b *testing.B) { panic(err) } - time.Sleep(time.Millisecond * 25) + time.Sleep(time.Millisecond * 250) conn, err := net.Dial("tcp", "127.0.0.1:8125") if err != nil { panic(err) diff --git a/plugins/inputs/zipkin/zipkin.go b/plugins/inputs/zipkin/zipkin.go index 02d82fac0..18a63dccd 100644 --- a/plugins/inputs/zipkin/zipkin.go +++ b/plugins/inputs/zipkin/zipkin.go @@ -29,6 +29,11 @@ const ( DefaultShutdownTimeout = 5 ) +var ( + // DefaultNetwork is the network to listen on; use only in tests. + DefaultNetwork = "tcp" +) + // Recorder represents a type which can record zipkin trace data as well as // any accompanying errors, and process that data. type Recorder interface { @@ -94,7 +99,7 @@ func (z *Zipkin) Start(acc telegraf.Accumulator) error { } addr := ":" + strconv.Itoa(z.Port) - ln, err := net.Listen("tcp", addr) + ln, err := net.Listen(DefaultNetwork, addr) if err != nil { return err } diff --git a/plugins/inputs/zipkin/zipkin_test.go b/plugins/inputs/zipkin/zipkin_test.go index b14fb3aca..b71e5bf4e 100644 --- a/plugins/inputs/zipkin/zipkin_test.go +++ b/plugins/inputs/zipkin/zipkin_test.go @@ -557,6 +557,10 @@ func TestZipkinPlugin(t *testing.T) { }, } + // Workaround for Go 1.8 + // https://github.com/golang/go/issues/18806 + DefaultNetwork = "tcp4" + z := &Zipkin{ Path: "/api/v1/spans", Port: 0, diff --git a/plugins/outputs/influxdb/udp_test.go b/plugins/outputs/influxdb/udp_test.go index 552e1c0d6..fd05c6905 100644 --- a/plugins/outputs/influxdb/udp_test.go +++ b/plugins/outputs/influxdb/udp_test.go @@ -197,7 +197,7 @@ func TestUDP_SerializeError(t *testing.T) { } func TestUDP_WriteWithRealConn(t *testing.T) { - conn, err := net.ListenPacket("udp", ":0") + conn, err := net.ListenPacket("udp", "127.0.0.0:0") require.NoError(t, err) metrics := []telegraf.Metric{