Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix go test -race ./...issues and run in CI #1099

Closed
anderseknert opened this issue Sep 11, 2024 · 1 comment · Fixed by #1102
Closed

Fix go test -race ./...issues and run in CI #1099

anderseknert opened this issue Sep 11, 2024 · 1 comment · Fixed by #1102
Labels

Comments

@anderseknert
Copy link
Member

Not sure what the impact of these issues are, but it'd be good to have a clean state here, and add this check to CI (in a new job, ideally not adding time to the total)

➜ go test -race ./...
?   	github.com/styrainc/regal	[no test files]
?   	github.com/styrainc/regal/bundle	[no test files]
?   	github.com/styrainc/regal/cmd	[no test files]
?   	github.com/styrainc/regal/internal/compile	[no test files]
?   	github.com/styrainc/regal/internal/dap	[no test files]
?   	github.com/styrainc/regal/internal/docs	[no test files]
?   	github.com/styrainc/regal/internal/embeds	[no test files]
?   	github.com/styrainc/regal/internal/explorer	[no test files]
?   	github.com/styrainc/regal/internal/git	[no test files]
ok  	github.com/styrainc/regal/internal/ast	1.662s
ok  	github.com/styrainc/regal/internal/capabilities	1.345s
?   	github.com/styrainc/regal/internal/lsp/cache	[no test files]
?   	github.com/styrainc/regal/internal/lsp/clients	[no test files]
?   	github.com/styrainc/regal/internal/lsp/examples	[no test files]
ok  	github.com/styrainc/regal/internal/capabilities/embedded	4.739s
ok  	github.com/styrainc/regal/internal/io	1.251s
?   	github.com/styrainc/regal/internal/lsp/opa/oracle	[no test files]
?   	github.com/styrainc/regal/internal/lsp/opa/scanner	[no test files]
?   	github.com/styrainc/regal/internal/lsp/opa/tokens	[no test files]
?   	github.com/styrainc/regal/internal/lsp/rego	[no test files]
?   	github.com/styrainc/regal/internal/lsp/types	[no test files]
?   	github.com/styrainc/regal/internal/lsp/types/completion	[no test files]
?   	github.com/styrainc/regal/internal/lsp/types/symbols	[no test files]
?   	github.com/styrainc/regal/internal/metrics	[no test files]
?   	github.com/styrainc/regal/internal/mode	[no test files]
?   	github.com/styrainc/regal/internal/novelty	[no test files]
?   	github.com/styrainc/regal/internal/test	[no test files]
?   	github.com/styrainc/regal/internal/testutil	[no test files]
?   	github.com/styrainc/regal/pkg/builtins	[no test files]
?   	github.com/styrainc/regal/pkg/report	[no test files]
?   	github.com/styrainc/regal/pkg/version	[no test files]
==================
WARNING: DATA RACE
Write at 0x00c001196440 by goroutine 45:
  github.com/styrainc/regal/internal/lsp.(*LanguageServer).StartConfigWorker()
      /Users/anderseknert/git/styra/regal/internal/lsp/server.go:324 +0x8a0
  github.com/styrainc/regal/internal/lsp.TestNewFileTemplating.gowrap1()
      /Users/anderseknert/git/styra/regal/internal/lsp/server_template_test.go:164 +0x4c

Previous read at 0x00c001196440 by goroutine 27:
  github.com/styrainc/regal/internal/lsp.TestNewFileTemplating()
      /Users/anderseknert/git/styra/regal/internal/lsp/server_template_test.go:213 +0x12f8
  testing.tRunner()
      /opt/homebrew/Cellar/go@1.22/1.22.6/libexec/src/testing/testing.go:1689 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go@1.22/1.22.6/libexec/src/testing/testing.go:1742 +0x40

Goroutine 45 (running) created at:
  github.com/styrainc/regal/internal/lsp.TestNewFileTemplating()
      /Users/anderseknert/git/styra/regal/internal/lsp/server_template_test.go:164 +0x56c
  testing.tRunner()
      /opt/homebrew/Cellar/go@1.22/1.22.6/libexec/src/testing/testing.go:1689 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go@1.22/1.22.6/libexec/src/testing/testing.go:1742 +0x40

