Skip to content
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

SolrCoreAdmin malfunction #186

Closed
pdelboca opened this issue Mar 4, 2016 · 2 comments
Closed

SolrCoreAdmin malfunction #186

pdelboca opened this issue Mar 4, 2016 · 2 comments
Labels

Comments

@pdelboca
Copy link

pdelboca commented Mar 4, 2016

Using the SolrCoreAdmin I have spotted some errors. (I'm glad to fix them with some guidance.)

Problem:

When calling the _get_url method, the params argument is being use to override the data argument of requests.get(). It should be used to replace the params argument instead.

This is the current code:

def _get_url(self, url, params={}, headers={}):
        resp = requests.get(url, data=safe_urlencode(params), headers=headers)
        return force_unicode(resp.content)

This causes all the methods of the SolrCoreAdmin to malfunction because they call only the URL (http://localhost:8983/solr/admin/cores) without the parameters. The tests check if the response of those calls contains ''<int name="status">0</int>'', however, when calling to the URL without the parameters Solr responses with some data about the cluster and always returns status = 0. So tests aren't actually testing correctly neither.

I'm missing something important here o is this a bug in this class? If so...

Proposal:

Changing requests.get to use params instead of data will make the _get_url work properly. After that I will need to fix all tests.

Any suggestion / warning?

@nikos
Copy link

nikos commented May 2, 2017

When using Solr 6.5.1 with pysolr the core admin functionality seems still not to work properly. It seems like the problem has not been fixed on the master branch yet.

When switching the implementation of _get_url (params=params) as proposed by @pdelboca the corresponding test cases are failing:

======================================================================
FAIL: test_create (tests.test_admin.SolrCoreAdminTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/niko/sandbox/python/pysolr/tests/test_admin.py", line 21, in test_create
    self.assertTrue('<int name="status">0</int>' in status)
AssertionError: False is not true

======================================================================
FAIL: test_reload (tests.test_admin.SolrCoreAdminTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/niko/sandbox/python/pysolr/tests/test_admin.py", line 24, in test_reload
    self.assertTrue('<int name="status">0</int>' in self.solr_admin.reload('wheatley'))
AssertionError: False is not true

======================================================================
FAIL: test_rename (tests.test_admin.SolrCoreAdminTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/niko/sandbox/python/pysolr/tests/test_admin.py", line 28, in test_rename
    self.assertTrue('<int name="status">0</int>' in self.solr_admin.rename('wheatley', 'rick'))
AssertionError: False is not true

======================================================================
FAIL: test_swap (tests.test_admin.SolrCoreAdminTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/niko/sandbox/python/pysolr/tests/test_admin.py", line 33, in test_swap
    self.assertTrue('<int name="status">0</int>' in self.solr_admin.swap('wheatley', 'rick'))
AssertionError: False is not true

----------------------------------------------------------------------
Ran 96 tests in 2.386s

FAILED (failures=4, skipped=41)

The response message from the create core call looks like:

<response>
<lst name="responseHeader"><int name="status">400</int><int name="QTime">13</int></lst><lst name="error"><str name="msg">Error CREATEing SolrCore 'wheatley': Unable to create core [wheatley] Caused by: Can't find resource 'solrconfig.xml' in classpath or '/Users/niko/sandbox/python/pysolr/solr/non-cloud/wheatley/conf'</str><int name="code">400</int></lst>
</response>

@stale
Copy link

stale bot commented Jun 5, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 5, 2018
@stale stale bot closed this as completed Jul 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants