-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[staticcheck] Cleanup deprecations #13898
Merged
ajm188
merged 6 commits into
vitessio:main
from
planetscale:andrew/staticcheck-deprecations
Aug 31, 2023
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0482611
update deprecated grpc dial options
e38becd
replace deprecated strings.Title with recommended replacement
07a12fc
RevokedCertificates=>RevokedCertificateEntries
8e554c7
Stop seeding rand with timestamps, it no longer auto-seeds with a con…
97ed3fc
fix bad seed
ac10ae1
messed up the condition order, also fix seeding rand
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ import ( | |
"testing" | ||
) | ||
|
||
func checkDistribution(t *testing.T, data []*net.SRV, margin float64) { | ||
func checkDistribution(t *testing.T, rand *rand.Rand, data []*net.SRV, margin float64) { | ||
sum := 0 | ||
for _, srv := range data { | ||
sum += int(srv.Weight) | ||
|
@@ -36,7 +36,7 @@ func checkDistribution(t *testing.T, data []*net.SRV, margin float64) { | |
for j := 0; j < count; j++ { | ||
d := make([]*net.SRV, len(data)) | ||
copy(d, data) | ||
byPriorityWeight(d).shuffleByWeight() | ||
byPriorityWeight(d).shuffleByWeight(rand) | ||
key := d[0].Target | ||
results[key] = results[key] + 1 | ||
} | ||
|
@@ -54,12 +54,11 @@ func checkDistribution(t *testing.T, data []*net.SRV, margin float64) { | |
} | ||
|
||
func testUniformity(t *testing.T, size int, margin float64) { | ||
rand.Seed(1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh duh, here's my problem |
||
data := make([]*net.SRV, size) | ||
for i := 0; i < size; i++ { | ||
data[i] = &net.SRV{Target: fmt.Sprintf("%c", 'a'+i), Weight: 1} | ||
} | ||
checkDistribution(t, data, margin) | ||
checkDistribution(t, rand.New(rand.NewSource(1)), data, margin) | ||
} | ||
|
||
func TestUniformity(t *testing.T) { | ||
|
@@ -70,13 +69,12 @@ func TestUniformity(t *testing.T) { | |
} | ||
|
||
func testWeighting(t *testing.T, margin float64) { | ||
rand.Seed(1) | ||
data := []*net.SRV{ | ||
{Target: "a", Weight: 60}, | ||
{Target: "b", Weight: 30}, | ||
{Target: "c", Weight: 10}, | ||
} | ||
checkDistribution(t, data, margin) | ||
checkDistribution(t, rand.New(rand.NewSource(1)), data, margin) | ||
} | ||
|
||
func TestWeighting(t *testing.T) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Given that the new
golang
behavior is to auto-seed the random generator on startup, why would we want to pass arand * Rand
argument to these functions? Wouldn't we just want them to generate random values as opposed to deterministic ones?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.
there were a few test cases that relied on
rand.Seed(1)
before the start of the test, so we update this function to take a rand instance which is either seeded to 1 or to time.Now() (aka "random value")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'm just hesitant to require this additional argument in the function signature. Is it possible to modify the tests to not rely on a reproducible ordering?
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 hear you, but I am hesitant to change it, and my brief read (without fully digging in/understanding, so admitting that up front) seems to be that it is definitionally dependent on randomness: https://github.com/vitessio/vitess/pull/42/files#diff-b0fbcaba3872685e058eab7c65e0397e27dab0b0df92694e46fbcb67be911f28
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.
Yeah, forget it, I notice that these functions are only called internally in the same file (and in the unit test file), so not worth bothering.