-
Notifications
You must be signed in to change notification settings - Fork 240
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
Capture variables in tests and add logging. #942
Conversation
My suggestion would be to remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving to not block you, but see the removal suggestion.
@@ -42,13 +43,15 @@ func TestRateLimiterSingleThreaded(t *testing.T) { | |||
if qps > float64(limit)*1.01 { | |||
t.Errorf("#%d: Too many operations per second. Expected ~%d, got %f", i, limit, qps) | |||
} | |||
log.Infof("#%d: Expected ~%d, got %f", i, limit, qps) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is redundant. The expected value is part of the test name, and the qps
only needs printing if it's not matching the expected value, which already happens 2 lines above.
Same below.
@@ -26,6 +26,7 @@ var testlimits = []int{1, 10, 50, 100, 1000} | |||
func TestRateLimiterSingleThreaded(t *testing.T) { | |||
for i, limit := range testlimits { | |||
t.Run(fmt.Sprintf("%d ops/s", limit), func(t *testing.T) { | |||
i, limit := i, limit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch.
+1 for removing them altogether. I have observed unexpected test failures where more than 2k operations per seconds happened, when there should never be more than 1k. Given the unpredictable behaviour of the current test code, I cannot tell for sure if it's because we're using |
Capture variable in tests to execute them all. It also adds logging to see how tests have performed.
Checklist