-
Notifications
You must be signed in to change notification settings - Fork 248
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
Start using -race flag in tests #453
Comments
+1 for start using race detector heavily. It's important to keep in mind that race detector can only catch the races on the path covered by tests, so tests should be implemented with it in mind. We already have some tests that target race conditions, but that's rather an exception now. Also, race detector has performance penalty up to 10x-20x in memory and execution time. Thus I suggest having a separate set of tests, probably under its own tag ( And the main challenge here still will be designing tests properly so they reflect actual program usage and cover actual code. |
@b00ris the scope of this issue is too huge, let's move step by step. Can you start from a small innocent package first and keep it really small? I'm afraid in the current setup this issue is going to take infinite time. |
@tiabc No, scope of this issue is not huge. This is issue only adding -race flag to tests and updating vendor libs to version with fixed races. I add to this issues all blocking race issues, which could be done independenly. After all blocked issues this issue could be done fastly. |
@divan I am not sure what problem do you want to resolve with As you suggested, creating a separate target in Makefile for unit tests with |
@b00ris Very nice, I like this type of issues that collect dependencies 👍 Btw. do you use ZenHub? You could set up dependencies with it and it would be easier to navigate. I would also update AC:
This is an implementation detail actually.
I am not sure we need to run e2e tests with |
@adambabik I've just finished #456 and fixed races in code of e2e tests TestNonExistentQueuedTransactions, TestNonExistentQueuedTransactions, TestDiscardMultipleQueuedTransactions, TestEvictionOfQueuedTransactions, TestCompleteTransaction. |
Actually, not. Imagine you have package with data race: package foo
var v int64
func foo() { v = 42 }
func bar() { _ = v } and test: package foo
import "testing"
func TestFoo(t *testing.T) { foo() }
func TestBar(t *testing.T) { bar() } Running That's what I meant by "should be implemented with it in mind". We need to look at the real world usage of functions being tested and ask questions like - "are foo() and bar() supposed to be called concurrently?". If so, we need either write new test that simulates this and allows race detector to catch possible races: func TestFooBar(t *testing.T) { go foo(); bar() } or instrument individual tests with func TestFoo(t *testing.T) { t.Parallel(); foo() }
func TestBar(t *testing.T) { t.Parallel(); bar() } But I agree that I may be extending the purpose of this issue too much — it's rather about "fixing existing data races" than about "improve chances to catch race detection". Anyway, that being said, another comment on:
Actually, that makes sense for many cases, because our e2e tests try to simulate real-world usage and increase chances to reveal race condition if any. But as they're mostly long-running,
Yeah, I was trying to find a sweet spot between "run tests quickly to catch implementation errors" vs "run long race-enabled testing" — first one is something that we use often (I run tests from IDE just to make sure new code didn't break anything, for example), while the second one is one-time run before submitting PR. Just having Makefile target might be enough — but our e2e tests are long-running anyway, so running it two times in CI (without and with race detector) will more than double testing time. But I agree that it'll bring some confusion, so we can go without it for now and decide later if there is benefit to adding build tags. |
@JekaMas I agree that our e2e tests itself should be free from race conditions. But if we have proper unit tests coverage and run unit tests with |
@divan Right, so we need to have proper integration tests as well, not only unit tests (that's why I was arguing about using mocks in other PRs). If any function call calls any other functions concurrently, this should be tested. That's why I think that we don't need to bring special category of "race" tests. We just need to keep that in mind writing regular unit/integration tests. How does it sound? We should put that into a document about writing tests btw. With e2e tests, I have the same concern that it will take much longer but it won't bring a lot of value because race issues should be discovered by proper unit and integration. |
@adambabik, to be honest, I never did so (implementing special category for "race" tests), but as a result, most of the tests I've written and seen are poor from the simulating real usage. At best, I just add That's why I proposed to make a tradeoff and run some tests without race detector, but again, I agree that it can bring more confusion. Let's ditch this idea for now. |
looks like a duplicate of #710, hence, closing |
Problem
We have dataraces in status-go. And don't use -race flag in tests.
Implementation
blocking issues:
External data races:
1.1) les: wg data race fixed ethereum/go-ethereum#15365
1.2) les: fix channels assignment data race ethereum/go-ethereum#15441
2.1) add mutex guard to object properties robertkrimen/otto#284
Internal data races:
Acceptance Criteria
The text was updated successfully, but these errors were encountered: