Skip to content

Commit

Permalink
Merge pull request #53 from Princeton-CDH/feature/solr8
Browse files Browse the repository at this point in the history
Address config changes and new defaults for Solr 8.
  • Loading branch information
kmcelwee committed Oct 15, 2020
2 parents 09471d9 + 17fd64a commit a594d73
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 28 deletions.
14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ jdk:
- openjdk8 # recommended jdk for solr < 7
env:
global:
- SOLR_VERSION=6.6.5
- JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 # otherwise jdk11 will be used
jobs:
- DJANGO=
- DJANGO=1.11
- DJANGO=2.0
- DJANGO=2.1
- DJANGO=2.2
# solr 8
- SOLR_VERSION=8.6.2 DJANGO=
- SOLR_VERSION=8.6.2 DJANGO=2.2
# solr 6
- SOLR_VERSION=6.6.5 DJANGO=
- SOLR_VERSION=6.6.5 DJANGO=2.2
before_install:
- pip install --upgrade pip
- pip install --upgrade pytest
Expand All @@ -37,8 +37,6 @@ script:
after_success:
- codecov
- if [[ "$TRAVIS_PULL_REQUEST" == "false" && "$TRAVIS_PYTHON_VERSION" == "3.6" ]]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi
before_cache:
- rm -rf downloads/solr-${SOLR_VERSION}
notifications:
slack:
secure: VQzciC3upnIlJPtdEo+z3LletLLsYtM2Ci76aK/ADH1wjEakiU3qNrUgqm7Cp06Hrngx4aBep7nvaRCk4nIAdE7ljGrI1HuoWqig85McIn2dEq1jM+p4rJAQNvqF949GVaJMjJUZi0pGNplDORPSh8c9NI0vzENnnM1yBqsdeA5NOV3HqLiPp49QQ8tUrt4Xy1YfmirnQOHJmwHu/vYlZpDggAaV3+MYVbhaMfHGgvC57QwyvxJjwqYYuCEZy6GDXBl/jayO0kvb0u1ZjeQ31u+JMKeg+kdzcfny8lnnJ4KcMJOAsZ/snwc+AkM6foj6oqC+I8hsVd8Dl5ebPjKU7Kmc8zjH+vBFXF3dtZ0QrtWWahe/p4mtNGDsOEGYQqhnG/ozWAgq14FQwhiJyq411gUbYSrjaeFgbevKzmGC40Diyt0h/BKRI5oeRqcSiqm+yspT8qMyH+3bt/mLpivfn2Enhj2mBSql2HYk9MZv245dUbpEKDsPFNsV2zLl8tnhUzICUPPxCBDzyebg/N3R8Zhz6YQzknDywp9gDWdPlUvzA/ZpnemSiwaedfcfFbvVY276aJO9vo57W+iHJ27OuPLCj5YJqBmQfIIa1LdgADIsGGOeuVEq+drzgoiLalR+0A4xUGw4pPM6gwAcj4/wUm2+kKeMT0QNXgG6J8HL7Ok=
15 changes: 11 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ configuration and indexing content.
:target: https://requires.io/github/Princeton-CDH/parasolr/requirements/?branch=master
:alt: Requirements Status

Currently tested against Python 3.5 and 3.6, Solr 6.6.5, and Django 1.11,
2.0, and 2.1, and without Django.
Currently tested against Python 3.5 and 3.6, Solr 6.6.5 and 8.6.2, and Django 2.2 and without Django.


Installation
Expand All @@ -74,8 +73,10 @@ To use with Django:
'default': {
'URL': 'http://localhost:8983/solr/',
'COLLECTION': 'name',
# any configSet in SOLR_ROOT/server/solr/configsets
'CONFIGSET': 'basic_configs' # optional, basic_configs is default
# Any configSet in SOLR_ROOT/server/solr/configsets.
# The default configset name is "_default" as of Solr 7.
# For Solr 6, "basic_configs" is the default.
'CONFIGSET': '_default'
}
}

Expand Down Expand Up @@ -120,6 +121,12 @@ requires a minimal settings file for Django-required configurations.
cp ci/testsettings.py.sample testsettings.py
python -c "import uuid; print('\nSECRET_KEY = \'%s\'' % uuid.uuid4())" >> testsettings.py

- By default, parasolr expects Solr 8. If running tests with an earlier
version of Solr, either explicitly change **MAJOR_SOLR_VERSION** in your
local **testsettings.py** or set the environment variable::

export SOLR_VERSION=x.x.x

- To run the test, either use the configured setup.py test command::

python setup.py test
Expand Down
7 changes: 6 additions & 1 deletion ci/testsettings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import os

MAJOR_SOLR_VERSION = int(os.environ.get('SOLR_VERSION', '8').split('.')[0])
configset = 'basic_configs' if MAJOR_SOLR_VERSION < 7 else '_default'

