-
Notifications
You must be signed in to change notification settings - Fork 197
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_provenpackager_request_privs has all kinds of issues #5597
Comments
As I read the unit test, it is: bodhi/bodhi-server/tests/services/test_updates.py Lines 1546 to 1558 in f610256
creates three users: bob is a provenpackager, ralph is a normal packager, someuser is neither of both. (yes, the use of proventester is odd, I assume it refers to old terminology)
bodhi/bodhi-server/tests/services/test_updates.py Lines 1560 to 1572 in f610256
Creates an update by using user ralph .
bodhi/bodhi-server/tests/services/test_updates.py Lines 1574 to 1588 in f610256
ralph tries to submit the update to stable, but they cannot because the update has not yet reached any threshold (and it is still in pending -> testing).
bodhi/bodhi-server/tests/services/test_updates.py Lines 1590 to 1613 in f610256
Force the update into testing and post three comments with karma so that the autopush is triggered. bodhi/bodhi-server/tests/services/test_updates.py Lines 1615 to 1644 in f610256
Move the update back to testing, like autokarma was not enabled, and use bob user to push to stable and then obsolete it. As a provenpackager they must can do that, also the Update has reached the karma threshold.
The following is just a check that |
Yes, that's how I read it too - but my point is, none of that makes a lot of sense.
well, it's both old and wrong. proventester is a real thing, separate from provenpackager, which at one point had different powers (proventester feedback was more important than regular user feedback). That's been disabled approximately forever, but some of the code is still around. So saying
Yes. Why are we doing this? What is it testing that has anything to do with "proven packager request privileges", especially since we do not check whether
Yes. Why? I don't know. Do you?
Well, yeah, except it doesn't do that. A normal update in testing has a request of
Right. Note this is the first part of the test, after Pete knows how many lines, where we actually assert anything about provenpackager privileges at all. But if all we wanted to do was assert that a provenpackager could submit a stable request for a package they don't own, we could do it in way less code, without involving a named user called
yes. But why do we only test
Sure. In fact it's a relatively sane test! But it doesn't need any of the stuff that happened before it, and it has nothing to do with request privileges. It should be a separate test (or the test should be renamed to make it clearer it's testing provenpackager abilities in general). So ultimately, we agree this huge long test boils down to only three assertions about 'request privileges' at all:
The first is tested elsewhere, and probably 75% of the test isn't necessary for the second. We never test the obvious comparisons: can a provenpackager push an update stable without karma? And can a non-provenpackager who does not own an update push it stable or obsolete it? We never test And of course, if we want this to be a test of "all provenpackager capabilities", we're missing a bunch of stuff. There are other tests for provenpackager capabilities around it, so stuffing non-request-related stuff into this test doesn't seem to make much sense. There is a To me, the test kinda reads like it wanted to test that provenpackagers can push updates stable without karma, only it never actually did that. |
I assume it was meant to reach the minimum karma threshold to be able to manually push the update, but it got confused with the autopush threshold. Probably we just need two positive comments without the need of triggering the autopush. I don't remember if it was me writing that code... |
I am filing this issue because if I keep fixing every goddamn thing I come across while I'm trying to work on this pull request from hell, I'll never get done.
I'm trying to consolidate the tests for
check_karma_thresholds()
. As part of that, I've been disabling bits of it, running the test suite, and seeing what fails.If you disable the bit that actually autopushes updates when they hit autokarma,
test_provenpackager_request_privs
(frombodhi-server/tests/services/test_updates.py
) fails. So I went to look at why, and...what the hell is this thing?The immediate reason it fails is that, for some inexplicable reason, there's a block in the middle of the test where it intentionally triggers an auto-push for karma:
but there is no indication why it's doing this. There's no comment, there's no explanation in the original commit that added this test - 73c211d . It doesn't appear to have anything to do with the ostensible purpose of this test.
After it does that, the test does this:
which leaves the update in a somewhat odd state - it has +3 karma, its status is UpdateStatus.testing , and its request is UpdateRequest.testing . What?
The test has multiple other issues. It says "proventester" instead of "provenpackager" several times, which is confusing. The comments on the users could be clearer, I'd write it like this:
AFAICT, the test creates the update as ralph. Which is weird, because that will give ralph more or less the same powers as bob regarding this update. It seems like it'd be more useful to have the update owned by someone else, then make sure ralph can't do stuff to it. Or have a fourth user, so we can check the privileges of a packager who's the update owner, a packager who's not the update owner, and a provenpackager.
The test then goes on to try and submit the update to stable as ralph (the update owner), and expect to be rejected because it doesn't meet the testing requirements. OK, sure, but...next it goes on to "Pretend it was pushed to testing", then triggers the autopush to stable, then half-heartedly resets it to testing, then tries submitting it stable as bob (a provenpackager). Wat? If it tried submitting it to stable as ralph at that point, it'd work too! This assertion really isn't proving anything much. Why didn't we trying pushing stable as bob in the same circumstance as we tried pushing it stable as ralph, and vice versa?
Then it re-initializes the app as bob even though it's already bob(?!) and checks it can send an 'obsolete' request. OK, that's fine in itself.
Then it goes off on a weird tangent and starts checking who's allowed to edit the update, even though the test name and docstring claim it's supposed to be a test of setting requests. This bit was added at a later date - the original version in 73c211d didn't have it (but it did have all the other problems).
If I just remove the bit of the test where it intentionally triggers a karma autopush, it starts failing because bob cannot request stable, because the karma requirements aren't met. That, with current update policies and Bodhi code, is correct behaviour - provenpackagers don't have superpowers to push untested updates stable. I'm not sure whether, at the time, provenpackagers were meant to have such powers and that changed, or whether the test was just nonsense from the beginning - there isn't enough context on the original commit to tell. But it means I don't really know what to do with this test, I don't really want to rewrite it from scratch as part of my mostly-unrelated PR.
So, yeah, this thing needs fixing. First decide what it's actually supposed to test, then make it...actually test that. :) If it's intended to be a test that provenpackagers can submit requests on other people's updates (and that non-provenpackagers can't), great, make it more sanely that. All the stuff about who can edit updates should probably be split out.
The text was updated successfully, but these errors were encountered: