Added --elasticsearch argument to runtests.py

pull/1914/head
Karl Hobley 2015-11-09 12:13:07 +00:00
rodzic 126761db51
commit 7459329d93
3 zmienionych plików z 15 dodań i 17 usunięć

Wyświetl plik

@ -92,16 +92,19 @@ the tests against it.
To test Elasticsearch, you need to have the ``elasticsearch`` package installed.
Once installed, Wagtail will attempt to connect to a local instance of
Elasticsearch (``http://localhost:9200``) and use the index ``test_wagtail``.
Once installed, you can test Wagtail with Elasticsearch by passing the
``--elasticsearch`` argument to ``runtests.py``::
python runtests.py --elasticsearch
Wagtail will attempt to connect to a local instance of Elasticsearch
(``http://localhost:9200``) and use the index ``test_wagtail``.
If your Elasticsearch instance is located somewhere else, you can set the
``ELASTICSEARCH_URL`` environment variable to point to its location::
ELASTICSEARCH_URL=http://my-elasticsearch-instance:9200 python runtests.py
If you no longer want Wagtail to test against Elasticsearch, uninstall the
``elasticsearch`` package.
ELASTICSEARCH_URL=http://my-elasticsearch-instance:9200 python runtests.py --elasticsearch
Compiling static assets
~~~~~~~~~~~~~~~~~~~~~~~

Wyświetl plik

@ -22,6 +22,10 @@ def runtests():
os.environ['DATABASE_ENGINE'] = 'django.db.backends.postgresql_psycopg2'
args.remove('--postgres')
if '--elasticsearch' in args:
os.environ.setdefault('ELASTICSEARCH_URL', 'http://localhost:9200')
args.remove('--elasticsearch')
argv = sys.argv[:1] + ['test'] + args
try:
execute_from_command_line(argv)

Wyświetl plik

@ -157,23 +157,14 @@ WAGTAILSEARCH_BACKENDS = {
AUTH_USER_MODEL = 'customuser.CustomUser'
try:
# Only add Elasticsearch backend if the elasticsearch-py library is installed
import elasticsearch # noqa
# Import succeeded, add an Elasticsearch backend
if 'ELASTICSEARCH_URL' in os.environ:
WAGTAILSEARCH_BACKENDS['elasticsearch'] = {
'BACKEND': 'wagtail.wagtailsearch.backends.elasticsearch',
'URLS': [os.environ['ELASTICSEARCH_URL']],
'TIMEOUT': 10,
'max_retries': 1,
'AUTO_UPDATE': False,
}
if 'ELASTICSEARCH_URL' in os.environ:
WAGTAILSEARCH_BACKENDS['elasticsearch']['URLS'] = [os.environ['ELASTICSEARCH_URL']]
except ImportError:
pass
WAGTAIL_SITE_NAME = "Test Site"