Skip to content

[Auditbeat] TestIncludedExcludedFiles fails with race condition #8009

Closed
@andrewkroh

Description

TestIncludedExcludedFiles fails sometimes with a race condition.

command [go test -race -cover -coverprofile /tmp/gotestcover-882901875 github.com/elastic/beats/auditbeat/module/file_integrity]: exit status 1
==================
WARNING: DATA RACE
Read at 0x00c42035b860 by goroutine 35:
  runtime.mapaccess2_faststr()
      /var/lib/jenkins/.gvm/versions/go1.10.3.linux.amd64/src/runtime/hashmap_fast.go:261 +0x0
  github.com/elastic/beats/auditbeat/module/file_integrity/monitor.FileTree.getByComponents()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/auditbeat/module/file_integrity/monitor/filetree.go:126 +0xe1
  github.com/elastic/beats/auditbeat/module/file_integrity/monitor.FileTree.At()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/auditbeat/module/file_integrity/monitor/filetree.go:93 +0xb4
  github.com/elastic/beats/auditbeat/module/file_integrity/monitor.FileTree.Visit()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/auditbeat/module/file_integrity/monitor/filetree.go:84 +0x53
  github.com/elastic/beats/auditbeat/module/file_integrity/monitor.(*recursiveWatcher).forwardEvents()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/auditbeat/module/file_integrity/monitor/recursive.go:136 +0x3fc

Previous write at 0x00c42035b860 by goroutine 47:
  [failed to restore the stack]

Goroutine 35 (running) created at:
  github.com/elastic/beats/auditbeat/module/file_integrity/monitor.(*recursiveWatcher).Start()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/auditbeat/module/file_integrity/monitor/recursive.go:46 +0x9f
  github.com/elastic/beats/auditbeat/module/file_integrity.(*reader).Start()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/auditbeat/module/file_integrity/eventreader_fsnotify.go:56 +0x84
  github.com/elastic/beats/auditbeat/module/file_integrity.(*MetricSet).init()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/auditbeat/module/file_integrity/metricset.go:158 +0x358
  github.com/elastic/beats/auditbeat/module/file_integrity.(*MetricSet).Run()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/auditbeat/module/file_integrity/metricset.go:111 +0x85
  github.com/elastic/beats/metricbeat/mb/testing.RunPushMetricSetV2.func1()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/metricbeat/mb/testing/modules.go:337 +0xf9

Goroutine 47 (finished) created at:
  github.com/elastic/beats/metricbeat/mb/testing.RunPushMetricSetV2()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/metricbeat/mb/testing/modules.go:331 +0x1c9
  github.com/elastic/beats/auditbeat/module/file_integrity.TestIncludedExcludedFiles()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/auditbeat/module/file_integrity/metricset_test.go:219 +0x9d3
  testing.tRunner()
      /var/lib/jenkins/.gvm/versions/go1.10.3.linux.amd64/src/testing/testing.go:777 +0x16d
==================
==================
WARNING: DATA RACE
Read at 0x00c42041e230 by goroutine 35:
  github.com/elastic/beats/auditbeat/module/file_integrity/monitor.FileTree.getByComponents()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/auditbeat/module/file_integrity/monitor/filetree.go:126 +0xfd
  github.com/elastic/beats/auditbeat/module/file_integrity/monitor.FileTree.At()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/auditbeat/module/file_integrity/monitor/filetree.go:93 +0xb4
  github.com/elastic/beats/auditbeat/module/file_integrity/monitor.FileTree.Visit()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/auditbeat/module/file_integrity/monitor/filetree.go:84 +0x53
  github.com/elastic/beats/auditbeat/module/file_integrity/monitor.(*recursiveWatcher).forwardEvents()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/auditbeat/module/file_integrity/monitor/recursive.go:136 +0x3fc

Previous write at 0x00c42041e230 by goroutine 47:
  [failed to restore the stack]

Goroutine 35 (running) created at:
  github.com/elastic/beats/auditbeat/module/file_integrity/monitor.(*recursiveWatcher).Start()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/auditbeat/module/file_integrity/monitor/recursive.go:46 +0x9f
  github.com/elastic/beats/auditbeat/module/file_integrity.(*reader).Start()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/auditbeat/module/file_integrity/eventreader_fsnotify.go:56 +0x84
  github.com/elastic/beats/auditbeat/module/file_integrity.(*MetricSet).init()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/auditbeat/module/file_integrity/metricset.go:158 +0x358
  github.com/elastic/beats/auditbeat/module/file_integrity.(*MetricSet).Run()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/auditbeat/module/file_integrity/metricset.go:111 +0x85
  github.com/elastic/beats/metricbeat/mb/testing.RunPushMetricSetV2.func1()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/metricbeat/mb/testing/modules.go:337 +0xf9

Goroutine 47 (finished) created at:
  github.com/elastic/beats/metricbeat/mb/testing.RunPushMetricSetV2()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/metricbeat/mb/testing/modules.go:331 +0x1c9
  github.com/elastic/beats/auditbeat/module/file_integrity.TestIncludedExcludedFiles()
      /var/lib/jenkins/workspace/elastic+beats+pull-request+multijob-linux/beat/auditbeat/label/ubuntu/src/github.com/elastic/beats/auditbeat/module/file_integrity/metricset_test.go:219 +0x9d3
  testing.tRunner()
      /var/lib/jenkins/.gvm/versions/go1.10.3.linux.amd64/src/testing/testing.go:777 +0x16d
==================
--- FAIL: TestIncludedExcludedFiles (0.02s)
	testing.go:730: race detected during execution of test
FAIL
coverage: 80.8% of statements
FAIL	github.com/elastic/beats/auditbeat/module/file_integrity	0.522s

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions