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

opa test --bench panics on failing test #7205

Open
anderseknert opened this issue Dec 4, 2024 · 3 comments
Open

opa test --bench panics on failing test #7205

anderseknert opened this issue Dec 4, 2024 · 3 comments
Labels

Comments

@anderseknert
Copy link
Member

Tested with both v0.70.0 and current main. While I think --bench is meant to work with successful tests only, it seems like the error handling is borked.

b.rego

package b

import rego.v1

x := true

test_x if {
    not x
}
> opa test b.rego --bench
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x10460281c]

goroutine 28 [running]:
testing.(*common).decorate(0x1400004fbe8?, {0x140003962d0, 0x29}, 0x1054439e0?)
	/opt/homebrew/Cellar/go/1.23.3/libexec/src/testing/testing.go:775 +0x9c
testing.(*common).logDepth(0x1400037fb88, {0x140003962d0, 0x29}, 0x3)
	/opt/homebrew/Cellar/go/1.23.3/libexec/src/testing/testing.go:1042 +0x150
testing.(*common).log(...)
	/opt/homebrew/Cellar/go/1.23.3/libexec/src/testing/testing.go:1011
testing.(*common).Fatal(0x1400037fb88, {0x1400004fee0?, 0x105670898?, 0x140003812d0?})
	/opt/homebrew/Cellar/go/1.23.3/libexec/src/testing/testing.go:1082 +0x50
github.com/open-policy-agent/opa/tester.(*Runner).runBenchmark.func1(0x1400037fb88)
	/Users/anderseknert/git/opa/opa/tester/runner.go:588 +0x36c
testing.(*B).runN(0x1400037fb88, 0x1)
	/opt/homebrew/Cellar/go/1.23.3/libexec/src/testing/benchmark.go:193 +0x128
testing.(*B).run1.func1()
	/opt/homebrew/Cellar/go/1.23.3/libexec/src/testing/benchmark.go:215 +0x4c
created by testing.(*B).run1 in goroutine 26
	/opt/homebrew/Cellar/go/1.23.3/libexec/src/testing/benchmark.go:208 +0x90

If I change the test to succeed, the command works as expected.

@ashutosh-narkar
Copy link
Member

Looks like it's hitting this case.

@anderseknert
Copy link
Member Author

Yes, but how does that turn into a panic / nil dereference? 🤔

@ashutosh-narkar
Copy link
Member

I haven't checked the code but are there any other goroutines running?

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

No branches or pull requests

2 participants