# minimal django settings required to run tests
DATABASES = {
Expand Down Expand Up @@ -25,12 +29,13 @@
# default config for testing pytest plugin
'URL': 'http://localhost:8983/solr/',
'COLLECTION': 'myplugin',
'CONFIGSET': configset,
'TEST': {
'URL': 'http://localhost:8983/solr/',
'COLLECTION': 'parasolr_test',
# aggressive commitWithin for test only
'COMMITWITHIN': 750,
'CONFIGSET': 'basic_configs'
'CONFIGSET': configset,
}
}
}
2 changes: 1 addition & 1 deletion parasolr/management/commands/solr_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def handle(self, *args, **kwargs):
# The error handling for ensuring there's a configuration
# has already happened, so just get default
default_solr = settings.SOLR_CONNECTIONS['default']
config_set = default_solr.get('CONFIGSET', 'basic_configs')
config_set = default_solr.get('CONFIGSET', '_default')
solr.core_admin.create(solr.collection, configSet=config_set)
else:
# if core was not created, bail out
Expand Down
2 changes: 1 addition & 1 deletion parasolr/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def configure_django_test_solr():
response = solr.core_admin.status(core=solr_config_opts['COLLECTION'])
if not response.status.get(solr_config_opts['COLLECTION'], None):
solr.core_admin.create(solr_config_opts['COLLECTION'],
configSet=solr_config_opts.get('CONFIGSET', 'basic_configs'))
configSet=solr_config_opts['CONFIGSET'])

try:
# if a schema is configured, update the test core
Expand Down
2 changes: 1 addition & 1 deletion parasolr/solr/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_client(request):
response = client.core_admin.status(core=collection)
if response.status.parasolr_test:
raise CoreExists('Test core "parasolr_test" exists, aborting!')
client.core_admin.create(collection, configSet='basic_configs')
client.core_admin.create(collection, configSet=TEST_SOLR_CONNECTION['CONFIGSET'])

def clean_up():
for field in TEST_FIELDS:
Expand Down
8 changes: 4 additions & 4 deletions parasolr/solr/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_init(self):

def test_create_unload(self, core_test_client):
test_client, core = core_test_client
test_client.core_admin.create(core, configSet='basic_configs')
test_client.core_admin.create(core, configSet=TEST_SOLR_CONNECTION['CONFIGSET'])
resp = test_client.core_admin.status(core=core)
assert not resp.initFailures
# core has a start time
Expand All @@ -31,14 +31,14 @@ def test_create_unload(self, core_test_client):
# check that additional params (for the rest of the API)
# can be used
with patch('parasolr.solr.admin.ClientBase.make_request') as mockrequest:
test_client.core_admin.create(core, configSet='basic_configs',
test_client.core_admin.create(core, configSet=TEST_SOLR_CONNECTION['CONFIGSET'],
dataDir='foo')
assert mockrequest.called
params = mockrequest.call_args[1]['params']
assert params['name'] == core
assert params['action'] == 'CREATE'
assert params['dataDir'] == 'foo'
assert params['configSet'] == 'basic_configs'
assert params['configSet'] == TEST_SOLR_CONNECTION['CONFIGSET']

def test_reload(self, test_client):
assert test_client.core_admin.reload(test_client.collection)
Expand All @@ -51,7 +51,7 @@ def test_ping(self, core_test_client, caplog):
# should not log the error since 404 is an allowed response for ping
assert not caplog.records
# create the core and then check it
solrclient.core_admin.create(core, configSet='basic_configs',
solrclient.core_admin.create(core, configSet=TEST_SOLR_CONNECTION['CONFIGSET'],
dataDir='foo')
assert solrclient.core_admin.ping(core)

Expand Down
22 changes: 14 additions & 8 deletions parasolr/solr/tests/test_schema.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from parasolr.solr.tests.conftest import settings

# NOTE: Field and field-type names must be registered and cleaned
# up in conftest.py
# Otherwise, they will be retained between test iterations and break results.


class TestSchema:

def test_add_field(self, test_client):
Expand All @@ -26,19 +29,19 @@ def test_delete_field(self, test_client):
def test_replace_fields(self, test_client):

test_client.schema.add_field(name='A', type='string')
test_client.schema.replace_field(name='A', type='int')
test_client.schema.replace_field(name='A', type='pint')
fields = test_client.schema.list_fields()
names = [f.name for f in fields]
assert fields[names.index('A')].type == 'int'
assert fields[names.index('A')].type == 'pint'


def test_list_fields(self, test_client):
test_client.schema.add_field(name='A', type='string')
test_client.schema.add_field(name='B', type='int')
test_client.schema.add_field(name='B', type='pint')
fields = test_client.schema.list_fields()
names = [f.name for f in fields]
assert fields[names.index('A')].type == 'string'
assert fields[names.index('B')].type == 'int'
assert fields[names.index('B')].type == 'pint'
# check that we can look for a subset of fields
fields = test_client.schema.list_fields(fields=['A'])
names = [f.name for f in fields]
Expand Down Expand Up @@ -77,8 +80,8 @@ def test_delete_copy_field(self, test_client):
def test_list_copy_fields(self, test_client):
test_client.schema.add_field(name='A', type='string')
test_client.schema.add_field(name='B', type='string')
test_client.schema.add_field(name='C', type='int')
test_client.schema.add_field(name='D', type='int')
test_client.schema.add_field(name='C', type='pint')
test_client.schema.add_field(name='D', type='pint')

test_client.schema.add_copy_field(source='A', dest='B')
test_client.schema.add_copy_field(source='C', dest='D')
Expand Down Expand Up @@ -168,5 +171,8 @@ def test_list_field_types(self, test_client):

def test_get_schema(self, test_client):
schema = test_client.schema.get_schema()
# check that we have the basic_configs schema
assert schema.name == 'example-basic'
# check that we have the default schema
assert schema.name == (
'default-config' if settings.MAJOR_SOLR_VERSION >= 7
else 'example-basic'
)

0 comments on commit a594d73

Please sign in to comment.