-
Notifications
You must be signed in to change notification settings - Fork 13
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
Django 4 support: Option 5, migrating to django-filter (v2) #492
Conversation
Nope, still no tests. |
lgtm 👍 |
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.
Has this been tested with the mreg-cli test suite? It uses quite a lot of api calls with filtering.
Also lots and lots of unrelated changes to Django 4 / django-filter.
CI=True | ||
passenv = MREG_*, GITHUB_* | ||
deps = | ||
-r{toxinidir}/requirements-test.txt |
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.
Add -r{toxinidir}/requirements.txt
and only have test depedencies in requirements-test.txt
.
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 main downside is that we then have to open up the django version directly in requirements.txt
to test against multiple versions of django. Otherwise we run into dependency conflicts. I opted to keep the version locked for now in prod.
To resolve the issue of tests not running, there was a suggestion to merge in from master, but for some reason it became individual commits and not a merge commit. :( And yeah, testing against mreg-cli is a good idea. |
I prefer that you don't merge in from master, instead rebase the feature branch on top of master. |
I prefer that as well. I'll look at cleaning this up. I'm honestly not sure what happened. There was a conflict and continue really didn't do what I expected. I'll rebase and reapply. |
For some reason, two commits from me have ended up as part of this branch. They are already in the master branch (b09877b and 749d096) so they can safely be removed from this branch. @terjekv I volunteer to pull this branch from your repo into the main repo, and rebase it and remove the unnecessary commits at the same time. That would probably fix the workflow trigger problem we've been struggling with too. Let me know if that's okay |
d5e3d56
to
ae7fc74
Compare
@oyvindhagberg I may just have broken that by doing a clean rebase and force push. :( |
ae7fc74
to
744946e
Compare
The JSON interface in particular needs testing before this can get anywhere. |
Regarding mreg contains a plethora of unit tests, so in my opinion that should be sufficient, but of course the more tests the better. I propose to:
It will be a while before I can carve out some time to do this. It's up to you whether this PR has to wait for that or not. |
I was thinking the same. This is a very very good idea. The PR can wait. There are fairly fundamental changes involved. |
69bd357
to
f90e036
Compare
f90e036
to
61a57fa
Compare
Finally, we have the new mreg-cli testing regime in place, and I've been able to run the test suite (a list of mreg-cli commands) towards this branch of mreg and compared the results. That uncovered a bug: It seems the API endpoint for hostgroups returns a different group than what was asked for. Perhaps the filter doesn't work. Here's an excerpt from a log that shows the http request and response: {
"method": "GET",
"url": "/api/v1/hostgroups/?name=yourgroup",
"data": {},
"status": 200,
"response": {
"count": 1,
"next": null,
"previous": null,
"results": [
{
"parent": [],
"groups": [],
"hosts": [
{
"name": "testhost1.example.org"
}
],
"owners": [
{
"name": "myself"
}
],
"name": "mygroup",
"description": "This describes the group"
}
]
}
}, |
Huh. That was interesting. I'll have a look at it, great work! |
61a57fa
to
303999f
Compare
Should be fixed in 303999f |
Couple of conflicts now after the previous PR was merged. If you fix those I can run the mreg-cli tests again |
6b99cd4
to
e11bd45
Compare
There we go, ready for testing. |
We have to find out why uploading to Coveralls suddenly fails... The branch is out of date anyway, so maybe rebase after #502 is merged and see if it works better then. |
e11bd45
to
540d5bd
Compare
@oyvindhagberg Huh. This was fascinating. Any idea what is going on here? https://github.com/unioslo/mreg/actions/runs/5314852531/jobs/9622678184?pr=492#step:7:4567 |
It looks like https://github.com/unioslo/mreg-cli/blob/51594309f34385c85940c248243f6343823efc77/mreg_cli/dhcp.py#L39 assumes we get at least one IP address. That kind of makes sense, as mreg shouldn't give it broken data, but mreg-cli shouldn't crash either way. |
I'll try and fix that in mreg-cli so we can run the tests again. |
I'm honestly finding it a bit hard follow the mreg-cli tests. I'd love to be able to see something like this (example only, this isn't a valid flow):
We may also have to add some information about the user performing the action. This would make it a lot easier to follow failing tests and find the source of the failure. Here we see the the creation fails, so the delete is a continuation of the same error. This would also make it easier to "copy" over the tests to mreg. Oh, and we might also need state overview (ie, what else is in the database during a failure). We could store the state of the system as an artifact that is parseable. Hm. |
I agree, the output from the mreg cli tests right now is just a byproduct of the commands that are being run, and isn't very useful. The actual useful information is found in the file |
6df5a61
to
6ee17bc
Compare
6ee17bc
to
a01293e
Compare
a01293e
to
5495978
Compare
5495978
to
d1fcbf5
Compare
Supports: python3.7+, django 3.2+. Tests included for this range. Breaking changes: None This implementation uses django-filter as intended. It sets a default filter backend and uses standard filter_class models where possible. Exceptions take place in the following views: HostList. Relies on manipulating the queryset, and said manipulation is also used in the filter-less HostDetail. *Zone*List. The abstraction model for these views is based around propagating a filterset into the parent class. Concerns: This patch creates explicit mapping filters for JSONField and CIDRField. It is unclear how well-tested these are.
- Required as we intriduced the toml file for ruff. - Sets some default keys. - Make tox.ini use the lint and coverage environments. - Make tox runs that use pythons and django show versions for both.
- Uses filterset_class correctly. - Applies the filter via MregMixin. - Test basic filtering in hostgroups.
- Requires manual lookup declarations. - See unioslo#489 (comment)
d1fcbf5
to
bd4fe41
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.
Recently switched to trunk based development so the master branch is now considered development.
Fixes #487 by implementing option 5 in the issue.
Implements django-filter as a replacement django-url-filter
Supports: python3.7+, django 3.2+. Tests included for this range.
Breaking changes: None
This implementation uses django-filter as intended. It sets a default filter backend and uses standard filter_class models where possible.
Exceptions to this implementation rule take place in the following views:
Concerns:
This patch creates explicit mapping filters for JSONField and CIDRField. It is unclear how well-tested these are.
(This is a replacement for #491)