-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
test: add function mock debug populate #1693
Merged
Merged
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
start_server {tags {"scan"}} { | ||
test "SCAN basic" { | ||
r flushdb | ||
r debug populate 1000 | ||
populate 1000 | ||
#populate 1000 | ||
|
||
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. 下面这个注释需要保留吗 |
||
set cur 0 | ||
set keys {} | ||
|
@@ -19,7 +20,7 @@ start_server {tags {"scan"}} { | |
|
||
test "SCAN COUNT" { | ||
r flushdb | ||
r debug populate 1000 | ||
populate 1000 | ||
|
||
set cur 0 | ||
set keys {} | ||
|
@@ -37,7 +38,7 @@ start_server {tags {"scan"}} { | |
|
||
test "SCAN MATCH" { | ||
r flushdb | ||
r debug populate 1000 | ||
populate 1000 | ||
|
||
set cur 0 | ||
set keys {} | ||
|
@@ -56,7 +57,7 @@ start_server {tags {"scan"}} { | |
test "SCAN TYPE" { | ||
r flushdb | ||
# populate only creates strings | ||
r debug populate 1000 | ||
populate 1000 | ||
|
||
# Check non-strings are excluded | ||
set cur 0 | ||
|
@@ -214,7 +215,7 @@ start_server {tags {"scan"}} { | |
|
||
test "SCAN guarantees check under write load" { | ||
r flushdb | ||
r debug populate 100 | ||
populate 100 | ||
|
||
# We start scanning here, so keys from 0 to 99 should all be | ||
# reported at the end of the iteration. | ||
|
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.
The code patch you provided appears to add a new procedure called "populate" for debug purposes. Here are some observations and suggestions for improvement:
Error handling: It's generally recommended to handle errors gracefully and provide meaningful error messages to users. Currently, the code uses
catch
to suppress the error when executing/bin/kill -9
. Consider adding appropriate error handling or logging in case of any failures.Magic numbers: The value "-9" in the
exec
command is a magic number, which might make the code less readable and maintainable. Consider using a named constant or explaining the purpose of this value with a comment.Code formatting: Ensure consistent code formatting throughout the codebase. Inconsistent indentation can make the code harder to read and maintain. Make sure to use a consistent number of spaces or tabs for indentation.
Variable naming: Consider choosing more descriptive names for variables. For example, instead of using
counter
, you could use a name that reflects its purpose, such asiteration
.Readability: Enclose expressions involving assignment, increment, and condition checks within parentheses to improve readability. For example, in the
populate
procedure, the expression$counter < $size
would be clearer if written as($counter < $size)
.Use of quotes: Verify whether the current quotation style (
"key:$counter"
) is appropriate for the application context. Depending on the requirements, it may be necessary to use single quotes or escape special characters within the string.Documentation: Consider adding comments or docstrings to explain the purpose and functionality of the procedures, especially for the newly added
populate
procedure.Remember that without having the complete code and context, it's difficult to assess all potential bug risks or suggest further improvements. It's essential to thoroughly test the code after making any changes to ensure its correctness and performance.