Goroutine 27 (running) created at:
  testing.(*T).Run()
      /opt/homebrew/Cellar/go@1.22/1.22.6/libexec/src/testing/testing.go:1742 +0x5e4
  testing.runTests.func1()
      /opt/homebrew/Cellar/go@1.22/1.22.6/libexec/src/testing/testing.go:2161 +0x80
  testing.tRunner()
      /opt/homebrew/Cellar/go@1.22/1.22.6/libexec/src/testing/testing.go:1689 +0x180
  testing.runTests()
      /opt/homebrew/Cellar/go@1.22/1.22.6/libexec/src/testing/testing.go:2159 +0x6e0
  testing.(*M).Run()
      /opt/homebrew/Cellar/go@1.22/1.22.6/libexec/src/testing/testing.go:2027 +0xb74
  main.main()
      _testmain.go:79 +0x294
==================
--- FAIL: TestNewFileTemplating (2.04s)
    server_template_test.go:298: received message: {
          "edit": {
            "documentChanges": [
              {
                "edits": [
                  {
                    "newText": "package foo.bar_test\n\nimport rego.v1\n",
                    "range": {
                      "end": {
                        "character": 0,
                        "line": 0
                      },
                      "start": {
                        "character": 0,
                        "line": 0
                      }
                    }
                  }
                ],
                "textDocument": {
                  "uri": "file:///var/folders/bf/hwrlmbv55h350734bhxyqkwh0000gn/T/TestNewFileTemplating3976708076/001/foo/bar/policy_test.rego",
                  "version": null
                }
              },
              {
                "kind": "rename",
                "newUri": "file:///var/folders/bf/hwrlmbv55h350734bhxyqkwh0000gn/T/TestNewFileTemplating3976708076/001/foo/bar_test/policy_test.rego",
                "oldUri": "file:///var/folders/bf/hwrlmbv55h350734bhxyqkwh0000gn/T/TestNewFileTemplating3976708076/001/foo/bar/policy_test.rego",
                "options": {
                  "ignoreIfExists": false,
                  "overwrite": false
                }
              },
              {
                "kind": "delete",
                "options": {
                  "ignoreIfNotExists": true,
                  "recursive": true
                },
                "uri": "file:///var/folders/bf/hwrlmbv55h350734bhxyqkwh0000gn/T/TestNewFileTemplating3976708076/001/foo/bar"
              }
            ]
          },
          "label": "Template new Rego file"
        }
    testing.go:1398: race detected during execution of test
--- FAIL: TestTemplateContentsForFile (0.00s)
    --- FAIL: TestTemplateContentsForFile/empty_deeply_nested_file_is_templated_based_on_root (1.25s)
        testing.go:1398: race detected during execution of test
    --- FAIL: TestTemplateContentsForFile/empty_file_is_templated_as_main_when_no_root (1.27s)
        testing.go:1398: race detected during execution of test
    --- FAIL: TestTemplateContentsForFile/empty_file_is_templated_based_on_root (1.42s)
        testing.go:1398: race detected during execution of test
    --- FAIL: TestTemplateContentsForFile/existing_contents_on_disk (1.30s)
        testing.go:1398: race detected during execution of test
--- FAIL: TestLanguageServerParentDirConfig (5.08s)
    server_test.go:936: expected items: [opa-fmt], got: [directory-package-mismatch opa-fmt]
    testing.go:1398: race detected during execution of test
--- FAIL: TestLanguageServerSingleFile (8.72s)
    server_test.go:195: expected items: [opa-fmt use-assignment-operator], got: [directory-package-mismatch opa-fmt use-assignment-operator]
    server_test.go:459: completion label: neo4j.query
    testing.go:1398: race detected during execution of test
2024/09/11 12:11:33 jsonrpc2: protocol error: io: read/write on closed pipe
--- FAIL: TestLanguageServerMultipleFiles (9.24s)
    server_test.go:617: expected items: [prefer-package-imports], got: [directory-package-mismatch prefer-package-imports]
    server_test.go:635: expected items: [use-assignment-operator], got: [directory-package-mismatch use-assignment-operator]
    server_test.go:678: expected items: [], got: [prefer-package-imports]
    testing.go:1398: race detected during execution of test
