-
Notifications
You must be signed in to change notification settings - Fork 192
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
Ensure verdi group show --limit
respects limit even in raw mode
#4092
Ensure verdi group show --limit
respects limit even in raw mode
#4092
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #4092 +/- ##
===========================================
- Coverage 78.81% 78.79% -0.01%
===========================================
Files 463 463
Lines 34413 34413
===========================================
- Hits 27119 27114 -5
- Misses 7294 7299 +5
Continue to review full report at Codecov.
|
The code is affected by the `--limit` flag both where the `--raw` flag is enabled and if it is disabled. However, in the disabled case the limit was not respected. This was not detected because the unit test only tested the code path when `--raw` is enabled.
82ecf9f
to
dab183a
Compare
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.
All good!
self.assertTrue(not (str(nodes[0].pk) in result.output and str(nodes[1].pk) in result.output)) | ||
|
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.
Perhaps the second assert could be replaced by checking the length of the output to be 1? Feels a bit more straighforward and easy to read than the negative of the intersection (although less logically-fancy). Also it feels a bit more resistant to the DB leackeages that sometimes ocurr with the tests. Idk, just an idea, up to you.
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 would agree that that would be easier, except, unfortunately, in this case the output is not a list. It is a single string. That is the reason I used --raw
before in the original test, so I would only get the nodes as rows, so I could exactly use the count. But that caused the hiding of the bug that this very PR resolves. So I cannot use --raw
and so I have to "parse" the full string, or at best the lines of the result. Since I don't want to make the parsing dependent on the number of header and footer lines, I solved it like this.
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.
Uhm, I see, I didn't notice the string casting. Question: although I guess very unlikely, but this way of checking with strings could raise a false fail if the nodes were assigned, say, pk=1 and pk=12, because both "12" and "1" are in "12", correct?
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.
Well they should get adjacent identifiers, but that is besides the point. You are correct that this test is vulnerable to false positives, but also to false negatives.
Fixes #4091
The code is affected by the
--limit
flag both where the--raw
flagis enabled and if it is disabled. However, in the disabled case the
limit was not respected. This was not detected because the unit test
only tested the code path when
--raw
is enabled.