From 113c98ad40a0eb88da3d9bc81bce695c662cc741 Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Mar 25 2019 09:54:07 +0000 Subject: Fix compatibility with new Pulp version. In latest Pulp version deployed internally, it is no longer possible to ask for particular sub-fields using the `fields` argument in the query. Pulp now supports only fields which directly match to its database fields in `fields` argument. The fix is simple. Instead of asking for `notes.content_set`, ODCS now asks just for `notes`. We will get more data from Pulp than we need (all `notes`, not just `notes.content_set`), but this does not break anything. --- diff --git a/server/odcs/server/pulp.py b/server/odcs/server/pulp.py index d19a6a2..26f2902 100644 --- a/server/odcs/server/pulp.py +++ b/server/odcs/server/pulp.py @@ -155,8 +155,7 @@ class Pulp(object): 'filters': { 'notes.content_set': {'$in': content_sets}, }, - 'fields': ['notes.relative_url', 'notes.content_set', - 'notes.arch', 'notes.signatures'], + 'fields': ['notes'], } } diff --git a/server/tests/test_backend.py b/server/tests/test_backend.py index 4f43c67..995bb9a 100644 --- a/server/tests/test_backend.py +++ b/server/tests/test_backend.py @@ -487,8 +487,7 @@ class TestBackend(ModelsBaseTest): expected_query = { "criteria": { - "fields": ["notes.relative_url", "notes.content_set", - "notes.arch", "notes.signatures"], + "fields": ["notes"], "filters": { "notes.content_set": {"$in": ["foo-1", "foo-2", "foo-3"]}, "notes.include_in_download_service": "True" @@ -554,8 +553,7 @@ gpgcheck=0 expected_query = { "criteria": { - "fields": ["notes.relative_url", "notes.content_set", - "notes.arch", "notes.signatures"], + "fields": ["notes"], "filters": { "notes.content_set": {"$in": ["foo-1", "foo-2"]}, } @@ -591,8 +589,7 @@ gpgcheck=0 expected_query = { "criteria": { - "fields": ["notes.relative_url", "notes.content_set", - "notes.arch", "notes.signatures"], + "fields": ["notes"], "filters": { "notes.content_set": {"$in": ["foo-1", "foo-2"]}, "notes.include_in_download_service": "True" diff --git a/server/tests/test_pulp.py b/server/tests/test_pulp.py index d4038ff..6dcfde3 100644 --- a/server/tests/test_pulp.py +++ b/server/tests/test_pulp.py @@ -45,8 +45,7 @@ class TestPulp(ModelsBaseTest): pulp_rest_post.assert_called_once_with( 'repositories/search/', {'criteria': { - 'fields': ['notes.relative_url', 'notes.content_set', - 'notes.arch', 'notes.signatures'], + 'fields': ['notes'], 'filters': { 'notes.include_in_download_service': 'True', 'notes.content_set': {'$in': ['foo-1', 'foo-2']} @@ -65,8 +64,7 @@ class TestPulp(ModelsBaseTest): pulp_rest_post.assert_called_once_with( 'repositories/search/', {'criteria': { - 'fields': ['notes.relative_url', 'notes.content_set', - 'notes.arch', 'notes.signatures'], + 'fields': ['notes'], 'filters': { 'notes.content_set': {'$in': ['foo-1', 'foo-2']} }