FAIL
FAIL	github.com/styrainc/regal/internal/lsp	9.816s
ok  	github.com/styrainc/regal/internal/lsp/bundles	1.692s
ok  	github.com/styrainc/regal/internal/lsp/commands	1.671s
ok  	github.com/styrainc/regal/internal/lsp/completions	1.977s
ok  	github.com/styrainc/regal/internal/lsp/completions/providers	2.576s
ok  	github.com/styrainc/regal/internal/lsp/completions/refs	2.404s
==================
WARNING: DATA RACE
Write at 0x00c000020290 by goroutine 6:
  github.com/styrainc/regal/internal/lsp/config.TestWatcher()
      /Users/anderseknert/git/styra/regal/internal/lsp/config/watcher_test.go:50 +0x61c
  testing.tRunner()
      /opt/homebrew/Cellar/go@1.22/1.22.6/libexec/src/testing/testing.go:1689 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go@1.22/1.22.6/libexec/src/testing/testing.go:1742 +0x40

Previous write at 0x00c000020290 by goroutine 7:
  github.com/styrainc/regal/internal/lsp/config.TestWatcher.func1()
      /Users/anderseknert/git/styra/regal/internal/lsp/config/watcher_test.go:32 +0x68

Goroutine 6 (running) created at:
  testing.(*T).Run()
      /opt/homebrew/Cellar/go@1.22/1.22.6/libexec/src/testing/testing.go:1742 +0x5e4
  testing.runTests.func1()
      /opt/homebrew/Cellar/go@1.22/1.22.6/libexec/src/testing/testing.go:2161 +0x80
  testing.tRunner()
      /opt/homebrew/Cellar/go@1.22/1.22.6/libexec/src/testing/testing.go:1689 +0x180
  testing.runTests()
      /opt/homebrew/Cellar/go@1.22/1.22.6/libexec/src/testing/testing.go:2159 +0x6e0
  testing.(*M).Run()
      /opt/homebrew/Cellar/go@1.22/1.22.6/libexec/src/testing/testing.go:2027 +0xb74
  main.main()
      _testmain.go:47 +0x294

Goroutine 7 (finished) created at:
  github.com/styrainc/regal/internal/lsp/config.TestWatcher()
      /Users/anderseknert/git/styra/regal/internal/lsp/config/watcher_test.go:31 +0x4f8
  testing.tRunner()
      /opt/homebrew/Cellar/go@1.22/1.22.6/libexec/src/testing/testing.go:1689 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go@1.22/1.22.6/libexec/src/testing/testing.go:1742 +0x40
==================
--- FAIL: TestWatcher (0.00s)
    testing.go:1398: race detected during execution of test
FAIL
FAIL	github.com/styrainc/regal/internal/lsp/config	0.577s
ok  	github.com/styrainc/regal/internal/lsp/hover	1.346s
ok  	github.com/styrainc/regal/internal/lsp/uri	1.296s
ok  	github.com/styrainc/regal/internal/parse	1.357s
ok  	github.com/styrainc/regal/internal/update	1.583s
ok  	github.com/styrainc/regal/internal/util	1.199s
ok  	github.com/styrainc/regal/internal/web	1.874s
ok  	github.com/styrainc/regal/pkg/config	1.753s
ok  	github.com/styrainc/regal/pkg/fixer	5.682s
ok  	github.com/styrainc/regal/pkg/fixer/fileprovider	1.587s
ok  	github.com/styrainc/regal/pkg/fixer/fixes	2.024s
ok  	github.com/styrainc/regal/pkg/hints	2.088s
ok  	github.com/styrainc/regal/pkg/linter	6.626s
ok  	github.com/styrainc/regal/pkg/reporter	1.981s
ok  	github.com/styrainc/regal/pkg/rules	1.610s
FAIL
@charlieegan3
Copy link
Member

Yes this would be good to fix, looks like at least one is related to the server's 'loadedConfig' state.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants