Merge pull request #2392 from coreos-inc/search-optimization

Optimize repository search by changing our lookup strategy
This commit is contained in:
josephschorr 2017-03-10 15:44:26 -05:00 committed by GitHub
commit 432b2d3fe8
9 changed files with 123 additions and 123 deletions

View file

@ -1291,7 +1291,8 @@ class V1RegistryTests(V1RegistryPullMixin, V1RegistryPushMixin, RegistryTestsMix
def test_search_pagination(self):
# Check for the first page.
resp = self.conduct('GET', '/v1/search', params=dict(q='s', n='1'))
resp = self.conduct('GET', '/v1/search', params=dict(q='s', n='1'),
auth=('devtable', 'password'))
data = resp.json()
self.assertEquals('s', data['query'])
@ -1301,17 +1302,16 @@ class V1RegistryTests(V1RegistryPullMixin, V1RegistryPushMixin, RegistryTestsMix
self.assertEquals(1, data['page'])
self.assertTrue(data['num_pages'] > 1)
# Check for the followup pages.
for page_index in range(1, data['num_pages']):
resp = self.conduct('GET', '/v1/search', params=dict(q='s', n='1', page=page_index))
data = resp.json()
self.assertEquals('s', data['query'])
# Check for the followup page.
resp = self.conduct('GET', '/v1/search', params=dict(q='s', n='1', page=2),
auth=('devtable', 'password'))
data = resp.json()
self.assertEquals('s', data['query'])
self.assertEquals(1, data['num_results'])
self.assertEquals(1, len(data['results']))
self.assertEquals(1, data['num_results'])
self.assertEquals(1, len(data['results']))
self.assertEquals(1, data['page'])
self.assertTrue(data['num_pages'] > 1)
self.assertEquals(2, data['page'])
def test_users(self):

View file

@ -971,11 +971,11 @@ class TestConductSearch(ApiTestCase):
params=dict(query='public'))
self.assertEquals(2, len(json['results']))
self.assertEquals(json['results'][0]['kind'], 'user')
self.assertEquals(json['results'][0]['name'], 'public')
self.assertEquals(json['results'][0]['kind'], 'repository')
self.assertEquals(json['results'][0]['name'], 'publicrepo')
self.assertEquals(json['results'][1]['kind'], 'repository')
self.assertEquals(json['results'][1]['name'], 'publicrepo')
self.assertEquals(json['results'][1]['kind'], 'user')
self.assertEquals(json['results'][1]['name'], 'public')
json = self.getJsonResponse(ConductSearch,
params=dict(query='owners'))