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

fix(inputs.socket_listener): Fix race in tests #13300

Merged
merged 1 commit into from
May 22, 2023

Conversation

srebhan
Copy link
Member

@srebhan srebhan commented May 22, 2023

This PR tries to fix a race in the unit-test observed on CI.

=== Failed
=== FAIL: plugins/inputs/socket_listener TestSocketListener/TCP_with_TLS (0.28s)
2023/05/19 19:23:12 I! [] Listening on tcp://127.0.0.1:49719
==================
WARNING: DATA RACE
Read at 0x00c0005a6960 by goroutine 51:
  reflect.maplen()
      C:/Program Files/Go/src/runtime/map.go:1394 +0x0
  reflect.Value.lenNonSlice()
      C:/Program Files/Go/src/reflect/value.go:1704 +0x26d
  reflect.Value.Len()
      C:/Program Files/Go/src/reflect/value.go:1693 +0x290
  github.com/stretchr/testify/assert.isEmpty()
      C:/Users/circleci.PACKER-64370BA5/go/pkg/mod/github.com/stretchr/testify@v1.8.2/assert/assertions.go:567 +0x281
  github.com/stretchr/testify/assert.NotEmpty()
      C:/Users/circleci.PACKER-64370BA5/go/pkg/mod/github.com/stretchr/testify@v1.8.2/assert/assertions.go:607 +0x5c
  github.com/stretchr/testify/require.NotEmpty()
      C:/Users/circleci.PACKER-64370BA5/go/pkg/mod/github.com/stretchr/testify@v1.8.2/require/require.go:1349 +0xa4
  github.com/influxdata/telegraf/plugins/inputs/socket_listener.TestSocketListener.func1()
      C:/Users/circleci.PACKER-64370BA5/project/plugins/inputs/socket_listener/socket_listener_test.go:195 +0x15fe
  testing.tRunner()
      C:/Program Files/Go/src/testing/testing.go:1576 +0x216
  testing.(*T).Run.func1()
      C:/Program Files/Go/src/testing/testing.go:1629 +0x47

Previous write at 0x00c0005a6960 by goroutine 54:
  runtime.mapdelete()
      C:/Program Files/Go/src/runtime/map.go:695 +0x0
  github.com/influxdata/telegraf/plugins/inputs/socket_listener.(*streamListener).closeConnection()
      C:/Users/circleci.PACKER-64370BA5/project/plugins/inputs/socket_listener/stream_listener.go:141 +0x2b4
  github.com/influxdata/telegraf/plugins/inputs/socket_listener.(*streamListener).listen.func1()
      C:/Users/circleci.PACKER-64370BA5/project/plugins/inputs/socket_listener/stream_listener.go:200 +0x204
  github.com/influxdata/telegraf/plugins/inputs/socket_listener.(*streamListener).listen.func3()
      C:/Users/circleci.PACKER-64370BA5/project/plugins/inputs/socket_listener/stream_listener.go:202 +0x58

Goroutine 51 (running) created at:
  testing.(*T).Run()
      C:/Program Files/Go/src/testing/testing.go:1629 +0x805
  github.com/influxdata/telegraf/plugins/inputs/socket_listener.TestSocketListener()
      C:/Users/circleci.PACKER-64370BA5/project/plugins/inputs/socket_listener/socket_listener_test.go:116 +0x944
  testing.tRunner()
      C:/Program Files/Go/src/testing/testing.go:1576 +0x216
  testing.(*T).Run.func1()
      C:/Program Files/Go/src/testing/testing.go:1629 +0x47

Goroutine 54 (finished) created at:
  github.com/influxdata/telegraf/plugins/inputs/socket_listener.(*streamListener).listen()
      C:/Users/circleci.PACKER-64370BA5/project/plugins/inputs/socket_listener/stream_listener.go:192 +0x4e9
  github.com/influxdata/telegraf/plugins/inputs/socket_listener.(*SocketListener).Start.func1()
      C:/Users/circleci.PACKER-64370BA5/project/plugins/inputs/socket_listener/socket_listener.go:241 +0xd8
==================
    testing.go:1446: race detected during execution of test

=== FAIL: plugins/inputs/socket_listener TestSocketListener (0.75s)
    testing.go:1446: race detected during execution of test

@telegraf-tiger telegraf-tiger bot added fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels May 22, 2023
@telegraf-tiger
Copy link
Contributor

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label May 22, 2023
Copy link
Contributor

@powersj powersj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - hopefully this gets it!

@powersj powersj merged commit 759691a into influxdata:master May 22, 2023
powersj pushed a commit that referenced this pull request May 22, 2023
@srebhan srebhan added this to the v1.26.3 milestone Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants